| 1 | /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ |
| 2 | /* If you are missing that file, acquire a complete release at teeworlds.com. */ |
| 3 | #ifndef ENGINE_SERVER_SERVER_H |
| 4 | #define ENGINE_SERVER_SERVER_H |
| 5 | |
| 6 | #include "antibot.h" |
| 7 | #include "authmanager.h" |
| 8 | #include "name_ban.h" |
| 9 | #include "snap_id_pool.h" |
| 10 | |
| 11 | #include <base/hash.h> |
| 12 | |
| 13 | #include <engine/console.h> |
| 14 | #include <engine/server.h> |
| 15 | #include <engine/shared/demo.h> |
| 16 | #include <engine/shared/econ.h> |
| 17 | #include <engine/shared/fifo.h> |
| 18 | #include <engine/shared/http.h> |
| 19 | #include <engine/shared/netban.h> |
| 20 | #include <engine/shared/network.h> |
| 21 | #include <engine/shared/protocol.h> |
| 22 | #include <engine/shared/snapshot.h> |
| 23 | #include <engine/shared/uuid_manager.h> |
| 24 | |
| 25 | #include <memory> |
| 26 | #include <optional> |
| 27 | #include <vector> |
| 28 | |
| 29 | #if defined(CONF_UPNP) |
| 30 | #include "upnp.h" |
| 31 | #endif |
| 32 | |
| 33 | class CConfig; |
| 34 | class CHostLookup; |
| 35 | class CLogMessage; |
| 36 | class CMsgPacker; |
| 37 | class CPacker; |
| 38 | class IEngine; |
| 39 | class IEngineMap; |
| 40 | class ILogger; |
| 41 | |
| 42 | class CServerBan : public CNetBan |
| 43 | { |
| 44 | class CServer *m_pServer; |
| 45 | |
| 46 | template<class T> |
| 47 | int BanExt(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason, bool VerbatimReason); |
| 48 | |
| 49 | public: |
| 50 | class CServer *Server() const { return m_pServer; } |
| 51 | |
| 52 | void InitServerBan(class IConsole *pConsole, class IStorage *pStorage, class CServer *pServer); |
| 53 | |
| 54 | int BanAddr(const NETADDR *pAddr, int Seconds, const char *pReason, bool VerbatimReason) override; |
| 55 | int BanRange(const CNetRange *pRange, int Seconds, const char *pReason) override; |
| 56 | |
| 57 | static void ConBanExt(class IConsole::IResult *pResult, void *pUser); |
| 58 | static void ConBanRegion(class IConsole::IResult *pResult, void *pUser); |
| 59 | static void ConBanRegionRange(class IConsole::IResult *pResult, void *pUser); |
| 60 | }; |
| 61 | |
| 62 | class CServer : public IServer |
| 63 | { |
| 64 | friend class CServerLogger; |
| 65 | |
| 66 | class IGameServer *m_pGameServer; |
| 67 | class CConfig *m_pConfig; |
| 68 | class IConsole *m_pConsole; |
| 69 | class IStorage *m_pStorage; |
| 70 | class IEngineAntibot *m_pAntibot; |
| 71 | class IRegister *m_pRegister; |
| 72 | IEngine *m_pEngine; |
| 73 | |
| 74 | #if defined(CONF_UPNP) |
| 75 | CUPnP m_UPnP; |
| 76 | #endif |
| 77 | |
| 78 | #if defined(CONF_FAMILY_UNIX) |
| 79 | UNIXSOCKETADDR m_ConnLoggingDestAddr; |
| 80 | bool m_ConnLoggingSocketCreated; |
| 81 | UNIXSOCKET m_ConnLoggingSocket; |
| 82 | #endif |
| 83 | |
| 84 | class CDbConnectionPool *m_pConnectionPool; |
| 85 | |
| 86 | #ifdef CONF_DEBUG |
| 87 | int m_PreviousDebugDummies = 0; |
| 88 | void UpdateDebugDummies(bool ForceDisconnect); |
| 89 | #endif |
| 90 | |
| 91 | public: |
| 92 | class IGameServer *GameServer() { return m_pGameServer; } |
| 93 | class CConfig *Config() { return m_pConfig; } |
| 94 | const CConfig *Config() const { return m_pConfig; } |
| 95 | class IConsole *Console() { return m_pConsole; } |
| 96 | class IStorage *Storage() { return m_pStorage; } |
| 97 | class IEngineAntibot *Antibot() { return m_pAntibot; } |
| 98 | class CDbConnectionPool *DbPool() { return m_pConnectionPool; } |
| 99 | IEngine *Engine() { return m_pEngine; } |
| 100 | |
| 101 | enum |
| 102 | { |
| 103 | MAX_RCONCMD_SEND = 16, |
| 104 | }; |
| 105 | |
| 106 | enum class EDnsblState |
| 107 | { |
| 108 | NONE, |
| 109 | PENDING, |
| 110 | BLACKLISTED, |
| 111 | WHITELISTED, |
| 112 | }; |
| 113 | |
| 114 | static const char *DnsblStateStr(EDnsblState State); |
| 115 | |
| 116 | class CClient |
| 117 | { |
| 118 | public: |
| 119 | enum |
| 120 | { |
| 121 | STATE_REDIRECTED = -1, |
| 122 | STATE_EMPTY, |
| 123 | STATE_PREAUTH, |
| 124 | STATE_AUTH, |
| 125 | STATE_CONNECTING, |
| 126 | STATE_READY, |
| 127 | STATE_INGAME, |
| 128 | }; |
| 129 | |
| 130 | enum |
| 131 | { |
| 132 | SNAPRATE_INIT = 0, |
| 133 | SNAPRATE_FULL, |
| 134 | SNAPRATE_RECOVER, |
| 135 | }; |
| 136 | |
| 137 | class CInput |
| 138 | { |
| 139 | public: |
| 140 | int m_aData[MAX_INPUT_SIZE]; |
| 141 | int m_GameTick; // the tick that was chosen for the input |
| 142 | }; |
| 143 | |
| 144 | // connection state info |
| 145 | int m_State; |
| 146 | int m_Latency; |
| 147 | int m_SnapRate; |
| 148 | |
| 149 | double m_Traffic; |
| 150 | int64_t m_TrafficSince; |
| 151 | |
| 152 | int m_LastAckedSnapshot; |
| 153 | int m_LastInputTick; |
| 154 | CSnapshotStorage m_Snapshots; |
| 155 | |
| 156 | CNetMsg_Sv_PreInput m_LastPreInput = {}; |
| 157 | CInput m_LatestInput; |
| 158 | CInput m_aInputs[200]; // TODO: handle input better |
| 159 | int m_CurrentInput; |
| 160 | |
| 161 | char m_aName[MAX_NAME_LENGTH]; |
| 162 | char m_aClan[MAX_CLAN_LENGTH]; |
| 163 | int m_Country; |
| 164 | std::optional<int> m_Score; |
| 165 | int m_AuthKey; |
| 166 | int m_AuthTries; |
| 167 | bool m_AuthHidden; |
| 168 | int m_NextMapChunk; |
| 169 | int m_Flags; |
| 170 | bool m_ShowIps; |
| 171 | bool m_DebugDummy; |
| 172 | bool m_ForceHighBandwidthOnSpectate; |
| 173 | NETADDR m_DebugDummyAddr; |
| 174 | std::array<char, NETADDR_MAXSTRSIZE> m_aDebugDummyAddrString; |
| 175 | std::array<char, NETADDR_MAXSTRSIZE> m_aDebugDummyAddrStringNoPort; |
| 176 | |
| 177 | const IConsole::ICommandInfo *m_pRconCmdToSend; |
| 178 | enum |
| 179 | { |
| 180 | MAPLIST_UNINITIALIZED = -1, |
| 181 | MAPLIST_DISABLED = -2, |
| 182 | MAPLIST_DONE = -3, |
| 183 | }; |
| 184 | int m_MaplistEntryToSend; |
| 185 | |
| 186 | bool m_HasPersistentData; |
| 187 | void *m_pPersistentData; |
| 188 | |
| 189 | void Reset(); |
| 190 | |
| 191 | // DDRace |
| 192 | |
| 193 | bool m_GotDDNetVersionPacket; |
| 194 | bool m_DDNetVersionSettled; |
| 195 | int m_DDNetVersion; |
| 196 | char m_aDDNetVersionStr[64]; |
| 197 | CUuid m_ConnectionId; |
| 198 | int64_t m_RedirectDropTime; |
| 199 | |
| 200 | // DNSBL |
| 201 | EDnsblState m_DnsblState; |
| 202 | std::shared_ptr<CHostLookup> m_pDnsblLookup; |
| 203 | |
| 204 | bool m_Sixup; |
| 205 | |
| 206 | bool IncludedInServerInfo() const |
| 207 | { |
| 208 | return m_State != STATE_EMPTY && !m_DebugDummy; |
| 209 | } |
| 210 | }; |
| 211 | |
| 212 | IConsole::EAccessLevel ConsoleAccessLevel(int ClientId) const; |
| 213 | |
| 214 | CClient m_aClients[MAX_CLIENTS]; |
| 215 | int m_aIdMap[MAX_CLIENTS * VANILLA_MAX_CLIENTS]; |
| 216 | |
| 217 | CSnapshotDelta m_SnapshotDelta; |
| 218 | CSnapshotBuilder m_SnapshotBuilder; |
| 219 | CSnapIdPool m_IdPool; |
| 220 | CNetServer m_NetServer; |
| 221 | CEcon m_Econ; |
| 222 | CFifo m_Fifo; |
| 223 | CServerBan m_ServerBan; |
| 224 | CHttp m_Http; |
| 225 | |
| 226 | IEngineMap *m_pMap; |
| 227 | |
| 228 | int64_t m_GameStartTime; |
| 229 | |
| 230 | enum |
| 231 | { |
| 232 | UNINITIALIZED = 0, |
| 233 | RUNNING = 1, |
| 234 | STOPPING = 2 |
| 235 | }; |
| 236 | |
| 237 | int m_RunServer; |
| 238 | |
| 239 | bool m_MapReload; |
| 240 | bool m_SameMapReload; |
| 241 | bool m_ReloadedWhenEmpty; |
| 242 | int m_RconClientId; |
| 243 | int m_RconAuthLevel; |
| 244 | int m_PrintCBIndex; |
| 245 | char m_aShutdownReason[128]; |
| 246 | void *m_pPersistentData; |
| 247 | |
| 248 | enum |
| 249 | { |
| 250 | MAP_TYPE_SIX = 0, |
| 251 | MAP_TYPE_SIXUP, |
| 252 | NUM_MAP_TYPES |
| 253 | }; |
| 254 | |
| 255 | enum |
| 256 | { |
| 257 | RECORDER_MANUAL = MAX_CLIENTS, |
| 258 | RECORDER_AUTO = MAX_CLIENTS + 1, |
| 259 | NUM_RECORDERS = MAX_CLIENTS + 2, |
| 260 | }; |
| 261 | |
| 262 | char m_aCurrentMap[IO_MAX_PATH_LENGTH]; |
| 263 | const char *m_pCurrentMapName; |
| 264 | SHA256_DIGEST m_aCurrentMapSha256[NUM_MAP_TYPES]; |
| 265 | unsigned m_aCurrentMapCrc[NUM_MAP_TYPES]; |
| 266 | unsigned char *m_apCurrentMapData[NUM_MAP_TYPES]; |
| 267 | unsigned int m_aCurrentMapSize[NUM_MAP_TYPES]; |
| 268 | char m_aMapDownloadUrl[256]; |
| 269 | |
| 270 | CDemoRecorder m_aDemoRecorder[NUM_RECORDERS]; |
| 271 | CAuthManager m_AuthManager; |
| 272 | |
| 273 | int64_t m_ServerInfoFirstRequest; |
| 274 | int m_ServerInfoNumRequests; |
| 275 | |
| 276 | char m_aErrorShutdownReason[128]; |
| 277 | |
| 278 | CNameBans m_NameBans; |
| 279 | |
| 280 | size_t m_AnnouncementLastLine; |
| 281 | std::vector<std::string> m_vAnnouncements; |
| 282 | |
| 283 | std::shared_ptr<ILogger> m_pFileLogger = nullptr; |
| 284 | std::shared_ptr<ILogger> m_pStdoutLogger = nullptr; |
| 285 | |
| 286 | CServer(); |
| 287 | ~CServer() override; |
| 288 | |
| 289 | bool IsClientNameAvailable(int ClientId, const char *pNameRequest); |
| 290 | bool SetClientNameImpl(int ClientId, const char *pNameRequest, bool Set); |
| 291 | bool SetClientClanImpl(int ClientId, const char *pClanRequest, bool Set); |
| 292 | |
| 293 | bool WouldClientNameChange(int ClientId, const char *pNameRequest) override; |
| 294 | bool WouldClientClanChange(int ClientId, const char *pClanRequest) override; |
| 295 | void SetClientName(int ClientId, const char *pName) override; |
| 296 | void SetClientClan(int ClientId, const char *pClan) override; |
| 297 | void SetClientCountry(int ClientId, int Country) override; |
| 298 | void SetClientScore(int ClientId, std::optional<int> Score) override; |
| 299 | void SetClientFlags(int ClientId, int Flags) override; |
| 300 | |
| 301 | void Kick(int ClientId, const char *pReason) override; |
| 302 | void Ban(int ClientId, int Seconds, const char *pReason, bool VerbatimReason) override; |
| 303 | void ReconnectClient(int ClientId); |
| 304 | void RedirectClient(int ClientId, int Port) override; |
| 305 | |
| 306 | void DemoRecorder_HandleAutoStart() override; |
| 307 | |
| 308 | int64_t TickStartTime(int Tick); |
| 309 | |
| 310 | int Init(); |
| 311 | |
| 312 | static bool StrHideIps(const char *pInput, char *pOutputWithIps, int OutputWithIpsSize, char *pOutputWithoutIps, int OutputWithoutIpsSize); |
| 313 | void SendLogLine(const CLogMessage *pMessage); |
| 314 | void SetRconCid(int ClientId) override; |
| 315 | int GetAuthedState(int ClientId) const override; |
| 316 | bool IsRconAuthed(int ClientId) const override; |
| 317 | bool IsRconAuthedAdmin(int ClientId) const override; |
| 318 | const char *GetAuthName(int ClientId) const override; |
| 319 | bool HasAuthHidden(int ClientId) const override; |
| 320 | void GetMapInfo(char *pMapName, int MapNameSize, int *pMapSize, SHA256_DIGEST *pMapSha256, int *pMapCrc) override; |
| 321 | bool GetClientInfo(int ClientId, CClientInfo *pInfo) const override; |
| 322 | void SetClientDDNetVersion(int ClientId, int DDNetVersion) override; |
| 323 | const NETADDR *ClientAddr(int ClientId) const override; |
| 324 | const std::array<char, NETADDR_MAXSTRSIZE> &ClientAddrStringImpl(int ClientId, bool IncludePort) const override; |
| 325 | const char *ClientName(int ClientId) const override; |
| 326 | const char *ClientClan(int ClientId) const override; |
| 327 | int ClientCountry(int ClientId) const override; |
| 328 | bool ClientSlotEmpty(int ClientId) const override; |
| 329 | bool ClientIngame(int ClientId) const override; |
| 330 | int Port() const override; |
| 331 | int MaxClients() const override; |
| 332 | int ClientCount() const override; |
| 333 | int DistinctClientCount() const override; |
| 334 | |
| 335 | int GetClientVersion(int ClientId) const override; |
| 336 | int SendMsg(CMsgPacker *pMsg, int Flags, int ClientId) override; |
| 337 | |
| 338 | void DoSnapshot(); |
| 339 | |
| 340 | static int NewClientCallback(int ClientId, void *pUser, bool Sixup); |
| 341 | static int NewClientNoAuthCallback(int ClientId, void *pUser); |
| 342 | static int DelClientCallback(int ClientId, const char *pReason, void *pUser); |
| 343 | |
| 344 | static int ClientRejoinCallback(int ClientId, void *pUser); |
| 345 | |
| 346 | void SendRconType(int ClientId, bool UsernameReq); |
| 347 | void SendCapabilities(int ClientId); |
| 348 | void SendMap(int ClientId); |
| 349 | void SendMapData(int ClientId, int Chunk); |
| 350 | void SendMapReload(int ClientId); |
| 351 | void SendConnectionReady(int ClientId); |
| 352 | void SendRconLine(int ClientId, const char *pLine); |
| 353 | // Accepts -1 as ClientId to mean "all clients with at least auth level admin" |
| 354 | void SendRconLogLine(int ClientId, const CLogMessage *pMessage); |
| 355 | |
| 356 | void SendRconCmdAdd(const IConsole::ICommandInfo *pCommandInfo, int ClientId); |
| 357 | void SendRconCmdRem(const IConsole::ICommandInfo *pCommandInfo, int ClientId); |
| 358 | void SendRconCmdGroupStart(int ClientId); |
| 359 | void SendRconCmdGroupEnd(int ClientId); |
| 360 | int NumRconCommands(int ClientId); |
| 361 | void UpdateClientRconCommands(int ClientId); |
| 362 | |
| 363 | class CMaplistEntry |
| 364 | { |
| 365 | public: |
| 366 | char m_aName[128]; |
| 367 | |
| 368 | CMaplistEntry() = default; |
| 369 | CMaplistEntry(const char *pName); |
| 370 | bool operator<(const CMaplistEntry &Other) const; |
| 371 | }; |
| 372 | std::vector<CMaplistEntry> m_vMaplistEntries; |
| 373 | void SendMaplistGroupStart(int ClientId); |
| 374 | void SendMaplistGroupEnd(int ClientId); |
| 375 | void UpdateClientMaplistEntries(int ClientId); |
| 376 | |
| 377 | bool CheckReservedSlotAuth(int ClientId, const char *pPassword); |
| 378 | void ProcessClientPacket(CNetChunk *pPacket); |
| 379 | |
| 380 | class CCache |
| 381 | { |
| 382 | public: |
| 383 | class CCacheChunk |
| 384 | { |
| 385 | public: |
| 386 | CCacheChunk(const void *pData, int Size); |
| 387 | CCacheChunk(const CCacheChunk &) = delete; |
| 388 | CCacheChunk(CCacheChunk &&) = default; |
| 389 | |
| 390 | std::vector<uint8_t> m_vData; |
| 391 | }; |
| 392 | |
| 393 | std::vector<CCacheChunk> m_vCache; |
| 394 | |
| 395 | CCache(); |
| 396 | ~CCache(); |
| 397 | |
| 398 | void AddChunk(const void *pData, int Size); |
| 399 | void Clear(); |
| 400 | }; |
| 401 | CCache m_aServerInfoCache[3 * 2]; |
| 402 | CCache m_aSixupServerInfoCache[2]; |
| 403 | bool m_ServerInfoNeedsUpdate; |
| 404 | |
| 405 | void FillAntibot(CAntibotRoundData *pData) override; |
| 406 | |
| 407 | void ExpireServerInfo() override; |
| 408 | void CacheServerInfo(CCache *pCache, int Type, bool SendClients); |
| 409 | void CacheServerInfoSixup(CCache *pCache, bool SendClients, int MaxConsideredClients); |
| 410 | void SendServerInfo(const NETADDR *pAddr, int Token, int Type, bool SendClients); |
| 411 | void GetServerInfoSixup(CPacker *pPacker, bool SendClients); |
| 412 | bool RateLimitServerInfoConnless(); |
| 413 | void SendServerInfoConnless(const NETADDR *pAddr, int Token, int Type); |
| 414 | void UpdateRegisterServerInfo(); |
| 415 | void UpdateServerInfo(bool Resend = false); |
| 416 | |
| 417 | void PumpNetwork(bool PacketWaiting); |
| 418 | |
| 419 | void ChangeMap(const char *pMap) override; |
| 420 | const char *GetMapName() const override; |
| 421 | void ReloadMap() override; |
| 422 | int LoadMap(const char *pMapName); |
| 423 | |
| 424 | void SaveDemo(int ClientId, float Time) override; |
| 425 | void StartRecord(int ClientId) override; |
| 426 | void StopRecord(int ClientId) override; |
| 427 | bool IsRecording(int ClientId) override; |
| 428 | void StopDemos() override; |
| 429 | |
| 430 | int Run(); |
| 431 | |
| 432 | static void ConKick(IConsole::IResult *pResult, void *pUser); |
| 433 | static void ConStatus(IConsole::IResult *pResult, void *pUser); |
| 434 | static void ConShutdown(IConsole::IResult *pResult, void *pUser); |
| 435 | static void ConRecord(IConsole::IResult *pResult, void *pUser); |
| 436 | static void ConStopRecord(IConsole::IResult *pResult, void *pUser); |
| 437 | static void ConMapReload(IConsole::IResult *pResult, void *pUser); |
| 438 | static void ConLogout(IConsole::IResult *pResult, void *pUser); |
| 439 | static void ConShowIps(IConsole::IResult *pResult, void *pUser); |
| 440 | static void ConHideAuthStatus(IConsole::IResult *pResult, void *pUser); |
| 441 | static void ConForceHighBandwidthOnSpectate(IConsole::IResult *pResult, void *pUser); |
| 442 | |
| 443 | static void ConAuthAdd(IConsole::IResult *pResult, void *pUser); |
| 444 | static void ConAuthAddHashed(IConsole::IResult *pResult, void *pUser); |
| 445 | static void ConAuthUpdate(IConsole::IResult *pResult, void *pUser); |
| 446 | static void ConAuthUpdateHashed(IConsole::IResult *pResult, void *pUser); |
| 447 | static void ConAuthRemove(IConsole::IResult *pResult, void *pUser); |
| 448 | static void ConAuthList(IConsole::IResult *pResult, void *pUser); |
| 449 | |
| 450 | // console commands for sqlmasters |
| 451 | static void ConAddSqlServer(IConsole::IResult *pResult, void *pUserData); |
| 452 | static void ConDumpSqlServers(IConsole::IResult *pResult, void *pUserData); |
| 453 | |
| 454 | static void ConReloadAnnouncement(IConsole::IResult *pResult, void *pUserData); |
| 455 | static void ConReloadMaplist(IConsole::IResult *pResult, void *pUserData); |
| 456 | |
| 457 | static void ConchainSpecialInfoupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 458 | static void ConchainMaxclientsperipUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 459 | static void ConchainCommandAccessUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 460 | |
| 461 | void LogoutClient(int ClientId, const char *pReason); |
| 462 | void LogoutKey(int Key, const char *pReason); |
| 463 | |
| 464 | void ConchainRconPasswordChangeGeneric(const char *pRoleName, const char *pCurrent, IConsole::IResult *pResult); |
| 465 | static void ConchainRconPasswordChange(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 466 | static void ConchainRconModPasswordChange(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 467 | static void ConchainRconHelperPasswordChange(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 468 | static void ConchainMapUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 469 | static void ConchainSixupUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 470 | static void (IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 471 | static void ConchainLoglevel(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 472 | static void ConchainStdoutOutputLevel(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 473 | static void ConchainAnnouncementFilename(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 474 | static void ConchainInputFifo(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 475 | |
| 476 | #if defined(CONF_FAMILY_UNIX) |
| 477 | static void ConchainConnLoggingServerChange(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); |
| 478 | #endif |
| 479 | |
| 480 | void RegisterCommands(); |
| 481 | |
| 482 | int SnapNewId() override; |
| 483 | void SnapFreeId(int Id) override; |
| 484 | void *SnapNewItem(int Type, int Id, int Size) override; |
| 485 | void SnapSetStaticsize(int ItemType, int Size) override; |
| 486 | |
| 487 | // DDRace |
| 488 | |
| 489 | int m_aPrevStates[MAX_CLIENTS]; |
| 490 | const char *GetAnnouncementLine() override; |
| 491 | void ReadAnnouncementsFile(); |
| 492 | |
| 493 | static int MaplistEntryCallback(const char *pFilename, int IsDir, int DirType, void *pUser); |
| 494 | void InitMaplist(); |
| 495 | |
| 496 | int *GetIdMap(int ClientId) override; |
| 497 | |
| 498 | void InitDnsbl(int ClientId); |
| 499 | bool DnsblWhite(int ClientId) override |
| 500 | { |
| 501 | return m_aClients[ClientId].m_DnsblState == EDnsblState::NONE || |
| 502 | m_aClients[ClientId].m_DnsblState == EDnsblState::WHITELISTED; |
| 503 | } |
| 504 | bool DnsblPending(int ClientId) override |
| 505 | { |
| 506 | return m_aClients[ClientId].m_DnsblState == EDnsblState::PENDING; |
| 507 | } |
| 508 | bool DnsblBlack(int ClientId) override |
| 509 | { |
| 510 | return m_aClients[ClientId].m_DnsblState == EDnsblState::BLACKLISTED; |
| 511 | } |
| 512 | |
| 513 | static bool CanClientUseCommandCallback(int ClientId, const IConsole::ICommandInfo *pCommand, void *pUser); |
| 514 | bool CanClientUseCommand(int ClientId, const IConsole::ICommandInfo *pCommand) const; |
| 515 | void AuthRemoveKey(int KeySlot); |
| 516 | bool ClientPrevIngame(int ClientId) override { return m_aPrevStates[ClientId] == CClient::STATE_INGAME; } |
| 517 | const char *GetNetErrorString(int ClientId) override { return m_NetServer.ErrorString(ClientId); } |
| 518 | void ResetNetErrorString(int ClientId) override { m_NetServer.ResetErrorString(ClientId); } |
| 519 | bool SetTimedOut(int ClientId, int OrigId) override; |
| 520 | void SetTimeoutProtected(int ClientId) override { m_NetServer.IgnoreTimeouts(ClientId); } |
| 521 | |
| 522 | void SendMsgRaw(int ClientId, const void *pData, int Size, int Flags) override; |
| 523 | |
| 524 | bool ErrorShutdown() const { return m_aErrorShutdownReason[0] != 0; } |
| 525 | void SetErrorShutdown(const char *pReason) override; |
| 526 | |
| 527 | bool IsSixup(int ClientId) const override { return ClientId != SERVER_DEMO_CLIENT && m_aClients[ClientId].m_Sixup; } |
| 528 | |
| 529 | void SetLoggers(std::shared_ptr<ILogger> &&pFileLogger, std::shared_ptr<ILogger> &&pStdoutLogger); |
| 530 | |
| 531 | #ifdef CONF_FAMILY_UNIX |
| 532 | enum CONN_LOGGING_CMD |
| 533 | { |
| 534 | OPEN_SESSION = 1, |
| 535 | CLOSE_SESSION = 2, |
| 536 | }; |
| 537 | |
| 538 | void SendConnLoggingCommand(CONN_LOGGING_CMD Cmd, const NETADDR *pAddr); |
| 539 | #endif |
| 540 | }; |
| 541 | |
| 542 | bool IsInterrupted(); |
| 543 | |
| 544 | extern CServer *CreateServer(); |
| 545 | #endif |
| 546 | |