Pyrogenesis  trunk
Functions
JSI_Network Namespace Reference

Functions

u16 GetDefaultPort ()
 
bool IsNetController ()
 
bool HasNetServer ()
 
bool HasNetClient ()
 
void StartNetworkHost (const ScriptRequest &rq, const CStrW &playerName, const u16 serverPort, bool useSTUN, const CStr &password, bool storeReplay)
 
void StartNetworkJoin (const ScriptRequest &rq, const CStrW &playerName, const CStr &serverAddress, u16 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 ScriptInterface &guiInterface)
 
void SendGameSetupMessage (const ScriptInterface &scriptInterface, JS::HandleValue attribs1)
 
void AssignNetworkPlayer (int playerID, const CStr &guid)
 
void KickPlayer (const CStrW &playerName, bool ban)
 
void SendNetworkChat (const CStrW &message)
 
void SendNetworkReady (int message)
 
void ClearAllPlayerReady ()
 
void StartNetworkGame (const ScriptInterface &scriptInterface, JS::HandleValue attribs1)
 
void SetTurnLength (int length)
 
void RegisterScriptFunctions (const ScriptRequest &rq)
 Registers the functions of the JavaScript interface for internationalization and localization into the specified JavaScript context. More...
 

Function Documentation

◆ AssignNetworkPlayer()

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

◆ ClearAllPlayerReady()

void JSI_Network::ClearAllPlayerReady ( )

◆ DisconnectNetworkGame()

void JSI_Network::DisconnectNetworkGame ( )

◆ GetDefaultPort()

u16 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 ScriptInterface guiInterface)

◆ RegisterScriptFunctions()

void JSI_Network::RegisterScriptFunctions ( const ScriptRequest rq)

Registers the functions of the JavaScript interface for internationalization and localization into the specified JavaScript context.

Parameters
ScriptRequestScript Request where RegisterScriptFunctions() registers the functions.
See also
GuiScriptingInit()

◆ SendGameSetupMessage()

void JSI_Network::SendGameSetupMessage ( const ScriptInterface scriptInterface,
JS::HandleValue  attribs1 
)

◆ SendNetworkChat()

void JSI_Network::SendNetworkChat ( const CStrW &  message)

◆ SendNetworkReady()

void JSI_Network::SendNetworkReady ( int  message)

◆ SetTurnLength()

void JSI_Network::SetTurnLength ( int  length)

◆ StartNetworkGame()

void JSI_Network::StartNetworkGame ( const ScriptInterface scriptInterface,
JS::HandleValue  attribs1 
)

◆ StartNetworkHost()

void JSI_Network::StartNetworkHost ( const ScriptRequest rq,
const CStrW &  playerName,
const u16  serverPort,
bool  useSTUN,
const CStr &  password,
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 ScriptRequest rq,
const CStrW &  playerName,
const CStr &  serverAddress,
u16  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.