Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
JSI_Network Namespace Reference

Functions

std::uint16_t GetDefaultPort ()
 
bool IsNetController ()
 
bool HasNetServer ()
 
bool HasNetClient ()
 
void StartNetworkHost (const CStrW &playerName, const std::uint16_t serverPort, const CStr &password, const bool continueSavedGame, bool storeReplay)
 
void StartNetworkJoin (const CStrW &playerName, const CStr &serverAddress, std::uint16_t serverPort, bool storeReplay)
 
void StartNetworkJoinLobby (const CStrW &playerName, const CStr &hostJID, const CStr &password)
 Requires XmppClient to send iq request to the server to get server's ip and port based on passed password. More...
 
void DisconnectNetworkGame ()
 
CStr GetPlayerGUID ()
 
JS::Value PollNetworkClient (const Script::Interface &guiInterface)
 
void SendGameSetupMessage (const Script::Interface &scriptInterface, JS::HandleValue attribs1)
 
void AssignNetworkPlayer (int playerID, const CStr &guid)
 
void KickPlayer (const CStrW &playerName, bool ban)
 
void SendNetworkChat (const Script::Request &rq, const CStrW &message, JS::HandleValue handle)
 
void SendNetworkReady (int message)
 
void ClearAllPlayerReady ()
 
void StartNetworkGame (const Script::Interface &scriptInterface, JS::HandleValue savegame, JS::HandleValue attribs1)
 
void SetTurnLength (int length)
 
void SendNetworkFlare (JS::HandleValue position)
 
void RegisterScriptFunctions (const Script::Request &rq)
 

Function Documentation

◆ AssignNetworkPlayer()

void JSI_Network::AssignNetworkPlayer ( int  playerID,
const CStr &  guid 
)

◆ ClearAllPlayerReady()

void JSI_Network::ClearAllPlayerReady ( )

◆ DisconnectNetworkGame()

void JSI_Network::DisconnectNetworkGame ( )

◆ GetDefaultPort()

std::uint16_t JSI_Network::GetDefaultPort ( )

◆ GetPlayerGUID()

CStr JSI_Network::GetPlayerGUID ( )

◆ HasNetClient()

bool JSI_Network::HasNetClient ( )

◆ HasNetServer()

bool JSI_Network::HasNetServer ( )

◆ IsNetController()

bool JSI_Network::IsNetController ( )

◆ KickPlayer()

void JSI_Network::KickPlayer ( const CStrW &  playerName,
bool  ban 
)

◆ PollNetworkClient()

JS::Value JSI_Network::PollNetworkClient ( const Script::Interface &  guiInterface)

◆ RegisterScriptFunctions()

void JSI_Network::RegisterScriptFunctions ( const Script::Request &  rq)

◆ SendGameSetupMessage()

void JSI_Network::SendGameSetupMessage ( const Script::Interface &  scriptInterface,
JS::HandleValue  attribs1 
)

◆ SendNetworkChat()

void JSI_Network::SendNetworkChat ( const Script::Request &  rq,
const CStrW &  message,
JS::HandleValue  handle 
)

◆ SendNetworkFlare()

void JSI_Network::SendNetworkFlare ( JS::HandleValue  position)

◆ SendNetworkReady()

void JSI_Network::SendNetworkReady ( int  message)

◆ SetTurnLength()

void JSI_Network::SetTurnLength ( int  length)

◆ StartNetworkGame()

void JSI_Network::StartNetworkGame ( const Script::Interface &  scriptInterface,
JS::HandleValue  savegame,
JS::HandleValue  attribs1 
)

◆ StartNetworkHost()

void JSI_Network::StartNetworkHost ( const CStrW &  playerName,
const std::uint16_t  serverPort,
const CStr &  password,
const bool  continueSavedGame,
bool  storeReplay 
)

Password security - we want 0 A.D. to protect players from malicious hosts. We assume that clients might mistakenly send a personal password instead of the game password (e.g. enter their mail account's password on autopilot). Malicious dedicated servers might be set up to farm these failed logins and possibly obtain user credentials. Therefore, we hash the passwords on the client side before sending them to the server. This still makes the passwords potentially recoverable, but makes it much harder at scale. To prevent the creation of rainbow tables, hash with:

  • the host name
  • the client name (this makes rainbow tables completely unworkable unless a specific user is targeted, but that would require both computing the matching rainbow table and for that specific user to mistype a personal password, at which point we assume the attacker would/could probably just rather use another means of obtaining the password).
  • the password itself
  • the engine version (so that the hashes change periodically) TODO: it should be possible to implement SRP or something along those lines to completely protect from this, but the cost/benefit ratio is probably not worth it.

◆ StartNetworkJoin()

void JSI_Network::StartNetworkJoin ( const CStrW &  playerName,
const CStr &  serverAddress,
std::uint16_t  serverPort,
bool  storeReplay 
)

◆ StartNetworkJoinLobby()

void JSI_Network::StartNetworkJoinLobby ( const CStrW &  playerName,
const CStr &  hostJID,
const CStr &  password 
)

Requires XmppClient to send iq request to the server to get server's ip and port based on passed password.

This is needed to not force server to share it's public ip with all potential clients in the lobby. XmppClient will also handle logic after receiving the answer.