Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
NetServer.h
Go to the documentation of this file.
1/* Copyright (C) 2026 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef NETSERVER_H
19#define NETSERVER_H
20
21#include "lib/code_annotation.h"
22#include "lib/config2.h"
23#include "network/NetHost.h"
24#include "ps/CStr.h"
25
26#include <ctime>
27#include <js/RootingAPI.h>
28#include <js/TypeDecls.h>
29#include <js/Value.h>
30#include <mutex>
31#include <optional>
32#include <set>
33#include <string>
34#include <thread>
35#include <unordered_map>
36#include <utility>
37#include <vector>
38
39class CNetMessage;
42class CNetStatsTable;
43class CPlayerAssignmentMessage;
45namespace Script { class Interface; }
46namespace Script { class Request; }
47template <typename MessageType> class CFsmEvent;
48
50{
51 // The server is open and accepting connections. This is the screen where
52 // rules are set up by the operator and where players join and select civs
53 // and stuff.
55
56 // All the hosts are connected and are loading the game
58
59 // The one with all the killing ;-)
61
62 // The game is over and someone has won. Players might linger to chat or
63 // download the replay log.
65};
66
67/**
68 * Server session representation of client state
69 */
71{
72 // The client has disconnected or been disconnected
74
75 // The client has just connected and we're waiting for its handshake message,
76 // to agree on the protocol version
78
79 // The client has handshook and we're waiting for its lobby authentication message
81
82 // The client has handshook and we're waiting for its authentication message,
83 // to find its name and check its password etc
85
86 // The client has fully joined, and is in the pregame setup stage
87 // or is loading the game.
88 // Server must be in SERVER_STATE_PREGAME or SERVER_STATE_LOADING.
90
91 // The client has authenticated but the game was already started,
92 // so it's synchronising with the game state from other clients
94
95 // The client is running the game.
96 // Server must be in SERVER_STATE_LOADING or SERVER_STATE_INGAME.
98};
99
100/**
101 * Network server worker thread.
102 * (This is run in a thread so that client/server communication is not delayed
103 * by the host player's framerate - the only delay should be the network latency.)
104 *
105 * Thread-safety:
106 * - Constructor/destructor must be called from the main thread.
107 * - The main thread may push commands onto the Queue members,
108 * while holding the m_WorkerMutex lock.
109 * - Public functions (SendMessage, Broadcast) must be called from the network
110 * server thread.
111 */
113{
115
116public:
117 // Public functions for CNetSession/CNetServerTurnManager to use:
118
119 /**
120 * Send a message to the given network peer.
121 */
122 bool SendMessage(ENetPeer* peer, const CNetMessage* message);
123
124 /**
125 * Disconnects a player from gamesetup or session.
126 */
127 void KickPlayer(const CStrW& playerName, const bool ban);
128
129 /**
130 * Send a message to all clients who match one of the given states.
131 */
132 bool Multicast(const CNetMessage* message, const std::vector<NetServerSessionState>& targetStates,
133 const std::optional<std::vector<std::string>>& receivers = std::nullopt);
134
135private:
136 friend class CNetServer;
137
138 CNetServerWorker(const bool continuesSavedGame, std::uint16_t port, const bool useLobbyAuth,
139 std::string password, std::string controllerSecret, std::string initAttributes,
140 std::set<std::string> buddies);
142
143 bool CheckPassword(const std::string& password, const std::string& salt) const;
144
145 /**
146 * The given GUID will be (re)assigned to the given player ID.
147 * Any player currently using that ID will be unassigned.
148 */
149 void AssignPlayer(int playerID, const CStr& guid);
150
151 /**
152 * Switch in game mode. The clients will have to be notified to start the
153 * game. This method is called by StartGame and StartSavedGame
154 */
155 void PreStartGame(const CStr& initAttribs);
156
157 /**
158 * Switch in game mode and notify all clients to start the game.
159 */
160 void StartGame(const CStr& initAttribs);
161
162 /**
163 * Switch in game mode and notify all clients to start the saved game.
164 */
165 void StartSavedGame(const CStr& initAttribs);
166
167 /**
168 * Make a player name 'nicer' by limiting the length and removing forbidden characters etc.
169 */
170 static CStrW SanitisePlayerName(const CStrW& original);
171
172 /**
173 * Make a player name unique, if it matches any existing session's name.
174 */
175 CStrW DeduplicatePlayerName(const CStrW& original);
176
177 /**
178 * Get the script context used for init attributes.
179 */
181
182 /**
183 * Set the turn length to a fixed value.
184 * TODO: we should replace this with some adaptive lag-dependent computation.
185 */
186 void SetTurnLength(std::uint32_t msecs);
187
188 void ProcessLobbyAuth(const CStr& name, const CStr& token);
189
190 void AddPlayer(const CStr& guid, const CStrW& name);
191 void RemovePlayer(const CStr& guid);
193 void ClearAllPlayerReady();
194
195 void SetupSession(CNetServerSession* session);
196 bool HandleConnect(CNetServerSession* session);
197
198 void OnUserJoin(CNetServerSession* session);
199 void OnUserLeave(CNetServerSession* session);
200
201 static bool OnClientHandshake(CNetServerSession* session, CFsmEvent<CNetMessage*>* event);
202 static bool OnAuthenticate(CNetServerSession* session, CFsmEvent<CNetMessage*>* event);
204 static bool OnFlare(CNetServerSession* session, CFsmEvent<CNetMessage*>* event);
205 static bool OnSyncCheck(CNetServerSession* session, CFsmEvent<CNetMessage*>* event);
206 static bool OnEndCommandBatch(CNetServerSession* session, CFsmEvent<CNetMessage*>* event);
207 static bool OnChat(CNetServerSession* session, CFsmEvent<CNetMessage*>* event);
208 static bool OnReady(CNetServerSession* session, CFsmEvent<CNetMessage*>* event);
209 static bool OnClearAllReady(CNetServerSession* session, CFsmEvent<CNetMessage*>* event);
210 static bool OnGameSetup(CNetServerSession* session, CFsmEvent<CNetMessage*>* event);
211 static bool OnAssignPlayer(CNetServerSession* session, CFsmEvent<CNetMessage*>* event);
212 static bool OnGameStart(CNetServerSession* session, CFsmEvent<CNetMessage*>* event);
213 static bool OnSavedGameStart(CNetServerSession* session, CFsmEvent<CNetMessage*>* event);
214 static bool OnLoadedGame(CNetServerSession* session, CFsmEvent<CNetMessage*>* event);
216 static bool OnRejoined(CNetServerSession* session, CFsmEvent<CNetMessage*>* event);
217 static bool OnKickPlayer(CNetServerSession* session, CFsmEvent<CNetMessage*>* event);
218 static bool OnDisconnect(CNetServerSession* session, CFsmEvent<CNetMessage*>* event);
219 static bool OnClientPaused(CNetServerSession* session, CFsmEvent<CNetMessage*>* event);
220
221 /**
222 * Checks if all clients have finished loading.
223 * If so informs the clients about that and change the server state.
224 *
225 * Returns if all clients finished loading.
226 */
227 bool CheckGameLoadStatus(CNetServerSession* changedSession);
228
229 void ConstructPlayerAssignmentMessage(CPlayerAssignmentMessage& message);
230
231 void HandleMessageReceive(CNetMessage* message, CNetServerSession* session);
232
233 /**
234 * Send a network warning if the connection to a client is being lost or has bad latency.
235 */
237
238 void SendHolePunchingMessage(const CStr& ip, std::uint16_t port);
239
240 /**
241 * Internal script context for (de)serializing script messages,
242 * and for storing init attributes.
243 * (TODO: we shouldn't bother deserializing (except for debug printing of messages),
244 * we should just forward messages blindly and efficiently.)
245 */
247
249
250 /**
251 * Stores the most current init attributes.
252 * NB: this is not guaranteed to be up-to-date until the server is LOADING or INGAME.
253 * At that point, the settings are frozen and ought to be identical to the simulation Init Attributes.
254 */
255 JS::PersistentRootedValue m_InitAttributes;
256
257 /**
258 * Whether this match continues a saved game.
259 */
261
262 /**
263 * Whether this match requires lobby authentication.
264 */
265 const bool m_LobbyAuth;
266
267 /**
268 * The nicknames (lowercase) of the host's buddies at the time the game was
269 * hosted, used to decide who may join after the game has started
270 * (lateobserver authentication).
271 */
272 const std::set<std::string> m_Buddies;
273
274 std::unique_ptr<ENetHost, DestroyHost> m_Host;
275 std::vector<std::unique_ptr<CNetServerSession>> m_Sessions;
276
277 std::unique_ptr<CNetStatsTable> m_Stats;
278
280
281 CStrW m_ServerName{L"Unnamed Server"};
282
283 std::vector<std::uint32_t> m_BannedIPs;
284 std::vector<CStrW> m_BannedPlayers;
285
287
288 /**
289 * Holds the GUIDs of all currently paused players.
290 */
291 std::vector<CStr> m_PausingPlayers;
292
293 std::uint32_t m_NextHostID{1};
294
295 std::unique_ptr<CNetServerTurnManager> m_ServerTurnManager;
296
297 /**
298 * The GUID of the client in control of the game (the 'host' from the players' perspective).
299 */
301
302 /**
303 * The 'secret' used to identify the controller of the game.
304 */
306
307 /**
308 * A copy of all simulation commands received so far, indexed by
309 * turn number, to simplify support for rejoining etc.
310 * TODO: verify this doesn't use too much RAM.
311 */
312 std::vector<std::vector<CSimulationMessage>> m_SavedCommands;
313
314 /**
315 * The latest copy of the simulation state, received from an existing
316 * client when a new client has asked to rejoin the game.
317 */
318 std::string m_JoinSyncFile;
319
320 /**
321 * The loaded game data when a game is loaded.
322 */
323 std::string m_SavedState;
324
325 /**
326 * Time when the clients connections were last checked for timeouts and latency.
327 */
328 std::time_t m_LastConnectionCheck{0};
329
330private:
331 // Thread-related stuff:
332
333#if CONFIG2_MINIUPNPC
334 /**
335 * Try to find a UPnP root on the network and setup port forwarding.
336 */
337 static void SetupUPnP(const std::uint16_t port);
338 std::thread m_UPnPThread;
339#endif
340
341 static void RunThread(CNetServerWorker* data, const std::string& initAttributes);
342 void Run(const std::string& initAttributes);
343 bool RunStep();
344
345 std::thread m_WorkerThread;
346 mutable std::mutex m_WorkerMutex;
347
348 // protected by m_WorkerMutex
349 bool m_Shutdown{false};
350
351 // Queues for messages sent by the game thread (protected by m_WorkerMutex):
352 std::vector<bool> m_StartGameQueue;
353 std::vector<std::pair<CStr, CStr>> m_LobbyAuthQueue;
354 std::vector<std::uint32_t> m_TurnLengthQueue;
355};
356
357/**
358 * Network server interface. Handles all the coordination between players.
359 * One person runs this object, and every player (including the host) connects their CNetClient to it.
360 *
361 * The actual work is performed by CNetServerWorker in a separate thread.
362 */
364{
366public:
367 CNetServer(const bool isSavedGame, std::uint16_t port, const bool useLobbyAuth = false,
368 std::string password = {}, std::string controllerSecret = {}, std::string initAttributes = {},
369 std::set<std::string> buddies = {});
370
371 /**
372 * Call from the GUI to asynchronously notify all clients that they should start loading the game.
373 * SetupConnection must be called at least once.
374 */
375 void StartGame();
376
377 /**
378 * Set the turn length to a fixed value.
379 * TODO: we should replace this with some adapative lag-dependent computation.
380 */
381 void SetTurnLength(std::uint32_t msecs);
382
383 bool UseLobbyAuth() const;
384
385 void OnLobbyAuth(const CStr& name, const CStr& token);
386
387 void SendHolePunchingMessage(const CStr& ip, std::uint16_t port);
388
389 /**
390 * Return the externally accessible IP.
391 */
392 CStr GetPublicIp() const;
393
394 /**
395 * Return the externally accessible port.
396 */
397 std::uint16_t GetPublicPort() const;
398
399 /**
400 * Return the serving port on the local machine.
401 */
402 std::uint16_t GetLocalPort() const;
403
404 /**
405 * Check if password is valid. If is not, increase number of failed attempts of the lobby user.
406 * This is used without established direct session with the client, to prevent brute force attacks
407 * when guessing password trying to get connection data from the host.
408 * @return true iff password is valid
409 */
410 bool CheckPasswordAndIncrement(const std::string& username, const std::string& password, const std::string& salt);
411
412 /**
413 * Check if user reached certain number of failed attempts.
414 * @see m_BanAfterNumberOfTries
415 * @see CheckPasswordAndBan
416 */
417 bool IsBanned(const std::string& username) const;
418
419private:
421 const bool m_LobbyAuth;
422 std::uint16_t m_PublicPort{20595};
425 std::unordered_map<std::string, int> m_FailedAttempts;
426};
427
428/// Global network server for the standard game
429extern CNetServer *g_NetServer;
430
431#endif // NETSERVER_H
Various declarations shared by networking code.
struct _ENetPeer ENetPeer
Definition: NetHost.h:33
std::map< CStr, PlayerAssignment > PlayerAssignmentMap
Definition: NetHost.h:56
CNetServer * g_NetServer
Global network server for the standard game.
Definition: NetServer.cpp:109
NetServerSessionState
Server session representation of client state.
Definition: NetServer.h:71
@ NSS_AUTHENTICATE
Definition: NetServer.h:84
@ NSS_INGAME
Definition: NetServer.h:97
@ NSS_PREGAME
Definition: NetServer.h:89
@ NSS_HANDSHAKE
Definition: NetServer.h:77
@ NSS_LOBBY_AUTHENTICATE
Definition: NetServer.h:80
@ NSS_UNCONNECTED
Definition: NetServer.h:73
@ NSS_JOIN_SYNCING
Definition: NetServer.h:93
NetServerState
Definition: NetServer.h:50
@ SERVER_STATE_INGAME
Definition: NetServer.h:60
@ SERVER_STATE_POSTGAME
Definition: NetServer.h:64
@ SERVER_STATE_PREGAME
Definition: NetServer.h:54
@ SERVER_STATE_LOADING
Definition: NetServer.h:57
Represents a signal in the state machine that a change has occurred.
Definition: FSM.h:34
The base class for all network messages exchanged within the game.
Definition: NetMessage.h:42
The server's end of a network session.
Definition: NetServerSession.h:39
The server-side counterpart to CNetClientTurnManager.
Definition: NetServerTurnManager.h:42
Network server worker thread.
Definition: NetServer.h:113
void OnUserJoin(CNetServerSession *session)
Definition: NetServer.cpp:734
void Run(const std::string &initAttributes)
Definition: NetServer.cpp:388
Script::Interface * m_ScriptInterface
Internal script context for (de)serializing script messages, and for storing init attributes.
Definition: NetServer.h:246
std::string m_SavedState
The loaded game data when a game is loaded.
Definition: NetServer.h:323
void SetupSession(CNetServerSession *session)
Definition: NetServer.cpp:649
NONCOPYABLE(CNetServerWorker)
~CNetServerWorker()
Definition: NetServer.cpp:163
static bool OnKickPlayer(CNetServerSession *session, CFsmEvent< CNetMessage * > *event)
Definition: NetServer.cpp:1510
std::unique_ptr< ENetHost, DestroyHost > m_Host
Definition: NetServer.h:274
void HandleMessageReceive(CNetMessage *message, CNetServerSession *session)
Definition: NetServer.cpp:620
void SendPlayerAssignments()
Definition: NetServer.cpp:890
static bool OnChat(CNetServerSession *session, CFsmEvent< CNetMessage * > *event)
Definition: NetServer.cpp:1274
CStrW m_ServerName
Definition: NetServer.h:281
std::unique_ptr< CNetServerTurnManager > m_ServerTurnManager
Definition: NetServer.h:295
std::vector< std::pair< CStr, CStr > > m_LobbyAuthQueue
Definition: NetServer.h:353
std::vector< std::uint32_t > m_TurnLengthQueue
Definition: NetServer.h:354
static bool OnClientHandshake(CNetServerSession *session, CFsmEvent< CNetMessage * > *event)
Definition: NetServer.cpp:925
static bool OnAuthenticate(CNetServerSession *session, CFsmEvent< CNetMessage * > *event)
Definition: NetServer.cpp:978
static bool OnClientPaused(CNetServerSession *session, CFsmEvent< CNetMessage * > *event)
Definition: NetServer.cpp:1535
void StartGame(const CStr &initAttribs)
Switch in game mode and notify all clients to start the game.
Definition: NetServer.cpp:1635
static bool OnLoadedGame(CNetServerSession *session, CFsmEvent< CNetMessage * > *event)
Definition: NetServer.cpp:1400
static bool OnAssignPlayer(CNetServerSession *session, CFsmEvent< CNetMessage * > *event)
Definition: NetServer.cpp:1355
static bool OnSimulationCommand(CNetServerSession *session, CFsmEvent< CNetMessage * > *event)
Definition: NetServer.cpp:1187
CNetServerWorker(const bool continuesSavedGame, std::uint16_t port, const bool useLobbyAuth, std::string password, std::string controllerSecret, std::string initAttributes, std::set< std::string > buddies)
Definition: NetServer.cpp:125
void OnUserLeave(CNetServerSession *session)
Definition: NetServer.cpp:743
const std::set< std::string > m_Buddies
The nicknames (lowercase) of the host's buddies at the time the game was hosted, used to decide who m...
Definition: NetServer.h:272
std::vector< std::uint32_t > m_BannedIPs
Definition: NetServer.h:283
void AddPlayer(const CStr &guid, const CStrW &name)
Definition: NetServer.cpp:758
const bool m_LobbyAuth
Whether this match requires lobby authentication.
Definition: NetServer.h:265
std::vector< std::unique_ptr< CNetServerSession > > m_Sessions
Definition: NetServer.h:275
static bool OnClearAllReady(CNetServerSession *session, CFsmEvent< CNetMessage * > *event)
Definition: NetServer.cpp:1320
std::vector< CStrW > m_BannedPlayers
Definition: NetServer.h:284
void PreStartGame(const CStr &initAttribs)
Switch in game mode.
Definition: NetServer.cpp:1588
bool Multicast(const CNetMessage *message, const std::vector< NetServerSessionState > &targetStates, const std::optional< std::vector< std::string > > &receivers=std::nullopt)
Send a message to all clients who match one of the given states.
Definition: NetServer.cpp:351
static bool OnSavedGameStart(CNetServerSession *session, CFsmEvent< CNetMessage * > *event)
Definition: NetServer.cpp:1381
CStrW DeduplicatePlayerName(const CStrW &original)
Make a player name unique, if it matches any existing session's name.
Definition: NetServer.cpp:1675
CStr m_ControllerGUID
The GUID of the client in control of the game (the 'host' from the players' perspective).
Definition: NetServer.h:300
std::thread m_UPnPThread
Definition: NetServer.h:338
std::unique_ptr< CNetStatsTable > m_Stats
Definition: NetServer.h:277
bool CheckGameLoadStatus(CNetServerSession *changedSession)
Checks if all clients have finished loading.
Definition: NetServer.cpp:1571
void SetTurnLength(std::uint32_t msecs)
Set the turn length to a fixed value.
Definition: NetServer.cpp:902
PlayerAssignmentMap m_PlayerAssignments
Definition: NetServer.h:248
static CStrW SanitisePlayerName(const CStrW &original)
Make a player name 'nicer' by limiting the length and removing forbidden characters etc.
Definition: NetServer.cpp:1653
NetServerState m_State
Definition: NetServer.h:279
std::time_t m_LastConnectionCheck
Time when the clients connections were last checked for timeouts and latency.
Definition: NetServer.h:328
bool SendMessage(ENetPeer *peer, const CNetMessage *message)
Send a message to the given network peer.
Definition: NetServer.cpp:342
const Script::Interface & GetScriptInterface()
Get the script context used for init attributes.
Definition: NetServer.cpp:897
void RemovePlayer(const CStr &guid)
Definition: NetServer.cpp:810
static bool OnFlare(CNetServerSession *session, CFsmEvent< CNetMessage * > *event)
Definition: NetServer.cpp:1237
bool m_Shutdown
Definition: NetServer.h:349
static void SetupUPnP(const std::uint16_t port)
Try to find a UPnP root on the network and setup port forwarding.
Definition: NetServer.cpp:191
bool RunStep()
Definition: NetServer.cpp:421
const bool m_ContinuesSavedGame
Whether this match continues a saved game.
Definition: NetServer.h:260
std::uint32_t m_NextHostID
Definition: NetServer.h:293
static void RunThread(CNetServerWorker *data, const std::string &initAttributes)
Definition: NetServer.cpp:381
std::vector< bool > m_StartGameQueue
Definition: NetServer.h:352
static bool OnReady(CNetServerSession *session, CFsmEvent< CNetMessage * > *event)
Definition: NetServer.cpp:1300
static bool OnDisconnect(CNetServerSession *session, CFsmEvent< CNetMessage * > *event)
Definition: NetServer.cpp:1524
static bool OnSyncCheck(CNetServerSession *session, CFsmEvent< CNetMessage * > *event)
Definition: NetServer.cpp:1249
std::mutex m_WorkerMutex
Definition: NetServer.h:346
std::thread m_WorkerThread
Definition: NetServer.h:345
void KickPlayer(const CStrW &playerName, const bool ban)
Disconnects a player from gamesetup or session.
Definition: NetServer.cpp:826
void ProcessLobbyAuth(const CStr &name, const CStr &token)
Definition: NetServer.cpp:908
void SendHolePunchingMessage(const CStr &ip, std::uint16_t port)
Definition: NetServer.cpp:1700
static bool OnEndCommandBatch(CNetServerSession *session, CFsmEvent< CNetMessage * > *event)
Definition: NetServer.cpp:1261
static bool OnRejoined(CNetServerSession *session, CFsmEvent< CNetMessage * > *event)
Definition: NetServer.cpp:1486
std::vector< std::vector< CSimulationMessage > > m_SavedCommands
A copy of all simulation commands received so far, indexed by turn number, to simplify support for re...
Definition: NetServer.h:312
CStr m_Password
Definition: NetServer.h:286
static bool OnGameStart(CNetServerSession *session, CFsmEvent< CNetMessage * > *event)
Definition: NetServer.cpp:1368
void ClearAllPlayerReady()
Definition: NetServer.cpp:817
void StartSavedGame(const CStr &initAttribs)
Switch in game mode and notify all clients to start the saved game.
Definition: NetServer.cpp:1644
JS::PersistentRootedValue m_InitAttributes
Stores the most current init attributes.
Definition: NetServer.h:255
void AssignPlayer(int playerID, const CStr &guid)
The given GUID will be (re)assigned to the given player ID.
Definition: NetServer.cpp:858
static bool OnGameSetup(CNetServerSession *session, CFsmEvent< CNetMessage * > *event)
Definition: NetServer.cpp:1332
std::string m_JoinSyncFile
The latest copy of the simulation state, received from an existing client when a new client has asked...
Definition: NetServer.h:318
void CheckClientConnections()
Send a network warning if the connection to a client is being lost or has bad latency.
Definition: NetServer.cpp:566
std::vector< CStr > m_PausingPlayers
Holds the GUIDs of all currently paused players.
Definition: NetServer.h:291
bool CheckPassword(const std::string &password, const std::string &salt) const
Definition: NetServer.cpp:185
bool HandleConnect(CNetServerSession *session)
Definition: NetServer.cpp:722
static bool OnJoinSyncingLoadedGame(CNetServerSession *session, CFsmEvent< CNetMessage * > *event)
Definition: NetServer.cpp:1434
void ConstructPlayerAssignmentMessage(CPlayerAssignmentMessage &message)
Definition: NetServer.cpp:874
std::string m_ControllerSecret
The 'secret' used to identify the controller of the game.
Definition: NetServer.h:305
Network server interface.
Definition: NetServer.h:364
CStr m_PublicIp
Definition: NetServer.h:423
void SetTurnLength(std::uint32_t msecs)
Set the turn length to a fixed value.
Definition: NetServer.cpp:1784
void SendHolePunchingMessage(const CStr &ip, std::uint16_t port)
Definition: NetServer.cpp:1790
CNetServer(const bool isSavedGame, std::uint16_t port, const bool useLobbyAuth=false, std::string password={}, std::string controllerSecret={}, std::string initAttributes={}, std::set< std::string > buddies={})
Definition: NetServer.cpp:1709
NONCOPYABLE(CNetServer)
std::uint16_t m_PublicPort
Definition: NetServer.h:422
void StartGame()
Call from the GUI to asynchronously notify all clients that they should start loading the game.
Definition: NetServer.cpp:1772
CNetServerWorker m_Worker
Definition: NetServer.h:420
void OnLobbyAuth(const CStr &name, const CStr &token)
Definition: NetServer.cpp:1778
bool IsBanned(const std::string &username) const
Check if user reached certain number of failed attempts.
Definition: NetServer.cpp:1766
bool CheckPasswordAndIncrement(const std::string &username, const std::string &password, const std::string &salt)
Check if password is valid.
Definition: NetServer.cpp:1750
CStr m_Password
Definition: NetServer.h:424
bool UseLobbyAuth() const
Definition: NetServer.cpp:1727
std::unordered_map< std::string, int > m_FailedAttempts
Definition: NetServer.h:425
const bool m_LobbyAuth
Definition: NetServer.h:421
std::uint16_t GetLocalPort() const
Return the serving port on the local machine.
Definition: NetServer.cpp:1742
CStr GetPublicIp() const
Return the externally accessible IP.
Definition: NetServer.cpp:1732
std::uint16_t GetPublicPort() const
Return the externally accessible port.
Definition: NetServer.cpp:1737
ENet connection statistics profiler table.
Definition: NetStats.h:43
Special message type for simulation commands.
Definition: NetMessage.h:123
Definition: Interface.h:93
Abstraction around a SpiderMonkey JSContext.
Definition: DapInterface.h:32