#include "tMemManager.h"
#include "tInitExit.h"
#include "nSimulatePing.h"
#include "nConfig.h"
#include "nNetwork.h"
#include "nServerInfo.h"
#include "tConsole.h"
#include "tDirectories.h"
#include "nSocket.h"
#include "nKrawall.h"
#include "tSysTime.h"
#include "tRecorder.h"
#include "tRandom.h"
#include <stdlib.h>
#include <fstream>
#include "tMath.h"
#include <string.h>
#include <netinet/in.h>
#include <deque>
Go to the source code of this file.
Classes | |
class | planned_send |
class | nMessage_planned_send |
class | nMessageIDExpander |
struct | myfloat |
class | nAckMessage |
class | nMachinePTR |
class | nMachinePersistor |
Defines | |
#define | NO_ACK |
#define | TRUE_ARMAGETRONAD_VERSION VERSION |
#define | ACKBACK 1000 |
#define | IDS_RESERVED 16 |
#define | MAXDESCRIPTORS 400 |
#define | MANT 26 |
#define | EXP (32-MANT) |
#define | MS (MANT-1) |
#define | MAX_MESS_LEN 300 |
#define | OVERHEAD 32 |
Typedefs | |
typedef std::deque < tJUST_CONTROLLED_PTR < nMessage > > | nMessageFifo |
typedef std::map< tString, nMachinePTR > | nMachineMap |
Functions | |
tString const & | sn_GetMyAddress () |
return the public IP address and port of this machine, or "*.*.*.*:*" if it is unknown.. | |
bool | sn_IsLANAddress (tString const &address) |
checks wheter a given address is on the user's LAN (or on loopback). | |
void | sn_DisconnectUserNoWarn (int i, const tOutput &reason, nServerInfoBase *redirectTo=0) |
void | sn_Delay () |
pause a bit, abort pause on network activity | |
static REAL | sn_GetTimeout (int user) |
int | sn_GetCurrentProtocolVersion () |
const nVersion & | sn_MyVersion () |
the version this progam maximally supports | |
const nVersion & | sn_CurrentVersion () |
the version currently supported by all connected players | |
nMessage & | operator>> (nMessage &m, nVersion &ver) |
nMessage & | operator<< (nMessage &m, const nVersion &ver) |
std::istream & | operator>> (std::istream &s, nVersion &ver) |
std::ostream & | operator<< (std::ostream &s, const nVersion &ver) |
void | handle_version_control (nMessage &m) |
void | sn_UpdateCurrentVersion () |
updates the sn_CurrentVersion() | |
nConnectError | sn_GetLastError () |
static void | reset_last_acks (int i) |
void | ack_handler (nMessage &m) |
static unsigned long int | sn_ExpandMessageID (unsigned short id, unsigned short sender) |
expands a short message ID to a full int message ID, assuming it is from a message that was | |
static void | sn_AddToString (tString &s, tString::CHAR c) |
void | req_info_handler (nMessage &m) |
void | RequestInfoHandler (nHandler *handle) |
std::auto_ptr< nServerInfoBase > | sn_GetRedirectTo () |
nServerInfoBase * | sn_PeekRedirectTo () |
void | login_deny_handler (nMessage &m) |
void | login_handler_1 (nMessage &m) |
void | login_handler_2 (nMessage &m) |
void | logout_handler (nMessage &m) |
void | login_ignore_handler (nMessage &m) |
void | first_fill_ids () |
void | login_accept_handler (nMessage &m) |
int | CountSameIP (int user, bool reset=false) |
int | CountSameConnection (int user) |
int | GetFreeSlot () |
bool | FloodProtection (nMessage const &m) |
int | login_handler (nMessage &m, unsigned short rate) |
static void | rec_peer (unsigned int peer) |
void | sn_ReceiveFromControlSocket () |
void | sn_DiscardFromControlSocket () |
nNetState | sn_GetNetState () |
void | clear_owners () |
static bool | sn_Listen (unsigned int &net_hostport, const tString &net_hostip) |
static void | sn_SaveMachines () |
static void | sn_LoadMachines () |
static void | sn_DisconnectAll () |
void | sn_SetNetState (nNetState x) |
void | sn_Bend (nAddress const &address) |
void | sn_Bend (tString const &server, unsigned int port) |
nConnectError | sn_Connect (nAddress const &server, nLoginType loginType, nSocket const *socket) |
void | nReadError (bool critical) |
static void | sn_ConsoleOut_handler (nMessage &m) |
nMessage * | sn_ConsoleOutMessage (const tOutput &o) |
void | sn_ConsoleOut (const tOutput &o, int client) |
static void | client_cen_handler (nMessage &m) |
void | sn_CenterMessage (const tOutput &o, int client) |
static void | ConsoleOut_conf (std::istream &s) |
static void | CeterMessage_conf (std::istream &s) |
static REAL | sn_SendPlanned1 () |
static void | sn_SendPlanned2 (REAL dt) |
void | sn_SendPlanned () |
void | sn_Receive () |
void | sn_KickUser (int i, const tOutput &reason, REAL severity, nServerInfoBase *redirectTo) |
throw out user i (violently) | |
void | sn_DisconnectUser (int i, const tOutput &reason, nServerInfoBase *redirectTo) |
terminate connection with user i (peacefully) | |
int | sn_QueueLen (int user) |
static bool | net_Accept () |
static void | net_exit () |
static tInitExit | net_ie (NULL,&net_exit) |
void | sn_Statistics () |
void | sn_GetAdr (int user, tString &name) |
unsigned int | sn_GetPort (int user) |
unsigned int | sn_GetServerPort () |
int | sn_NumUsers (bool all) |
int | sn_NumUsers () |
int | sn_NumRealUsers () |
int | sn_MaxUsers () |
int | sn_MessagesPending (int user) |
std::istream & | operator>> (std::istream &stream, nAverager &averager) |
read operator for nAveragers | |
std::ostream & | operator<< (std::ostream &stream, nAverager const &averager) |
write operator for nAveragers | |
static nMachineMap & | sn_GetMachineMap () |
static nMachine & | sn_LookupMachine (tString const &address) |
static void | sn_Erase (nMachineMap &map, nMachineMap::iterator &iter) |
static void | sn_UnBanConf (std::istream &s) |
static void | sn_BanConf (std::istream &s) |
static void | sn_ListBanConf (std::istream &s) |
Variables | |
static tString | sn_myAddress ("*.*.*.*:*") |
tString | sn_bigBrotherString |
tString | sn_programVersion (TRUE_ARMAGETRONAD_VERSION) |
tString | sn_serverName ("Unnamed Server") |
const unsigned int | sn_defaultPort = 4534 |
unsigned int | sn_serverPort = 4534 |
tString | net_hostip ("ANY") |
bool | big_brother = true |
static tConfItem< bool > | sn_bb ("BIG_BROTHER", big_brother) |
static tConfItemLine | sn_sn ("SERVER_NAME", sn_serverName) |
static tConfItem< int > | sn_sport ("SERVER_PORT", reinterpret_cast< int & >(sn_serverPort)) |
static tConfItemLine | sn_sbtip ("SERVER_IP", net_hostip) |
int | sn_defaultDelay = 10000 |
int | sn_maxRateIn = 8 |
int | sn_maxRateOut = 8 |
static nConnectError | sn_Error = nOK |
bool | deb_net = false |
static REAL | maxTimeout = 1 |
static REAL | minTimeout = .01 |
static REAL | pingTimeout = 1 |
static REAL | pingVarianceTimeout = 1 |
static REAL | zeroTimeout = .01 |
static REAL | killTimeout = 30 |
static const int | kickOnDemandTimeout = 10 |
static bool | send_again_warn = false |
int | sn_maxNoAck = 100 |
static nNetState | current_state |
nConnectionInfo | sn_Connections [MAXCLIENTS+2] |
static nAddress | peers [MAXCLIENTS+2] |
static int | timeouts [MAXCLIENTS+2] |
static unsigned short | lastacks [MAXCLIENTS+2][ACKBACK] |
static unsigned short | lastackPos [MAXCLIENTS+2] |
static unsigned short | highest_ack [MAXCLIENTS+2] |
static int | sn_MaxBackwardsCompatibility = 1000 |
static tSettingItem< int > | sn_mxc ("BACKWARD_COMPATIBILITY", sn_MaxBackwardsCompatibility) |
static int | sn_newFeatureDelay = 0 |
static tSettingItem< int > | sn_nfd ("NEW_FEATURE_DELAY", sn_newFeatureDelay) |
static const int | sn_currentProtocolVersion = sn_GetCurrentProtocolVersion() |
static const int | sn_backwardCompatibleProtocolVersion = 0 |
static const nVersion | sn_myVersion (sn_backwardCompatibleProtocolVersion, sn_currentProtocolVersion) |
static nVersion | sn_currentVersion (sn_myVersion) |
nDescriptor | versionControl (10, handle_version_control,"version") |
int | sn_maxClients = MAXCLIENTS |
static tSettingItem< int > | sn_maxClientsConf ("MAX_CLIENTS", sn_maxClients) |
int | sn_allowSameIPCountSoft = 4 |
static tSettingItem< int > | sn_allowSameIPCountSoftConf ("MAX_CLIENTS_SAME_IP_SOFT", sn_allowSameIPCountSoft) |
int | sn_allowSameIPCountHard = 8 |
static tSettingItem< int > | sn_allowSameIPCountHardConf ("MAX_CLIENTS_SAME_IP_HARD", sn_allowSameIPCountHard) |
int | sn_myNetID = 0 |
unsigned short | current_id = 1 |
static nDescriptor * | descriptors [MAXDESCRIPTORS] |
static nDescriptor * | nDescriptor_anchor |
static nDescriptor | s_Acknowledge (1, ack_handler,"ack") |
static tList< nWaitForAck > | sn_pendingAcks |
static nTimeRolling | netTime |
static nVersionFeature | sn_ZeroMessageCrashfix (1) |
bool | sn_filterColorStrings = false |
static tConfItem< bool > | cs ("FILTER_COLOR_STRINGS", sn_filterColorStrings) |
static bool | login_failed = false |
static bool | login_succeeded = false |
static nKrawall::nSalt | loginSalt |
static nHandler * | real_req_info_handler = NULL |
static nDescriptor | req_info (2, req_info_handler,"req_info") |
static std::auto_ptr < nServerInfoBase > | sn_redirectTo |
static nDescriptor | login_deny (3, login_deny_handler,"login_deny") |
nDescriptor | login (6, login_handler_1,"login1", true) |
nDescriptor | login_2 (11, login_handler_2,"login2", true) |
nDescriptor | logout (7, logout_handler,"logout") |
tString | sn_DenyReason |
static nDescriptor | login_ignore (4, login_ignore_handler,"login_ignore") |
bool | sn_AcceptingFromMaster |
static nDescriptor | login_accept (5, login_accept_handler,"login_accept", true) |
static REAL | sn_minBan = 120 |
static tSettingItem< REAL > | sn_minBanSetting ("NETWORK_MIN_BAN", sn_minBan) |
static bool | sn_lockOut028tTest = true |
static tSettingItem< bool > | sn_lockOut028TestConf ("NETWORK_LOCK_OUT_028_TEST", sn_lockOut028tTest) |
static REAL | sn_OrderPriority = 0 |
int | sn_SentBytes = 0 |
int | sn_SentPackets = 0 |
int | sn_ReceivedBytes = 0 |
int | sn_ReceivedPackets = 0 |
nTimeRolling | sn_StatsTime = 0 |
REAL | sent_per_messid [MAXDESCRIPTORS+100] |
static bool | sn_noReset = false |
static nDescriptor | sn_ConsoleOut_nd (8, sn_ConsoleOut_handler,"sn_ConsoleOut") |
static nDescriptor | client_cen_nd (9, client_cen_handler,"client_cen") |
static tConfItemFunc | ConsoleOut_c ("CONSOLE_MESSAGE",&ConsoleOut_conf) |
static tAccessLevelSetter | sn_ConsoleConfLevel (ConsoleOut_c, tAccessLevel_Moderator) |
static tConfItemFunc | CenterMessage_c ("CENTER_MESSAGE",&CeterMessage_conf) |
static tAccessLevelSetter | sn_CenterConfLevel (CenterMessage_c, tAccessLevel_Moderator) |
tHeap< planned_send > | send_queue [MAXCLIENTS+2] |
static tCallback * | s_loginoutAnchor = NULL |
static tCallbackOr * | s_AcceptAnchor = NULL |
static tCallback * | s_ReceivedCompleteAnchor = NULL |
static nCallbackAcceptPackedWithoutConnection net_acc & | net_Accept |
nBasicNetworkSystem | sn_BasicNetworkSystem |
static REAL | sn_spectatorTime = 0 |
static tSettingItem< REAL > | sn_spectatorTimeConf ("NETWORK_SPECTATOR_TIME", sn_spectatorTime) |
static REAL | sn_autobanOffset = 5 |
static REAL | sn_autobanFactor = 10 |
static REAL | sn_autobanMaxKPH = 30 |
static tSettingItem< REAL > | sn_autobanOffsetSetting ("NETWORK_AUTOBAN_OFFSET", sn_autobanOffset) |
static tSettingItem< REAL > | sn_autobanFactorSetting ("NETWORK_AUTOBAN_FACTOR", sn_autobanFactor) |
static tSettingItem< REAL > | sn_autobanMaxKPHSetting ("NETWORK_AUTOBAN_MAX_KPH", sn_autobanMaxKPH) |
static bool | sn_printBans = true |
static char const * | sn_machinesFileName = "bans.txt" |
static tConfItemFunc | sn_unBanConf ("UNBAN_IP",&sn_UnBanConf) |
static tConfItemFunc | sn_banConf ("BAN_IP",&sn_BanConf) |
static tConfItemFunc | sn_listBanConf ("BAN_LIST",&sn_ListBanConf) |
#define ACKBACK 1000 |
#define EXP (32-MANT) |
#define IDS_RESERVED 16 |
Definition at line 494 of file nNetwork.cpp.
#define MANT 26 |
#define MAX_MESS_LEN 300 |
#define MAXDESCRIPTORS 400 |
Definition at line 530 of file nNetwork.cpp.
Referenced by nDescriptor::HandleMessage(), and nDescriptor::nDescriptor().
#define MS (MANT-1) |
#define NO_ACK |
#define OVERHEAD 32 |
Definition at line 1880 of file nNetwork.cpp.
Referenced by nSendBuffer::Broadcast(), rec_peer(), and nSendBuffer::Send().
#define TRUE_ARMAGETRONAD_VERSION VERSION |
Definition at line 108 of file nNetwork.cpp.
typedef std::map< tString, nMachinePTR > nMachineMap |
Definition at line 4141 of file nNetwork.cpp.
typedef std::deque< tJUST_CONTROLLED_PTR< nMessage > > nMessageFifo |
Definition at line 2181 of file nNetwork.cpp.
void ack_handler | ( | nMessage & | m | ) |
Definition at line 626 of file nNetwork.cpp.
References nConnectionInfo::AckReceived(), nWaitForAck::Ackt(), nMessage::End(), nMessage::Read(), and nMessage::SenderID().
00628 { 00629 while (!m.End()){ 00630 sn_Connections[m.SenderID()].AckReceived(); 00631 00632 unsigned short ack; 00633 m.Read(ack); 00634 //con << "Got ack:" << ack << ":" << m.SenderID() << '\n'; 00635 nWaitForAck::Ackt(ack,m.SenderID());
static void CeterMessage_conf | ( | std::istream & | s | ) | [static] |
void clear_owners | ( | ) |
Definition at line 2025 of file nNetObject.cpp.
References GrowingArrayBase::Len(), and sn_netObjectsOwner.
02025 { 02026 sn_freedIDs.clear(); 02027 for (int i=sn_netObjectsOwner.Len()-1;i>=0;i--) 02028 sn_netObjectsOwner(i)=0; 02029 }
static void client_cen_handler | ( | nMessage & | m | ) | [static] |
Definition at line 2900 of file nNetwork.cpp.
02903 { 02904 if (sn_GetNetState()!=nSERVER){ 02905 tString s; 02906 m >> s;
static void ConsoleOut_conf | ( | std::istream & | s | ) | [static] |
Definition at line 2926 of file nNetwork.cpp.
02930 { 02931 // read the message 02932 tString message; 02933 message.ReadLine( s, true ); 02934 02935 message += "\n"; 02936
int CountSameConnection | ( | int | user | ) |
Definition at line 1562 of file nNetwork.cpp.
References nAddress::Compare(), and NULL.
01565 { 01566 int count = 0; 01567 for(int user2=1;user2<=MAXCLIENTS;++user2) 01568 { 01569 if( NULL == sn_Connections[user2].socket ) 01570 continue; 01571 01572 if ( user2 != user && nAddress::Compare( peers[user], peers[user2] ) == 0 ) 01573 { 01574 count++; 01575 } 01576 } 01577
int CountSameIP | ( | int | user, | |
bool | reset = false | |||
) |
Definition at line 1536 of file nNetwork.cpp.
References nAddress::Compare(), and tASSERT.
Referenced by GetFreeSlot().
01539 { 01540 static int sameIP[ MAXCLIENTS+2 ]; 01541 tASSERT( user >= 0 && user <= MAXCLIENTS+1 ); 01542 01543 if ( reset ) 01544 { 01545 int count = 0; 01546 for(int user2=1;user2<=MAXCLIENTS;++user2) 01547 { 01548 if(!sn_Connections[user2].socket) 01549 continue; 01550 01551 if ( user2 != user && nAddress::Compare( peers[user], peers[user2] ) >=0 ) 01552 { 01553 count++; 01554 } 01555 } 01556 01557 sameIP[user] = count; 01558 } 01559
void first_fill_ids | ( | ) |
Definition at line 518 of file nNetObject.cpp.
References ID_PREFETCH, id_req, nCLIENT, request, sn_GetNetState(), and tERR_ERROR.
Referenced by login_accept_handler(), and net_clear_handler().
00518 { 00519 if (sn_GetNetState()!=nCLIENT) 00520 tERR_ERROR("first_fill_ids is only for clients!"); 00521 00522 distribute=request=0; 00523 00524 tJUST_CONTROLLED_PTR< nMessage > m = new nMessage(id_req); 00525 m->Write(ID_PREFETCH - 10); 00526 m->Send(0); 00527 }
bool FloodProtection | ( | nMessage const & | m | ) |
Definition at line 954 of file nServerInfo.cpp.
References nQueryMessageStats::Block(), FloodProtection(), nMachine::GetMachine(), GetQueryMessageStats(), nMessage::SenderID(), and server().
Referenced by FloodProtection(), nServerInfo::GetBigServerInfoMaster(), nServerInfo::GiveBigServerInfo(), nServerInfo::GiveBigServerInfoMaster(), and nServerInfo::GiveSmallServerInfo().
00955 { 00956 // get the machine infos 00957 nMachine & server = nMachine::GetMachine( 0 ); 00958 nMachine & peer = nMachine::GetMachine( m.SenderID() ); 00959 00960 // only accept one ping per packet 00961 if ( !sn_firstInPacket ) 00962 { 00963 GetQueryMessageStats( peer ).Block(); 00964 00965 return true; 00966 } 00967 00968 // don't accept further queries from this packet 00969 sn_firstInPacket = false; 00970 00971 if ( sn_minPingTimes[sn_minPingCount - 1] <= 0 ) 00972 return false; 00973 00974 // and delegate 00975 return FloodProtection( peer ) || ( sn_minPingTimeGlobalFactor > 0 && FloodProtection( server, sn_minPingTimeGlobalFactor ) ); 00976 }
int GetFreeSlot | ( | ) |
Definition at line 1580 of file nNetwork.cpp.
References CountSameIP(), and sn_NumUsers().
01583 { 01584 int user; 01585 01586 // level 1: look for free slot 01587 if ( sn_NumUsers() < sn_maxClients ) 01588 { 01589 for(user=1;user<=sn_maxClients;++user) 01590 { 01591 // look for empty slot 01592 if(!sn_Connections[user].socket) 01593 { 01594 return user; 01595 } 01596 } 01597 } 01598 01599 int best = -1; 01600 01601 // level 2 kicked out users who were timing out and was not a good idea. 01602 01603 int bestCount = sn_allowSameIPCountSoft-1; 01604 01605 // level 3: look for dublicate IPs 01606 for(user=1;user<=MAXCLIENTS;++user) 01607 { 01608 int count = CountSameIP( user ); 01609 if ( count > bestCount ) 01610 { 01611 bestCount = count; 01612 best = user; 01613 } 01614 } 01615 if ( best > 0 ) 01616 return best; 01617
void handle_version_control | ( | nMessage & | m | ) |
Definition at line 380 of file nNetwork.cpp.
00383 { 00384 if ( sn_GetNetState() == nCLIENT ) 00385 { 00386 m >> sn_currentVersion; 00387 00388 // inform configuration of changes 00389 nConfItemVersionWatcher::OnVersionChange( sn_currentVersion );
void login_accept_handler | ( | nMessage & | m | ) |
Definition at line 1464 of file nNetwork.cpp.
References nMessage::End(), first_fill_ids(), nVersion::Max(), nReadError(), nSERVER, tRecorder::Playback(), nMessage::Read(), nKrawall::ReadScrambledPassword(), tRecorder::Record(), section, nMessage::SenderID(), sn_GetNetState(), sn_IsLANAddress(), sn_myAddress, and nConnectionInfo::version.
01466 { 01467 if (sn_GetNetState()!=nSERVER && m.SenderID() == 0){ 01468 unsigned short id=0; 01469 m.Read(id); 01470 01471 // read or reset server version info 01472 if ( !m.End() ) 01473 { 01474 m >> sn_Connections[0].version; 01475 01476 #ifdef DEBUG 01477 #define NOEXPIRE 01478 #endif 01479 01480 #ifndef NOEXPIRE 01481 #ifndef DEDICATED 01482 // expiration for public beta versions 01483 if ( !sn_AcceptingFromMaster && 01484 ( strstr( VERSION, "rc" ) || strstr( VERSION, "alpha" ) || strstr( VERSION, "beta" ) ) && 01485 sn_Connections[0].version.Max() > sn_currentProtocolVersion + 1 ) 01486 { 01487 throw tGenericException( tOutput("$testing_version_expired"), tOutput("$testing_version_expired_title" ) ); 01488 } 01489 #endif 01490 #endif 01491 } 01492 else 01493 sn_Connections[0].version = nVersion( 0, 0); 01494 01495 // read my public IP 01496 if ( !m.End() ) 01497 { 01498 // only accept it if it is not a LAN address 01499 tString address; 01500 m >> address; 01501 if ( !sn_IsLANAddress( address ) ) 01502 { 01503 sn_myAddress = address; 01504 } 01505 01506 // read salt reply and compare it to what we sent 01507 nKrawall::nSalt replySalt; 01508 nKrawall::ReadScrambledPassword( m, replySalt ); 01509 01510 int compare = memcmp( &loginSalt,&replySalt, sizeof(replySalt) ); 01511 01512 // since we generate a different random salt on playback, record the comparison result 01513 static const char * section = "LOGIN_SALT"; 01514 tRecorder::Playback( section, compare ); 01515 tRecorder::Record( section, compare ); 01516 01517 if ( compare != 0 ) 01518 { 01519 nReadError( false ); 01520 } 01521 } 01522 01523 // only now, login can be considered a success 01524 login_succeeded=true; 01525 sn_myNetID=id; 01526 01527 first_fill_ids();
void login_deny_handler | ( | nMessage & | m | ) |
Definition at line 1386 of file nNetwork.cpp.
01388 { 01389 if ( !m.End() ) 01390 { 01391 // tOutput output; 01392 // m >> output; 01393 // sn_DenyReason = output; 01394 m >> sn_DenyReason; 01395 } 01396 else 01397 { 01398 sn_DenyReason = tOutput( "$network_kill_unknown" ); 01399 } 01400 01401 if ( !m.End() ) 01402 { 01403 // read redirection data from message 01404 tString connectionName; 01405 m >> connectionName; 01406 int port; 01407 m >> port; 01408 01409 if ( connectionName.Len() > 1 ) 01410 { 01411 // create server info and fill it with data 01412 sn_redirectTo = std::auto_ptr< nServerInfoBase>( new nServerInfoRedirect( connectionName, port ) ); 01413 } 01414 } 01415 01416 if (!login_failed) 01417 con << tOutput("$network_login_denial"); 01418 if (sn_GetNetState()!=nSERVER){ 01419 login_failed=true; 01420 login_succeeded=false; 01421 sn_SetNetState(nSTANDALONE);
int login_handler | ( | nMessage & | m, | |
unsigned short | rate | |||
) |
Definition at line 1629 of file nNetwork.cpp.
01631 { 01632 nCurrentSenderID senderID; 01633 01634 // read version and suppored authentication methods 01635 nVersion version; 01636 tString supportedAuthenticationMethods(""); 01637 nKrawall::nSalt salt; // it's OK that this may stay uninitialized 01638 if ( !m.End() ) 01639 { 01640 // read version 01641 m >> version; 01642 01643 // ok, clients that send a version do have at lesat basic authentication. 01644 supportedAuthenticationMethods = "bmd5"; 01645 } 01646 if ( !m.End() ) 01647 { 01648 // read authentication methods 01649 m >> supportedAuthenticationMethods; 01650 } 01651 if ( !m.End() ) 01652 { 01653 // also read a login salt, the client expects to get it returned verbatim 01654 nKrawall::ReadScrambledPassword( m, salt ); 01655 } 01656 01657 // don't accept logins in client mode 01658 if (sn_GetNetState() != nSERVER) 01659 return -1; 01660 01661 // ban users 01662 nMachine & machine = nMachine::GetMachine( m.SenderID() ); 01663 REAL banned = machine.IsBanned(); 01664 if ( banned > 0 ) 01665 { 01666 // the reason for the ban 01667 tString const & reason = machine.GetBanReason(); 01668 01669 // ban user some more so he learns 01670 if ( banned < sn_minBan ) 01671 { 01672 machine.Ban( sn_minBan ); 01673 banned = sn_minBan; 01674 } 01675 else 01676 con << tOutput( "$network_ban", machine.GetIP() , int(banned/60), reason.Len() > 1 ? reason : tOutput( "$network_ban_noreason" ) ); 01677 01678 sn_DisconnectUser(m.SenderID(), tOutput( "$network_kill_banned", int(banned/60), reason ) ); 01679 } 01680 01681 // ignore multiple logins 01682 if( CountSameConnection( m.SenderID() ) > 0 ) 01683 return -1; 01684 01685 // ignore login floods 01686 if ( FloodProtection( m ) ) 01687 return -1; 01688 01689 bool success=false; 01690 01691 int new_id = -1; 01692 01693 // test 01694 // sn_DisconnectUser(m.SenderID(), "$network_kill_incompatible"); 01695 // return -1; 01696 01697 nVersion mergedVersion; 01698 if ( !mergedVersion.Merge( version, sn_CurrentVersion() ) ) 01699 { 01700 sn_DisconnectUser(m.SenderID(), "$network_kill_incompatible"); 01701 } 01702 01703 // expire 0.2.8 test versions, they have a security flaw 01704 if ( sn_lockOut028tTest && version.Max() >= 5 && version.Max() <= 10 ) 01705 { 01706 sn_DisconnectUser(m.SenderID(), "0.2.8_beta and 0.2.8.0_rc versions have a dangerous security flaw and are obsoleted, please upgrade to 0.2.8.2.1."); 01707 } 01708 01709 if (m.SenderID()!=MAXCLIENTS+1) 01710 { 01711 //con << "Ignoring second login from " << m.SenderID() << ".\n"; 01712 (new nMessage(login_ignore))->Send(m.SenderID()); 01713 } 01714 else if (sn_Connections[m.SenderID()].socket) 01715 { 01716 if ( sn_maxClients > MAXCLIENTS ) 01717 sn_maxClients = MAXCLIENTS; 01718 01719 // count doublicate IPs 01720 if ( CountSameIP( m.SenderID(), true ) < sn_allowSameIPCountHard ) 01721 { 01722 // find new free ( or freeable ) ID 01723 new_id = GetFreeSlot(); 01724 if ( new_id > 0 ) 01725 { 01726 if(sn_Connections[new_id].socket) 01727 sn_DisconnectUser( new_id, "$network_kill_full" ); 01728 01729 success = true; 01730 01731 senderID.SetID( new_id ); 01732 01733 sn_Connections [ new_id ].socket = sn_Connections[MAXCLIENTS+1].socket; // the new connection has number MC+1 01734 peers [ new_id ] = peers[MAXCLIENTS+1]; 01735 timeouts [ new_id ] = kickOnDemandTimeout/2; 01736 01737 // sn_Connections [ MAXCLIENTS+1 ].socket = NULL; 01738 // peers [ MAXCLIENTS+1 ].sa_family = 0; 01739 // nCallbackLoginLogout::UserLoggedIn(i); 01740 01741 sn_Connections [ new_id ].supportedAuthenticationMethods_ = supportedAuthenticationMethods; 01742 01743 // recount doublicate IPs 01744 CountSameIP( new_id, true ); 01745 } 01746 } 01747 01748 // log login to console 01749 tOutput o; 01750 o.SetTemplateParameter(1, peers[m.SenderID()].ToString() ); 01751 o.SetTemplateParameter(2, sn_Connections[m.SenderID()].socket->GetAddress().ToString() ); 01752 o << "$network_server_login"; 01753 con << o; 01754 } 01755 if (success) 01756 { 01757 tOutput o; 01758 o.SetTemplateParameter(1, new_id); 01759 o << "$network_server_login_success"; 01760 con << o; 01761 // tString s; 01762 // s << "User " << new_id << " logged in.\n"; 01763 01764 sn_Connections[new_id].ping.Reset(); 01765 sn_Connections[new_id].bandwidthControl_.Reset(); 01766 reset_last_acks(new_id); 01767 01768 if (rate>sn_maxRateOut) 01769 rate=sn_maxRateOut; 01770 01771 sn_Connections[new_id].bandwidthControl_.SetRate( rate ); 01772 sn_Connections[new_id].version = version; 01773 01774 nWaitForAck::AckAllPeer(MAXCLIENTS+1); 01775 reset_last_acks(MAXCLIENTS+1); 01776 if (sn_Connections[MAXCLIENTS+1].ackMess) 01777 { 01778 sn_Connections[MAXCLIENTS+1].ackMess=NULL; 01779 } 01780 01781 // send login accept message with high priority 01782 nMessage *rep=new nMessage(login_accept); 01783 rep->Write(new_id); 01784 (*rep) << sn_myVersion; 01785 (*rep) << peers[m.SenderID()].ToString(); 01786 nKrawall::WriteScrambledPassword( salt, *rep ); 01787 01788 rep->Send(new_id, -killTimeout); 01789 01790 nMessage::SendCollected( new_id ); 01791 01792 nConfItemBase::s_SendConfig(true, new_id); 01793 01794 // fake activity 01795 nMachine & machine = nMachine::GetMachine( new_id ); 01796 machine.AddPlayer(); 01797 machine.RemovePlayer(); 01798 01799 nCallbackLoginLogout::UserLoggedIn(new_id); 01800 01801 // ANET_Listen(false); 01802 // ANET_Listen(true); 01803 } 01804 else if (m.SenderID()==MAXCLIENTS+1) 01805 { 01806 sn_DisconnectUser(MAXCLIENTS+1, "$network_kill_full"); 01807 } 01808 01809 sn_UpdateCurrentVersion(); 01810
void login_handler_1 | ( | nMessage & | m | ) |
Definition at line 1812 of file nNetwork.cpp.
01815 { 01816 unsigned short rate; 01817 01818 m.Read( rate ); 01819 01820 if ( !m.End() ){ // we get a big brother message (ignore it) 01821 tString rem_bb; 01822 m >> rem_bb; 01823 } 01824
void login_handler_2 | ( | nMessage & | m | ) |
Definition at line 1826 of file nNetwork.cpp.
01829 { 01830 unsigned short rate; 01831 unsigned short bb; 01832 01833 m.Read( rate ); 01834 m.Read( bb ); 01835 tString rem_bb; 01836 01837 if ( bb ) 01838 { // we get a big brother message 01839 m >> rem_bb; 01840 } 01841 01842 int new_ID = login_handler( m, rate ); 01843 01844 if ( new_ID > 0 ) 01845 { 01846 nMessage* m = tNEW( nMessage )( versionControl ); 01847 (*m) << sn_currentVersion; 01848 01849 m->Send( new_ID ); 01850 01851 if ( bb ) 01852 { 01853 std::ofstream s; 01854 if ( tDirectories::Var().Open(s, "big_brother",std::ios::app) ) 01855 s << rem_bb << '\n'; 01856 }
void login_ignore_handler | ( | nMessage & | m | ) |
Definition at line 1435 of file nNetwork.cpp.
References nSERVER, and sn_GetNetState().
01437 { 01438 if (sn_GetNetState()!=nSERVER && !login_succeeded){ 01439 /* 01440 login_failed=true; 01441 login_succeeded=false; 01442 01443 // kicking the one who uses our place 01444 // (he is probably timing out anyway..) 01445 nMessage *lo=new nMessage(logout); 01446 lo->Write((unsigned short)sn_myNetID); 01447 lo->Send(0); 01448 01449 sn_Sync(10); 01450 01451 (new nMessage(login))->Send(0); 01452 */ 01453 } 01454
void logout_handler | ( | nMessage & | m | ) |
Definition at line 1859 of file nNetwork.cpp.
References nWaitForAck::AckAllPeer(), con, nMessage::SenderID(), tOutput::SetTemplateParameter(), and sn_DisconnectUser().
01861 { 01862 unsigned short id = m.SenderID(); 01863 //m.Read(id); 01864 01865 if (sn_Connections[id].socket) 01866 { 01867 tOutput o; 01868 o.SetTemplateParameter(1, id); 01869 o << "$network_logout_server"; 01870 con << o; 01871 } 01872 nWaitForAck::AckAllPeer(id); 01873 01874 if (0<id && id<=MAXCLIENTS) 01875 { 01876 sn_DisconnectUser(id, "$network_kill_logout");
static bool net_Accept | ( | ) | [static] |
static void net_exit | ( | ) | [static] |
Definition at line 3327 of file nNetwork.cpp.
03330 { 03331 for (int i=MAXCLIENTS+1;i>=0;i--) 03332 { 03333 sn_Connections[i].ackMess = NULL; 03334 while (send_queue[i].Len())
static tInitExit net_ie | ( | NULL | , | |
& | net_exit | |||
) | [static] |
void nReadError | ( | bool | critical | ) |
Definition at line 2792 of file nNetwork.cpp.
References con.
Referenced by nNOInitialisator< T >::Init(), login_accept_handler(), nNetObject::Object(), nMessage::Read(), nNetObject::Register(), and nConfItemBase::s_GetConfigMessage().
02795 { 02796 // st_Breakpoint(); 02797 #ifndef NOEXCEPT 02798 if ( critical ) 02799 throw nKillHim(); 02800 else 02801 throw nIgnore(); 02802 #else 02803 con << "\nI told you not to use PGCC! Now we need to leave the\n" 02804 << "system in an undefined state. The progam will crash now.\n"
std::ostream& operator<< | ( | std::ostream & | stream, | |
nAverager const & | averager | |||
) |
write operator for nAveragers
stream | stream to write to | |
averager | averager to write |
Definition at line 3813 of file nNetwork.cpp.
std::ostream& operator<< | ( | std::ostream & | s, | |
const nVersion & | ver | |||
) |
std::istream& operator>> | ( | std::istream & | stream, | |
nAverager & | averager | |||
) |
read operator for nAveragers
stream | stream to read to | |
averager | averager to read |
Definition at line 3796 of file nNetwork.cpp.
std::istream& operator>> | ( | std::istream & | s, | |
nVersion & | ver | |||
) |
Definition at line 323 of file nNetwork.cpp.
00326 { 00327 int min,max; 00328 s >> min; 00329 s >> max; 00330 00331 ver = nVersion( min, max ); 00332
Definition at line 304 of file nNetwork.cpp.
00307 { 00308 int min,max; 00309 m >> min; 00310 m >> max; 00311 00312 ver = nVersion( min, max ); 00313
static void rec_peer | ( | unsigned int | peer | ) | [static] |
Definition at line 2183 of file nNetwork.cpp.
References nCallbackAcceptPackedWithoutConnection::Accept(), ACKBACK, nConnectionInfo::ackMess, nAddress::Compare(), con, nMessage::Descriptor(), nMachine::Expire(), nDescriptor::HandleMessage(), nDescriptor::ID(), GrowingArrayBase::Len(), login, login_accept, login_deny, login_ignore, nMessage::MessageID(), NO_ACK, nSERVER, nSTANDALONE, NULL, OVERHEAD, nSocket::Read(), nCallbackReceivedComplete::ReceivedComplete(), sn_DisconnectUser(), sn_GetNetState(), nConnectionInfo::socket, tASSERT, tERR_WARN, and tNEW.
Referenced by sn_ReceiveFromControlSocket().
02185 { 02186 tASSERT( sn_Connections[peer].socket ); 02187 02188 nMachine::Expire(); 02189 02190 // temporary fifo for received messages 02191 //static tArray< tJUST_CONTROLLED_PTR< nMessage > > receivedMessages; 02192 static nMessageFifo receivedMessages; 02193 02194 // the growing buffer we read messages into 02195 const int serverMaxAcceptedSize=2000; 02196 static tArray< unsigned short > storage(2000); 02197 int maxrec = 0; maxrec = storage.Len(); 02198 unsigned short * buff = 0; buff = &storage[0]; 02199 02200 // short buff[maxrec]; 02201 if (sn_Connections[peer].socket){ 02202 int count=0; 02203 int len=1; 02204 while (len>=0 && sn_Connections[peer].socket) 02205 { 02206 nAddress addrFrom; // the sender of the current packet 02207 len = sn_Connections[peer].socket->Read( reinterpret_cast<int8 *>(buff),maxrec*2, addrFrom); 02208 02209 if (len>0){ 02210 if ( len >= maxrec*2 ) 02211 { 02212 // the message was too long to receive. What to do? 02213 if ( sn_GetNetState() != nSERVER || len < serverMaxAcceptedSize ) 02214 { 02215 // expand the buffer. The message is lost now, but the 02216 // peer will certainly resend it. Hopefully, the buffer will be large enough to hold it then. 02217 storage[maxrec*2-1]=0; 02218 maxrec = storage.Len(); 02219 buff = &storage[0]; 02220 02221 tERR_WARN( "Oversized network packet received. Read buffer has been enlargened to catch it the next time."); 02222 02223 // no use in processing the truncated packet. Some messages may get lost, 02224 // but that's better than the inevitable network error and connection 02225 // termination that expects us if we go on. 02226 continue; 02227 } 02228 else 02229 { 02230 // terminate the connection 02231 sn_DisconnectUser( peer, "$network_kill_error" ); 02232 } 02233 } 02234 02235 unsigned short *b=buff; 02236 unsigned short *bend=buff+(len/2-1); 02237 02238 sn_ReceivedPackets++; 02239 sn_ReceivedBytes += len + OVERHEAD; 02240 02241 unsigned short claim_id=ntohs(*bend); 02242 02243 // z-man: security check ( thanks, Luigi Auriemma! ) 02244 if ( claim_id > MAXCLIENTS+1 ) 02245 continue; // drop packet, maybe it was just truncated. 02246 02247 /* 02248 std::cerr << "Received " << len << " bytes"; 02249 con << " from user " << claim_id << '\n'; 02250 */ 02251 count ++; 02252 02253 unsigned int id=peer; 02254 // for(unsigned int i=1;i<=(unsigned int)maxclients;i++) 02255 int comp=nAddress::Compare( addrFrom, peers[claim_id] ); 02256 if ( comp == 0 ) // || claim_id == MAXCLIENTS+1 ) 02257 { 02258 // everything seems allright. accept the id. 02259 id = claim_id; 02260 } 02261 else 02262 { 02263 // assume it's a new connection 02264 id = MAXCLIENTS+1; 02265 peers[ MAXCLIENTS+1 ] = addrFrom; 02266 sn_Connections[ MAXCLIENTS+1 ].socket = sn_Connections[peer].socket; 02267 } 02268 02269 // if (peer!=id) 02270 // con << "Changed incoming address.\n"; 02271 int lenleft = bend - b; 02272 02273 #ifndef NOEXCEPT 02274 try 02275 { 02276 #endif 02277 while( lenleft > 0 ){ 02278 tJUST_CONTROLLED_PTR< nMessage > pmess; 02279 pmess = tNEW( nMessage )(b,id,lenleft); 02280 nMessage& mess = *pmess; 02281 02282 lenleft = bend - b; 02283 02284 bool mess_is_new=true; 02285 // see if we have got this packet before 02286 unsigned short mess_id=mess.MessageID(); 02287 02288 #ifdef DEBUG 02289 if ( (simulate_loss && rand()%simulate_loss==0)){ 02290 // simulate packet loss 02291 con << "Losing packet " << mess_id << ":" << id << ".\n"; 02292 }else 02293 #endif 02294 if(// (id==MAXCLIENTS+1 && !nCallbackAcceptPackedWithoutConnection::Accept( mess ) ) || 02295 // do not accept normal packages from the login 02296 // slot; just login and information packets are allowed. 02297 ( sn_GetNetState() != nSERVER && !login_succeeded && !nCallbackAcceptPackedWithoutConnection::Accept( mess ) ) 02298 // if we are not yet logged in, accept only login and login_deny. 02299 ) 02300 { 02301 // con << "Ignoring packet " << mess_id << ":" << id << ".\n"; 02302 } 02303 else 02304 { 02305 if (id <= MAXCLIENTS && mess_id != 0) // messages with ID 0 are non-ack messages and come really often. they are always new. 02306 { 02307 unsigned short diff=mess_id-highest_ack[id]; 02308 if (diff>0 && diff<10000 || 02309 (( 02310 mess.Descriptor() == login_accept.ID() || 02311 mess.Descriptor() == login_deny.ID() || 02312 mess.Descriptor() == login.ID() 02313 ) && highest_ack[id] == 0) 02314 ){ 02315 // the message has a more recent id than anything before. 02316 // it is surely new. 02317 highest_ack[id]=mess_id; 02318 } 02319 else{ 02320 // do a better check 02321 for(int i=ACKBACK-1;i>=0;i--) 02322 if (mess_id==lastacks[id][i]) 02323 mess_is_new=false; 02324 } 02325 } 02326 02327 02328 // acknowledge the message, even if it was old (the sender 02329 // then thinks it got lost the first time) 02330 02331 // special situation: logout. Do not sent ack any more. 02332 if ((!sn_Connections[id].socket)) 02333 { 02334 sn_Connections[id].ackMess=NULL; 02335 } 02336 else if ( 02337 #ifdef NO_ACK 02338 (mess.MessageID()) && 02339 #endif 02340 (mess.Descriptor()!=login_ignore.ID() || 02341 login_succeeded )){ 02342 // do not ack the login_ignore packet that did not let you in. 02343 02344 #ifdef DEBUG 02345 if ( id > MAXCLIENTS ) 02346 { 02347 con << "Sending ack to login slot.\n"; 02348 } 02349 #endif 02350 02351 if(sn_Connections[id].ackMess==NULL) 02352 { 02353 sn_Connections[id].ackMess=new nAckMessage(); 02354 } 02355 02356 sn_Connections[id].ackMess->Write(mess.MessageID()); 02357 if (sn_Connections[id].ackMess->DataLen()>100){ 02358 sn_Connections[id].ackMess->Send(id, 0, false); 02359 sn_Connections[id].ackMess=NULL; 02360 } 02361 } 02362 02363 if (mess_is_new){ 02364 // mark the message as old 02365 if (mess_id > 0) 02366 { 02367 lastacks[id][lastackPos[id]]=mess_id; 02368 if(++lastackPos[id]>=ACKBACK) lastackPos[id]=0; 02369 } 02370 02371 /* 02372 // special situation: login. Change peer number permanently 02373 if (peer==MAXCLIENTS+1 && new_id>0){ 02374 id=peer=new_id; 02375 } 02376 */ 02377 02378 if (sn_GetNetState() != nSTANDALONE) 02379 { 02380 // store the message for later processing 02381 receivedMessages.push_back( pmess ); 02382 } 02383 } 02384 //else 02385 //con << "Message " << mess_id << ":" << id << " was not new.\n"; 02386 } 02387 } 02388 #ifndef NOEXCEPT 02389 } 02390 02391 catch(nKillHim) 02392 { 02393 con << "nKillHim signal caught.\n"; 02394 sn_DisconnectUser(peer, "$network_kill_error"); 02395 } 02396 #endif 02397 } 02398 #ifndef NOEXCEPT 02399 try 02400 { 02401 #endif 02402 static int recursionCount = 0; 02403 ++recursionCount; 02404 02405 // handle messages 02406 while ( receivedMessages.begin() != receivedMessages.end() ) 02407 { 02408 tJUST_CONTROLLED_PTR< nMessage > mess = receivedMessages.front(); 02409 receivedMessages.pop_front(); 02410 02411 // perhaps the connection died? 02412 if ( sn_Connections[ mess->SenderID() ].socket ) 02413 nDescriptor::HandleMessage( *mess ); 02414 } 02415 02416 if ( --recursionCount <= 0 ) 02417 { 02418 nCallbackReceivedComplete::ReceivedComplete(); 02419 } 02420 02421 #ifndef NOEXCEPT 02422 } 02423 02424 catch(nKillHim const &) 02425 { 02426 con << "nKillHim signal caught.\n"; 02427 sn_DisconnectUser(peer, "$network_kill_error"); 02428 } 02429 #endif 02430 02431 }
void req_info_handler | ( | nMessage & | m | ) |
Definition at line 1361 of file nNetwork.cpp.
References nMessage::SenderID(), and sn_DisconnectUser().
01363 { 01364 if (real_req_info_handler) 01365 (*real_req_info_handler)(m); 01366 if (m.SenderID()==MAXCLIENTS+1)
void RequestInfoHandler | ( | nHandler * | handle | ) |
static void reset_last_acks | ( | int | i | ) | [static] |
Definition at line 468 of file nNetwork.cpp.
References ACKBACK.
00470 { 00471 for(int j=ACKBACK-1;j>=0;j--) 00472 lastacks[i][j]=0; 00473 lastackPos[i]=0;
static void sn_AddToString | ( | tString & | s, | |
tString::CHAR | c | |||
) | [static] |
static void sn_BanConf | ( | std::istream & | s | ) | [static] |
Definition at line 4686 of file nNetwork.cpp.
04690 { 04691 // read IP to unban 04692 tString address; 04693 s >> address; 04694 04695 if ( !s.good() && address.Len() < 7 ) 04696 { 04697 con << "Usage: BAN_IP <ip> <time in minutes (defaults to 60)> <reason>\n"; 04698 return; 04699 } 04700 04701 REAL duration = 60; 04702 s >> duration; 04703 04704 // read reason 04705 tString reason; 04706 std::ws(s); 04707 if ( s.good() ) 04708 { 04709 reason.ReadLine(s); 04710 } 04711 04712 // and ban 04713 if ( address.Len() > 4 ) 04714 {
void sn_Bend | ( | tString const & | server, | |
unsigned int | port | |||
) |
Definition at line 2623 of file nNetwork.cpp.
02626 { 02627 // fill address info 02628 nAddress address; 02629 address.SetHostname( server ); 02630 address.SetPort( port ); 02631 02632 // delegate
void sn_Bend | ( | nAddress const & | address | ) |
Definition at line 2615 of file nNetwork.cpp.
References nCLIENT, nSTANDALONE, sn_GetNetState(), and sn_SetNetState().
Referenced by nServerInfo::NetReadThis(), and nServerInfo::QueryServer().
02618 { 02619 if ((sn_GetNetState() == nSTANDALONE)) 02620 sn_SetNetState(nCLIENT); 02621
void sn_CenterMessage | ( | const tOutput & | o, | |
int | client | |||
) |
Definition at line 2911 of file nNetwork.cpp.
Referenced by gGame::Analysis(), StartNewMatch(), gGame::StateUpdate(), and update_settings().
02914 { 02915 tString message(o); 02916 02917 tJUST_CONTROLLED_PTR< nMessage > m=new nMessage(client_cen_nd); 02918 *m << message; 02919 if (client<0){ 02920 m->BroadCast(); 02921 con.CenterDisplay(message); 02922 } 02923 else if (client==sn_myNetID) 02924 con.CenterDisplay(message);
nConnectError sn_Connect | ( | nAddress const & | server, | |
nLoginType | loginType, | |||
nSocket const * | socket | |||
) |
Definition at line 2634 of file nNetwork.cpp.
Referenced by client(), nServerInfoBase::Connect(), and ntest().
02636 { 02637 sn_DenyReason = ""; 02638 02639 // reset redirection 02640 sn_redirectTo.release(); 02641 02642 // pings in the beginning of the login are not really representative 02643 nPingAverager::SetWeight(.0001); 02644 02645 // net_hostport = sn_clientPort; 02646 02647 sn_SetNetState(nSTANDALONE); 02648 sn_SetNetState(nCLIENT); 02649 02650 // set user requested socket 02651 if ( socket ) 02652 sn_Connections[0].socket = socket; 02653 02654 sn_Connections[0].ping.Reset(); 02655 02656 peers[0] = server; 02657 02658 reset_last_acks(0); 02659 nCallbackLoginLogout::UserLoggedOut(0); 02660 sn_Connections[0].sendBuffer_.Clear(); 02661 02662 tASSERT( sn_Connections[0].socket ); 02663 02664 // sn_Connections[0].socket->Connect( peers[0] ); // useless 02665 sn_Connections[0].bandwidthControl_.SetRate( sn_maxRateOut ); 02666 02667 sn_myNetID=0; // MAXCLIENTS+1; // reset network id 02668 02669 // first, get all pending messages 02670 sn_Receive(); 02671 sn_Receive(); 02672 sn_Receive(); 02673 02674 // reset version control until the true value is given by the server. 02675 sn_currentVersion = nVersion(0,0); 02676 02677 // Login stuff..... 02678 tJUST_CONTROLLED_PTR< nMessage > mess; 02679 if ( loginType != Login_Pre0252 ) 02680 { 02681 mess=new nMessage(login_2); 02682 mess->Write(sn_maxRateIn); 02683 02684 unsigned short bb = big_brother; 02685 mess->Write( bb ); 02686 if ( bb ){ 02687 (*mess) << sn_bigBrotherString; 02688 big_brother=false; 02689 } 02690 } 02691 else 02692 { 02693 mess=new nMessage(login); 02694 mess->Write(sn_maxRateIn); 02695 02696 // send (worthless) big brother string 02697 if (big_brother) 02698 { 02699 (*mess) << sn_bigBrotherString; 02700 } 02701 else 02702 { 02703 (*mess) << tString(""); 02704 } 02705 02706 big_brother=false; 02707 } 02708 02709 // write our version 02710 (*mess) << sn_MyVersion(); 02711 02712 // write our supported authentication methods 02713 (*mess) << nKrawall::nMethod::SupportedMethods(); 02714 02715 // write a random salt 02716 nKrawall::RandomSalt( loginSalt ); 02717 nKrawall::WriteScrambledPassword( loginSalt, *mess ); 02718 02719 mess->ClearMessageID(); 02720 mess->SendImmediately(0,false); 02721 nMessage::SendCollected(0); 02722 02723 con << tOutput("$network_login_process"); 02724 02725 login_failed=false; 02726 login_succeeded=false; 02727 02728 nTimeRolling timeout=tSysTimeFloat()+5; 02729 02730 static REAL resend = .25; 02731 nTimeAbsolute nextSend = tSysTimeFloat() + resend/5; 02732 while(sn_GetNetState()==nCLIENT && tSysTimeFloat()<timeout && 02733 !login_failed && !login_succeeded){ 02734 if ( tSysTimeFloat() > nextSend ) 02735 { 02736 // con << "retrying...\n"; 02737 nextSend = tSysTimeFloat() + resend; 02738 mess->SendImmediately(0,false); 02739 nMessage::SendCollected(0); 02740 } 02741 02742 tAdvanceFrame(10000); 02743 sn_Receive(); 02744 sn_SendPlanned(); 02745 02746 // check for user abort 02747 if ( tConsole::Idle() ) 02748 { 02749 con << tOutput("$network_login_failed_abort"); 02750 sn_SetNetState(nSTANDALONE); 02751 return nABORT; 02752 } 02753 } 02754 if (login_failed) 02755 { 02756 con << tOutput("$network_login_failed"); 02757 sn_SetNetState(nSTANDALONE); 02758 return nDENIED; 02759 } 02760 else if (tSysTimeFloat()>=timeout || sn_GetNetState()!=nCLIENT){ 02761 if ( loginType == Login_All ) 02762 { 02763 return sn_Connect( server, Login_Pre0252, socket ); 02764 } 02765 else 02766 { 02767 con << tOutput("$network_login_failed_timeout"); 02768 sn_SetNetState(nSTANDALONE); 02769 return nTIMEOUT; 02770 } 02771 } 02772 else{ 02773 nCallbackLoginLogout::UserLoggedIn(0); 02774 02775 tOutput mess; 02776 mess.SetTemplateParameter(1, sn_myNetID); 02777 mess << "$network_login_success"; 02778 con << mess; 02779 con << tOutput("$network_login_sync"); 02780 sn_Sync(40); 02781 con << tOutput("$network_login_relabeling"); 02782 con << tOutput("$network_login_sync2"); 02783 sn_Sync(40,true); 02784 con << tOutput("$network_login_done"); 02785 02786 // marginalize past ping values 02787 nPingAverager::SetWeight(1); 02788 02789 return nOK;
void sn_ConsoleOut | ( | const tOutput & | o, | |
int | client | |||
) |
Definition at line 2883 of file nNetwork.cpp.
Referenced by eVoteItem::AcceptNewVote(), eTeam::AddPlayer(), eTeam::AddScore(), ePlayerNetID::AddScore(), gGame::Analysis(), eVoteItem::BroadcastMessage(), eChatSpamTester::Check(), nSpamProtection::CheckSpam(), eVoteItem::CheckValid(), ePlayerNetID::CreateNewTeam(), eVoteItemKick::DoCheckValid(), eVoteItemHarm::DoCheckValid(), ePlayerNetID::FindPlayerByName(), eVoteItem::GetControlMessage(), eVoter::GetVoter(), eVoter::HandleChat(), nDescriptor::HandleMessage(), eTeam::Invite(), IsSilencedWithWarning(), gCycle::KillAt(), gBaseZoneHack::OnVanish(), eVoteItem::ReBroadcast(), ePlayerNetID::ReceiveControlNet(), eTeam::RemovePlayer(), se_CancelAllVotes(), se_ChatMe(), se_ChatMsg(), se_ChatShuffle(), se_ChatTeam(), se_ChatTeamLeave(), se_FindPlayerInChatCommand(), se_LoginWanted(), se_rubyEval(), se_SendTo(), eTeam::SetLocked(), ePlayerNetID::SetTeam(), ePlayerNetID::SetTeamWish(), sg_CreateWinDeathZone(), sg_FullscreenMessage(), sg_TopologyPoliceKill(), eTeam::Shuffle(), StartNewMatch(), gGame::StateUpdate(), ePlayerNetID::Suspend(), ePlayerNetID::TeamChangeAllowed(), gBaseZoneHack::Timestep(), eTeam::UnInvite(), ePlayerNetID::Update(), update_settings(), eTeam::UpdateAppearance(), ePlayerNetID::UpdateName(), ePlayerNetID::UpdateTeam(), and ePlayerNetID::WaitToLeaveChat().
02886 { 02887 // tString message(o); 02888 02889 tJUST_CONTROLLED_PTR< nMessage > m = sn_ConsoleOutMessage( o ); 02890 02891 if (client<0){ 02892 m->BroadCast(); 02893 con << o; 02894 } 02895 else if (client==sn_myNetID) 02896 { 02897 con << o; 02898 }
static void sn_ConsoleOut_handler | ( | nMessage & | m | ) | [static] |
Definition at line 2847 of file nNetwork.cpp.
References con, nSERVER, and sn_GetNetState().
02850 { 02851 if (sn_GetNetState()!=nSERVER){ 02852 tString s; 02853 m >> s;
Definition at line 2859 of file nNetwork.cpp.
Referenced by se_OldChatMessage().
02863 { 02864 tString message(o); 02865 message << "0xffffff"; 02866 02867 // truncate message to 1.4K, a safe size for all UDP packets 02868 static const int maxLen = 1400; 02869 static bool recurse = true; 02870 if ( message.Len() > maxLen && recurse ) 02871 { 02872 recurse = false; 02873 tERR_WARN( "Long console message truncated."); 02874 02875 message.SetLen( maxLen+1 ); 02876 message[maxLen]='\0'; 02877 recurse = false; 02878 } 02879 02880 nMessage* m=new nMessage(sn_ConsoleOut_nd); 02881 *m << message;
const nVersion& sn_CurrentVersion | ( | ) |
the version currently supported by all connected players
Definition at line 240 of file nNetwork.cpp.
Referenced by nServerInfo::DoGetFrom(), and nConfItemVersionWatcher::DoWritable().
void sn_Delay | ( | ) |
pause a bit, abort pause on network activity
Definition at line 134 of file nNetwork.cpp.
Referenced by ConnectToServerCore(), gGame::NetSyncIdle(), and sn_Sync().
00136 { 00137 sn_BasicNetworkSystem.Select( sn_defaultDelay / 1000000.0 ); 00138 tAdvanceFrame();
void sn_DiscardFromControlSocket | ( | ) |
Definition at line 2440 of file nNetwork.cpp.
References nSocket::Read(), and nConnectionInfo::socket.
Referenced by sg_Receive().
02443 { 02444 // new facts: pending incoming data on the control socket causes the idle loops 02445 // to use 100% CPU time, we need to fetch and discard the data instead of ignoring it. 02446 if ( sn_Connections[0].socket ) 02447 { 02448 int8 buff[2]; 02449 nAddress addrFrom; 02450 sn_Connections[0].socket->Read( reinterpret_cast<int8 *>(buff),0, addrFrom);
static void sn_DisconnectAll | ( | ) | [static] |
Definition at line 2505 of file nNetwork.cpp.
02508 { 02509 for(int i=MAXCLIENTS+1;i>=0;i--) 02510 { 02511 if( sn_Connections[i].socket ) 02512 { 02513 sn_DisconnectUser(i, "$network_kill_shutdown"); 02514 tVERIFY( !sn_Connections[i].socket ); 02515 } 02516 }
void sn_DisconnectUser | ( | int | i, | |
const tOutput & | reason, | |||
nServerInfoBase * | redirectTo | |||
) |
terminate connection with user i (peacefully)
Definition at line 3167 of file nNetwork.cpp.
Referenced by Cheater(), nDescriptor::HandleMessage(), kill_id_hog(), logout_handler(), ePlayerNetID::MyInitAfterCreation(), rec_peer(), req_info_handler(), and nServerInfo::RunMaster().
03171 { 03172 // don't be daft and kill yourself, server! 03173 if ( i == 0 && sn_GetNetState() == nSERVER ) 03174 { 03175 tERR_WARN( "Server tried to disconnect from itself." ); 03176 return; 03177 } 03178 03179 // clients can only disconnect from the server 03180 if ( i != 0 && sn_GetNetState() == nCLIENT ) 03181 { 03182 tERR_ERROR( "Client tried to disconnect from another client: impossible and a bad idea." ); 03183 return; 03184 } 03185 03186 // anything to do at all? 03187 if (!sn_Connections[i].socket) 03188 { 03189 return; 03190 }
void sn_DisconnectUserNoWarn | ( | int | i, | |
const tOutput & | reason, | |||
nServerInfoBase * | redirectTo = 0 | |||
) |
Definition at line 3192 of file nNetwork.cpp.
03196 { 03197 nCurrentSenderID senderID( i ); 03198 03199 nWaitForAck::AckAllPeer(i); 03200 03201 static bool reentry=false; 03202 if (reentry) 03203 return; 03204 reentry=true; 03205 03206 bool printMessage = false; // is it worth printing a message for this event? 03207 03208 if (sn_Connections[i].socket) 03209 { 03210 nMessage::SendCollected(i); 03211 printMessage = true; 03212 03213 // to make sure... 03214 if ( i!=0 && i != MAXCLIENTS+2 && sn_GetNetState() == nSERVER ){ 03215 for(int j=2;j>=0;j--){ 03216 nMessage* mess = (new nMessage(login_deny)); 03217 *mess << tString( reason ); 03218 03219 // write redirection 03220 tString redirection; 03221 int port; 03222 if ( redirectTo ) 03223 { 03224 redirection = redirectTo->GetConnectionName(); 03225 port = redirectTo->GetPort(); 03226 } 03227 *mess << redirection; 03228 *mess << port; 03229 03230 mess->SendImmediately(i, false); 03231 nMessage::SendCollected(i); 03232 } 03233 } 03234 } 03235 03236 nWaitForAck::AckAllPeer(i); 03237 03238 sn_Connections[i].ackMess=NULL; 03239 03240 if (i==0 && sn_GetNetState()==nCLIENT) 03241 sn_SetNetState(nSTANDALONE); 03242 03243 reset_last_acks(i); 03244 03245 // peers[i].sa_family=0; 03246 03247 sn_Connections[i].ackPending=0; 03248 // sn_ackAckPending[i]=0; 03249 03250 nCallbackLoginLogout::UserLoggedOut(i); 03251 03252 if ( printMessage ) 03253 { 03254 con << tOutput( "$network_killuser", i, sn_Connections[i].ping.GetPing() ); 03255 } 03256 03257 // clear address, socket and send queue 03258 sn_Connections[i].sendBuffer_.Clear(); 03259 sn_Connections[i].socket=NULL; 03260 peers[i] = nAddress(); 03261 sn_Connections[i].Clear(); 03262 while (send_queue[i].Len()) 03263 delete (send_queue[i](0)); 03264 03265 reentry=false;
static void sn_Erase | ( | nMachineMap & | map, | |
nMachineMap::iterator & | iter | |||
) | [static] |
static unsigned long int sn_ExpandMessageID | ( | unsigned short | id, | |
unsigned short | sender | |||
) | [static] |
expands a short message ID to a full int message ID, assuming it is from a message that was
Definition at line 914 of file nNetwork.cpp.
00917 { 00918 #ifdef DEBUG 00919 BreakOnMessageID( id ); 00920 #endif 00921 00922 static nMessageIDExpander expanders[MAXCLIENTS+2]; 00923 00924 tASSERT( sender <= MAXCLIENTS+2 )
void sn_GetAdr | ( | int | user, | |
tString & | name | |||
) |
Definition at line 3424 of file nNetwork.cpp.
Referenced by FinishHandlePasswordRequest(), GetSenderData(), nServerInfo::GiveSmallServerInfo(), and nServerInfoBase::NetReadThis().
int sn_GetCurrentProtocolVersion | ( | ) |
Definition at line 463 of file nConfig.cpp.
References sn_versionString.
00464 { 00465 return (sizeof(sn_versionString)/sizeof(char const *)) - 2; 00466 }
nConnectError sn_GetLastError | ( | ) |
Definition at line 457 of file nNetwork.cpp.
References nOK.
Referenced by ConnectToServerCore().
00460 { 00461 nConnectError ret = sn_Error; 00462 sn_Error = nOK;
static nMachineMap& sn_GetMachineMap | ( | ) | [static] |
Definition at line 4142 of file nNetwork.cpp.
Referenced by nMachinePersistor::SaveMachines().
tString const& sn_GetMyAddress | ( | ) |
return the public IP address and port of this machine, or "*.*.*.*:*" if it is unknown..
Definition at line 64 of file nNetwork.cpp.
nNetState sn_GetNetState | ( | ) |
Definition at line 2453 of file nNetwork.cpp.
Referenced by eVoteItem::AcceptNewVote(), gCycle::Act(), gNetPlayerWall::ActionOnQuit(), gCycle::ActionOnQuit(), Activate(), gCycleChatBot::Activate(), nConfItemVersionWatcher::AdaptVersion(), gCycleMovement::AddDestination(), eTeam::AddPlayer(), eTeam::AddScore(), gEnemyInfluence::AddSensor(), gEnemyInfluence::AddWall(), gGame::Analysis(), blocks(), gNetPlayerWall::BlowHole(), nMessage::BroadCast(), eVoteItem::BroadcastMessage(), gCycleMovement::CalculateAcceleration(), eVoteItem::CheckValid(), client(), ConnectToServerCore(), gCycleMovement::CopyFrom(), gNetPlayerWall::CopyIntoGrid(), ePlayerNetID::CreateNewTeam(), ePlayerNetID::CreateNewTeamWish(), ePlayerNetID::CreateVoter(), eLag::Credit(), gCycle::Die(), nNetObject::DoBroadcastExistence(), eVoteItemKick::DoCheckValid(), eVoteItemHarm::DoCheckValid(), eVoteItemHarmServerControlled::DoFillFromMessage(), eVoteItem::DoFillFromMessage(), eVoteItemHarmServerControlled::DoFillToMessage(), eVoteItem::DoFillToMessage(), gCycle::DoTurn(), ePlayerNetID::Enemies(), eNetGameObject::eNetGameObject(), eTeam::Enforce(), eMenuItemKick::Enter(), eTimer::eTimer(), eVoteItemServerControlled::Evaluate(), eVoteItem::Evaluate(), exit_game_objects(), eVoteItem::FillFromMessage(), eGameObject::FindCurrentFace(), first_fill_ids(), GameLoop(), gGame::GameLoop(), nServerInfo::GetBigServerInfoMaster(), eVoteItem::GetControlMessage(), nServerInfo::GetFromLAN(), nServerInfo::GetFromLANContinuously(), nServerInfo::GetFromMaster(), gGame::gGame(), gNetPlayerWall::gNetPlayerWall(), handle_chat_client(), nAuthentication::HandlePasswordRequest(), id_req_handler(), ingame_menu_cleanup(), nNOInitialisator< T >::Init(), init_game_camera(), init_game_objects(), eVoter::IsSpamming(), eTimer::IsSynced(), gCycle::Kill(), gCycle::KillAt(), eNetGameObject::LagThreshold(), ePlayer::LogIn(), login_accept_handler(), login_callback(), login_ignore_handler(), LoginLogout(), MainMenu(), gCamera::MyInit(), gCycle::MyInitAfterCreation(), ePlayerNetID::MyInitAfterCreation(), net_clear_handler(), net_control_handler(), net_sync_handler(), new_destination_handler(), next_free(), next_free_server_nokill(), nNetObject::nNetObject(), gGame::NoLongerGoOn(), ntest(), nWaitForAck::nWaitForAck(), nNetObject::Object(), gCycleMovement::OnNotifyNewDestination(), gCycle::OnNotifyNewDestination(), gCycle::OnRemoveFromGame(), nConfItemVersionWatcher::OnVersionChange(), gParser::parseSetting(), gParser::parseZoneArthemis_v1(), gCycle::PassEdge(), eTimer::pause(), eTeam::PlayerMayJoin(), nNetObject::ReadSync(), eTeam::ReadSync(), eVoteItem::ReBroadcast(), rec_peer(), eNetGameObject::ReceiveControl(), nNetObject::ReceiveControlNet(), nNetObject::Register(), nNetObject::RelabelOnConnect(), ePlayerNetID::RemoveChatbots(), eTeam::RemovePlayer(), gCycle::Render(), req_id_handler(), nNetObject::RequestSync(), gCycle::RequestSyncAll(), gCycle::RequestSyncOwner(), eTimer::Reset(), eTeam::ResetScore(), gAIPlayer::RightBeforeDeath(), nConfItemBase::s_GetConfigMessage(), nConfItemBase::s_SendConfig(), se_CancelAllVotes(), se_GetPing(), se_HandleNewServerVote(), se_NeedsServer(), se_OptionalNameFilters(), se_PauseGameTimer(), se_receiveLagMessage(), se_rubyEval(), se_WantLogin(), nMessage::Send(), ePlayer::SendAuthNames(), nConfItemBase::SendConfig(), eNetGameObject::SendControl(), nMessage::SendImmediately(), server(), ePlayerNetID::SetChatting(), zShape::setColor(), ePlayerNetID::SetDefaultTeam(), ePlayerNetID::SetName(), eNetGameObject::SetPlayer(), zShape::setRotation2(), eTeam::SetScore(), gGame::SetState(), ePlayerNetID::SetTeam(), ePlayerNetID::SetTeamWish(), sg_Deprecated(), sg_DropTempWall(), sg_KillFutureWalls(), sg_ParseMap(), sg_Receive(), sg_RespawnPlayer(), sg_TopologyPoliceKill(), sg_UseAntiLagSliding(), sn_Bend(), sn_ConsoleOut_handler(), sn_Sync(), eVoter::Spam(), StartNewMatch(), gGame::StateUpdate(), sync_msg_handler(), nNetObject::SyncAll(), gCycle::SyncEnemy(), gGame::SyncState(), eTimer::SyncTime(), nServerInfo::TellMasterAboutMe(), gAIPlayer::ThinkCloseCombat(), gBaseZoneHack::Timestep(), gCycleMovement::Timestep(), gCycle::Timestep(), eNetGameObject::Timestep(), gCycleMovement::TimestepCore(), gCycle::TimestepCore(), eGameObject::TimestepThis(), eGameObject::TimestepThisWrapper(), gNetPlayerWall::Update(), ePlayerNetID::Update(), update_settings(), eTeam::UpdateAppearance(), ePlayerNetID::UpdateName(), eTeam::UpdateProperties(), ePlayerNetID::UpdateTeam(), eVoter::VotingPossible(), nConfItemBase::Writable(), nNetObject::WriteSync(), eVoteItemServerControlled::~eVoteItemServerControlled(), and nNetObject::~nNetObject().
unsigned int sn_GetPort | ( | int | user | ) |
Definition at line 3429 of file nNetwork.cpp.
Referenced by GetSenderData(), and nServerInfo::GiveSmallServerInfo().
std::auto_ptr< nServerInfoBase > sn_GetRedirectTo | ( | ) |
Definition at line 1376 of file nNetwork.cpp.
Referenced by ConnectToServer().
unsigned int sn_GetServerPort | ( | ) |
Definition at line 3434 of file nNetwork.cpp.
Referenced by nServerInfoBase::DoGetFrom(), and nServerInfo::TellMasterAboutMe().
static REAL sn_GetTimeout | ( | int | user | ) | [static] |
Definition at line 161 of file nNetwork.cpp.
References nAverager::GetAverageVariance(), nPingAverager::GetPing(), nPingAverager::GetSnailAverager(), MAXCLIENTS, nConnectionInfo::ping, REAL, sn_Connections, sqrtf(), and tASSERT.
Referenced by nWaitForAck::nWaitForAck().
00163 { 00164 tASSERT( user >= 0 && user <= MAXCLIENTS+1 ); 00165 00166 nPingAverager & averager = sn_Connections[ user ].ping; 00167 00168 REAL timeout = pingTimeout * averager.GetPing() + pingVarianceTimeout * sqrtf( averager.GetSnailAverager().GetAverageVariance() ); 00169 00170 if ( timeout < minTimeout ) 00171 timeout = minTimeout; 00172 if ( timeout > maxTimeout ) 00173 timeout = maxTimeout; 00174 00175 return timeout;
bool sn_IsLANAddress | ( | tString const & | address | ) |
checks wheter a given address is on the user's LAN (or on loopback).
Definition at line 70 of file nNetwork.cpp.
Referenced by login_accept_handler().
00072 { 00073 if ( address.StartsWith("127.") || address.StartsWith("10.") || address.StartsWith("192.168.") ) 00074 { 00075 // easy LANs. Accept the client sent IP, we don't know our own LAN address. 00076 return true; 00077 } 00078 00079 if( address.StartsWith( "172." ) && address[6] == '.' ) 00080 { 00081 // more complicated LAN :) 00082 int second = address.SubStr(4,2).ToInt(); 00083 if ( 16 <= second && second < 32 ) 00084 { 00085 return true; 00086 } 00087 } 00088 00089 return false;
void sn_KickUser | ( | int | i, | |
const tOutput & | reason, | |||
REAL | severity, | |||
nServerInfoBase * | redirectTo | |||
) |
throw out user i (violently)
Definition at line 3152 of file nNetwork.cpp.
Referenced by nSpamProtection::CheckSpam(), ePlayerNetID::RemoveChatbots(), and se_VoteKickUser().
03156 { 03157 // print it 03158 con << tOutput( "$network_kill_log", i, reason ); 03159 03160 // log it 03161 if ( severity > 0 ) 03162 { 03163 nMachine::GetMachine(i).OnKick( severity ); 03164 } 03165
static void sn_ListBanConf | ( | std::istream & | s | ) | [static] |
Definition at line 4719 of file nNetwork.cpp.
04723 { 04724 nMachineMap & map = sn_GetMachineMap(); 04725 for( nMachineMap::iterator iter = map.begin(); iter != map.end(); ++iter ) 04726 { 04727 nMachine & machine = *(*iter).second.machine; 04728 REAL banned = machine.IsBanned(); 04729 if ( banned > 0 ) 04730 { 04731 con << tOutput( "$network_ban", machine.GetIP(), int(banned/60), machine.GetBanReason() );
static bool sn_Listen | ( | unsigned int & | net_hostport, | |
const tString & | net_hostip | |||
) | [static] |
Definition at line 2460 of file nNetwork.cpp.
References nBasicNetworkSystem::AccessListener(), con, tException::GetDescription(), tException::GetName(), nSocketListener::Listen(), reported, nSocketListener::SetIpList(), nSocketListener::SetPort(), and sn_BasicNetworkSystem.
02463 { 02464 unsigned int net_hostport_before = net_hostport; 02465 02466 try 02467 { 02468 nSocketListener & listener = sn_BasicNetworkSystem.AccessListener(); 02469 02470 listener.SetIpList( net_hostip ); 02471 02472 bool reported = false; 02473 02474 // try ports in a range 02475 while ( net_hostport < sn_serverPort + 100 ) 02476 { 02477 if ( listener.SetPort( net_hostport ).Listen( true ) ) 02478 return true; 02479 02480 if ( !reported ) 02481 { 02482 con << "sn_SetNetState: Unable to open accept socket on desired port " << net_hostport << ", Trying next ports...\n"; 02483 reported = true; 02484 } 02485 02486 net_hostport++; 02487 } 02488 02489 con << "sn_SetNetState: Giving up setting up listening sockets for IP list " << net_hostip << ".\n"; 02490 } 02491 catch( const tException & e ) 02492 { 02493 con << "sn_SetNetState: can't setup listening sockets. Reason given:\n" 02494 << e.GetName() << ": " << e.GetDescription() << "\n"; 02495 } 02496 02497 // reset host port 02498 net_hostport = net_hostport_before; 02499
static void sn_LoadMachines | ( | ) | [static] |
Definition at line 4148 of file nNetwork.cpp.
Referenced by sn_UnBanConf().
int sn_MaxUsers | ( | ) |
Definition at line 3463 of file nNetwork.cpp.
Referenced by nServerInfo::DoGetFrom().
int sn_MessagesPending | ( | int | user | ) |
Definition at line 3468 of file nNetwork.cpp.
Referenced by client(), and nServerInfo::RunMaster().
const nVersion& sn_MyVersion | ( | ) |
the version this progam maximally supports
Definition at line 235 of file nNetwork.cpp.
Referenced by nServerInfo::CalcScore(), nServerInfo::Compatibility(), and nConfItemVersionWatcher::OnVersionChange().
int sn_NumRealUsers | ( | ) |
Definition at line 3458 of file nNetwork.cpp.
Referenced by nServerInfo::DoGetFrom().
int sn_NumUsers | ( | ) |
int sn_NumUsers | ( | bool | all | ) |
Definition at line 3439 of file nNetwork.cpp.
Referenced by nServerLag::Balance(), GetFreeSlot(), and sg_NumUsers().
03443 { 03444 int ret = 0; 03445 for (int i=MAXCLIENTS; i>0; i--) 03446 if (sn_Connections[i].socket && ( all || ( sn_allowSameIPCountSoft > CountSameIP( i ) ) ) ) 03447 ret++; 03448 03449 #ifndef DEDICATED 03450 ret++; 03451 #endif
nServerInfoBase* sn_PeekRedirectTo | ( | ) |
Definition at line 1381 of file nNetwork.cpp.
Referenced by sg_NetworkError().
int sn_QueueLen | ( | int | user | ) |
Definition at line 3268 of file nNetwork.cpp.
Referenced by sn_Sync().
void sn_Receive | ( | ) |
Definition at line 3092 of file nNetwork.cpp.
Referenced by client(), nServerInfo::DoQueryAll(), nServerInfo::GetFromLAN(), nServerInfo::GetFromMaster(), main(), next_free(), ntest(), nNetObject::Object(), gBrowserMenuItem::RenderBackground(), nServerInfo::RunMaster(), server(), sg_Receive(), sn_Sync(), and nServerInfo::TellMasterAboutMe().
03095 { 03096 /* 03097 static bool reentry=false; 03098 if (reentry) 03099 return; 03100 reentry=true; 03101 */ 03102 03103 netTime=tSysTimeFloat(); 03104 // new_id=0; 03105 sn_Connections[MAXCLIENTS+1].ping.Reset(); 03106 03107 // create the ack messages (not required, is done on demand later) 03108 /* 03109 int i; 03110 for(i=0;i<=MAXCLIENTS+1;i++) 03111 if(sn_Connections[i].ackMess==NULL) 03112 sn_Connections[i].ackMess=new nAckMessage(); 03113 */ 03114 03115 03116 switch (current_state){ 03117 case nSERVER: 03118 { 03119 memset( &peers[0], 0, sizeof(sockaddr) ); 03120 03121 // listen on all sockets 03122 nSocketListener const & listener = sn_BasicNetworkSystem.GetListener(); 03123 for ( nSocketListener::iterator i = listener.begin(); i != listener.end(); ++i ) 03124 { 03125 // clear peer info used for receiving 03126 memset( &peers[MAXCLIENTS+1], 0, sizeof(sockaddr) ); 03127 03128 if((sn_Connections[MAXCLIENTS+1].socket = (*i).CheckNewConnection() ) != NULL) 03129 rec_peer(MAXCLIENTS+1); 03130 } 03131 } 03132 // z-man: after much thought, the server does also need to listen to the 03133 // network control socket. .... Thinking again, it's only important for the master 03134 // servers, and they call rec_peer(0) separately. 03135 break; 03136 03137 case nCLIENT: 03138 rec_peer(0); 03139 break; 03140 03141 case nSTANDALONE: 03142 default: 03143 break; 03144 } 03145 03146 /* 03147 // scedule regular messages 03148 REAL dt = sn_SendPlanned1(); 03149 03150 // actually resend messages
void sn_ReceiveFromControlSocket | ( | ) |
Definition at line 2434 of file nNetwork.cpp.
References rec_peer().
Referenced by main().
static void sn_SaveMachines | ( | ) | [static] |
void sn_SendPlanned | ( | ) |
Definition at line 3070 of file nNetwork.cpp.
Referenced by client(), ConnectToServerCore(), nServerInfo::DoQueryAll(), gGame::GameLoop(), nServerInfo::GetFromLAN(), nServerInfo::GetFromMaster(), main(), gGame::NetSync(), next_free(), ntest(), nNetObject::Object(), gBrowserMenuItem::RenderBackground(), nServerInfo::RunMaster(), server(), sn_Sync(), and nServerInfo::TellMasterAboutMe().
03074 { 03075 // propagate messages to buffers 03076 REAL dt = sn_SendPlanned1(); 03077 03078 // schedule the acks: send them if it's possible (bandwith limit) or if there already is a packet in the pipe. 03079 for(int i=0;i<=MAXCLIENTS+1;i++) 03080 if(sn_Connections[i].socket && sn_Connections[i].ackMess && !sn_Connections[i].ackMess->End() 03081 // && sn_ackAckPending[i] <= 1+sn_Connections[].ackMess[i]->DataLen() 03082 && ( sn_Connections[i].bandwidthControl_.CanSend() || sn_Connections[i].sendBuffer_.Len() > 0 ) 03083 ){ 03084 sn_Connections[i].ackMess->SendImmediately(i, false); 03085 sn_Connections[i].ackMess=NULL; 03086 } 03087 03088 // schedule lost messages for resending 03089 nWaitForAck::Resend(); 03090
static REAL sn_SendPlanned1 | ( | ) | [static] |
Definition at line 3009 of file nNetwork.cpp.
References nConnectionInfo::ackPending, nConnectionInfo::bandwidthControl_, nBandwidthControl::CanSend(), dt, nMessage_planned_send::execute(), lastTime, tHeap< T >::Len(), REAL, nConnectionInfo::socket, tERR_ERROR, tERR_WARN, and tSysTimeFloat().
03012 { 03013 sn_OrderPriority = 0; 03014 03015 // if possible, send waiting messages 03016 static double lastTime=-1; 03017 nTimeAbsolute time=tSysTimeFloat(); 03018 if (lastTime<0) 03019 lastTime=time; 03020 03021 if (time<lastTime-.01 || time>lastTime+1000) 03022 #ifdef DEBUG 03023 { 03024 tERR_ERROR("Timer hickup!"); 03025 } 03026 #else 03027 { 03028 tERR_WARN("Timer hickup!"); 03029 lastTime=time; 03030 } 03031 #endif 03032 REAL dt = time - lastTime; 03033 03034 //for(int i=MAXCLIENTS+1;i>=0;i--){ 03035 for(int i=0;i<=MAXCLIENTS+1;i++){ 03036 nConnectionInfo & connection = sn_Connections[i]; 03037 if ( !connection.socket ) 03038 continue; 03039 03040 while (connection.ackPending<sn_maxNoAck && 03041 connection.bandwidthControl_.CanSend() && 03042 send_queue[i].Len()) 03043 { 03044 send_queue[i](0)->execute(); 03045 if (send_queue[i].Len()) 03046 delete send_queue[i](0); 03047 } 03048 03049 // make everything a little more urgent: 03050 for(int j=send_queue[i].Len()-1;j>=0;j--) 03051 send_queue[i](j)->add_to_priority(-dt); 03052 } 03053 lastTime=time;
static void sn_SendPlanned2 | ( | REAL | dt | ) | [static] |
Definition at line 3055 of file nNetwork.cpp.
03058 { 03059 // empty the send buffers 03060 for(int i=0;i<=MAXCLIENTS+1;i++){ 03061 nConnectionInfo & connection = sn_Connections[i]; 03062 if ( connection.socket ) 03063 { 03064 if (connection.sendBuffer_.Len()>0 && connection.bandwidthControl_.CanSend() ) 03065 nMessage::SendCollected(i); 03066 03067 // update bandwidth usage and other time related data 03068 connection.Timestep( dt );
void sn_SetNetState | ( | nNetState | x | ) |
Definition at line 2529 of file nNetwork.cpp.
Referenced by client(), ConnectToServerCore(), nServerInfo::GetFromLAN(), nServerInfo::GetFromLANContinuously(), nServerInfo::GetFromLANContinuouslyStop(), nServerInfo::GetFromMaster(), main(), ntest(), Poll(), ret_to_MainMenu(), server(), sg_HostGame(), singlePlayer_game(), sn_Bend(), and nServerInfo::TellMasterAboutMe().
02531 { 02532 static bool reentry=false; 02533 if(!reentry && x!=current_state){ 02534 sn_UpdateCurrentVersion(); 02535 02536 //if (x == nSERVER) 02537 unsigned int net_hostport = sn_serverPort; 02538 02539 // save/load machines on entering/leaving server mode 02540 if ( x == nSERVER ) 02541 sn_LoadMachines(); 02542 else if ( current_state == nSERVER ) 02543 if ( !tRecorder::IsPlayingBack() ) 02544 sn_SaveMachines(); 02545 02546 reentry=true; 02547 if (x!=nSTANDALONE) 02548 { 02549 if (x==nCLIENT) 02550 { 02551 sn_DisconnectAll(); 02552 } 02553 else 02554 { 02555 sn_myNetID=0; 02556 } 02557 02558 if (!sn_Connections[0].socket) 02559 sn_Connections[0].socket=sn_BasicNetworkSystem.Init(); 02560 // bool success = true; 02561 if (x == nSERVER) 02562 { 02563 // bool success = 02564 sn_Listen( net_hostport, net_hostip ) || // first try: do it according to user specs 02565 sn_Listen( net_hostport, tString( "ANY" ) ) || // second try: bind to generic IP 02566 sn_Listen( net_hostport, tString( "ALL" ) ); // last try: bind to all available IPs 02567 02568 #ifdef DEDICATED 02569 // save host port that worked, otherwise it may change from the port sent to the master server 02570 sn_serverPort = net_hostport; 02571 #endif 02572 } 02573 } 02574 else 02575 { 02576 clear_owners(); 02577 for(int i=MAXCLIENTS+1;i>=0;i--){ 02578 if(sn_Connections[i].socket){ 02579 if (i==0 && current_state!=nSERVER) 02580 { // logout: fire and forget 02581 con << tOutput("$network_logout_process"); 02582 for(int j=3;j>=0;j--){ // just to make sure 02583 nMessage *lo=new nMessage(logout); 02584 lo->Write(static_cast<unsigned short>(sn_myNetID)); 02585 lo->ClearMessageID(); 02586 lo->SendImmediately(0, false); 02587 nMessage::SendCollected(0); 02588 tDelay(1000); 02589 } 02590 con << tOutput("$network_logout_done"); 02591 02592 sn_myNetID=0; // MAXCLIENTS+1; // reset network id 02593 } 02594 } 02595 sn_DisconnectUserNoWarn(i, "$network_kill_shutdown"); 02596 } 02597 02598 sn_Connections[0].socket = 0; 02599 02600 // shutdown network system to get new socket 02601 if ( !sn_noReset ) 02602 sn_BasicNetworkSystem.Shutdown(); 02603 } 02604 02605 current_state=x; 02606 reentry=false; 02607 } 02608
void sn_Statistics | ( | ) |
Definition at line 3340 of file nNetwork.cpp.
References con, dt, REAL, tOutput::SetTemplateParameter(), and tSysTimeFloat().
Referenced by gGame::StateUpdate().
03344 { 03345 nTimeRolling time = tSysTimeFloat(); 03346 REAL dt = time - sn_StatsTime; 03347 sn_StatsTime = time; 03348 03349 if (dt > 0 && (sn_SentPackets || sn_SentBytes)) 03350 { 03351 tOutput o; 03352 o.SetTemplateParameter(1,dt); 03353 o.SetTemplateParameter(2,sn_SentBytes); 03354 o.SetTemplateParameter(3,sn_SentPackets); 03355 o.SetTemplateParameter(4,sn_SentBytes/dt); 03356 o.SetTemplateParameter(5,sn_ReceivedBytes); 03357 o.SetTemplateParameter(6,sn_ReceivedPackets); 03358 o.SetTemplateParameter(7,sn_ReceivedBytes/dt); 03359 o << "$network_statistics1"; 03360 o << "$network_statistics2"; 03361 o << "$network_statistics3"; 03362 03363 con << o; 03364 } 03365 03366 sn_SentPackets = 0; 03367 sn_SentBytes = 0;
static void sn_UnBanConf | ( | std::istream & | s | ) | [static] |
Definition at line 4660 of file nNetwork.cpp.
References nMachine::Ban(), con, and sn_LookupMachine().
04664 { 04665 if ( !s.good() || s.eof() ) 04666 { 04667 con << "Usage: UNBAN_IP <ip>\n"; 04668 return; 04669 } 04670 04671 // read IP to unban 04672 tString address; 04673 s >> address; 04674 04675 if ( address.Len() < 8 ) 04676 { 04677 con << "Usage: UNBAN_IP <ip>, no or too short ip given.\n"; 04678 } 04679 // and unban 04680 else 04681 {
void sn_UpdateCurrentVersion | ( | ) |
updates the sn_CurrentVersion()
Definition at line 393 of file nNetwork.cpp.
Referenced by nConfItemVersionWatcher::OnChange().
00396 { 00397 // update the current version from the native version and the versions of all attached clients 00398 00399 // allow maximally sn_MaxBackwardsCompatibility old versions to connect 00400 int min = sn_myVersion.Max() - sn_MaxBackwardsCompatibility; 00401 if ( min < sn_myVersion.Min() ) 00402 min = sn_myVersion.Min(); 00403 00404 // disable features that are too new 00405 int max = sn_myVersion.Max() - sn_newFeatureDelay; 00406 if ( max < min ) 00407 max = min; 00408 00409 nVersion version( min, max ); 00410 00411 // ask configuration if version is OK 00412 nConfItemVersionWatcher::AdaptVersion( version ); 00413 00414 nVersion maxVersion = version; 00415 00416 if ( sn_GetNetState() == nCLIENT ) 00417 { 00418 sn_currentVersion = version; 00419 return; 00420 } 00421 00422 for ( int i = MAXCLIENTS; i>0; --i ) 00423 { 00424 const nConnectionInfo& info = sn_Connections[i]; 00425 if ( info.socket ) 00426 { 00427 if ( ! version.Merge( version, info.version ) ) 00428 { 00429 // kick user; it has gotten incompatible. 00430 static bool recurse = true; 00431 if ( recurse ) 00432 { 00433 recurse = false; 00434 sn_DisconnectUser( i, "$network_kill_incompatible" ); 00435 recurse = true; 00436 } 00437 00438 version = maxVersion; 00439 } 00440 } 00441 } 00442 00443 // inform configuration of changes 00444 nConfItemVersionWatcher::OnVersionChange( version ); 00445 00446 if ( version != sn_currentVersion ) 00447 { 00448 sn_currentVersion = version; 00449 00450 nMessage* m = tNEW( nMessage )( versionControl ); 00451 (*m) << version; 00452 00453 m->BroadCast();
bool big_brother = true |
Definition at line 120 of file nNetwork.cpp.
tConfItemFunc CenterMessage_c("CENTER_MESSAGE",&CeterMessage_conf) [static] |
nDescriptor client_cen_nd(9, client_cen_handler,"client_cen") [static] |
tConfItemFunc ConsoleOut_c("CONSOLE_MESSAGE",&ConsoleOut_conf) [static] |
Referenced by operator<<(), tMemManBase::Profile(), and tMemManager::tMemManager().
unsigned short current_id = 1 |
Definition at line 495 of file nNetwork.cpp.
nNetState current_state [static] |
Definition at line 200 of file nNetwork.cpp.
bool deb_net = false |
Definition at line 153 of file nNetwork.cpp.
nDescriptor* descriptors[MAXDESCRIPTORS] [static] |
Definition at line 531 of file nNetwork.cpp.
unsigned short highest_ack[MAXCLIENTS+2] [static] |
Definition at line 214 of file nNetwork.cpp.
const int kickOnDemandTimeout = 10 [static] |
Definition at line 182 of file nNetwork.cpp.
REAL killTimeout = 30 [static] |
Definition at line 178 of file nNetwork.cpp.
unsigned short lastackPos[MAXCLIENTS+2] [static] |
Definition at line 213 of file nNetwork.cpp.
unsigned short lastacks[MAXCLIENTS+2][ACKBACK] [static] |
Definition at line 212 of file nNetwork.cpp.
nDescriptor login(6, login_handler_1,"login1", true) |
Referenced by PasswordCallback(), and rec_peer().
nDescriptor login_2(11, login_handler_2,"login2", true) |
nDescriptor login_accept(5, login_accept_handler,"login_accept", true) [static] |
Referenced by rec_peer().
nDescriptor login_deny(3, login_deny_handler,"login_deny") [static] |
Referenced by rec_peer().
bool login_failed = false [static] |
Definition at line 1351 of file nNetwork.cpp.
nDescriptor login_ignore(4, login_ignore_handler,"login_ignore") [static] |
Referenced by rec_peer().
bool login_succeeded = false [static] |
Definition at line 1352 of file nNetwork.cpp.
nKrawall::nSalt loginSalt [static] |
Definition at line 1357 of file nNetwork.cpp.
nDescriptor logout(7, logout_handler,"logout") |
REAL maxTimeout = 1 [static] |
Definition at line 155 of file nNetwork.cpp.
REAL minTimeout = .01 [static] |
Definition at line 156 of file nNetwork.cpp.
nDescriptor* nDescriptor_anchor [static] |
Definition at line 533 of file nNetwork.cpp.
nCallbackAcceptPackedWithoutConnection net_acc & net_Accept [static] |
Definition at line 3325 of file nNetwork.cpp.
tString net_hostip("ANY") |
nTimeRolling netTime [static] |
Definition at line 208 of file nNetwork.cpp.
REAL pingTimeout = 1 [static] |
Definition at line 157 of file nNetwork.cpp.
REAL pingVarianceTimeout = 1 [static] |
Definition at line 158 of file nNetwork.cpp.
nHandler* real_req_info_handler = NULL [static] |
Definition at line 1359 of file nNetwork.cpp.
nDescriptor req_info(2, req_info_handler,"req_info") [static] |
tCallbackOr* s_AcceptAnchor = NULL [static] |
Definition at line 3293 of file nNetwork.cpp.
nDescriptor s_Acknowledge(1, ack_handler,"ack") [static] |
Referenced by nAckMessage::nAckMessage(), nWaitForAck::nWaitForAck(), nMessage::Send(), and nMessage::SendImmediately().
tCallback* s_loginoutAnchor = NULL [static] |
Definition at line 3273 of file nNetwork.cpp.
tCallback* s_ReceivedCompleteAnchor = NULL [static] |
Definition at line 3306 of file nNetwork.cpp.
bool send_again_warn = false [static] |
Definition at line 184 of file nNetwork.cpp.
tHeap<planned_send> send_queue[MAXCLIENTS+2] |
Definition at line 2959 of file nNetwork.cpp.
REAL sent_per_messid[MAXDESCRIPTORS+100] |
Definition at line 2130 of file nNetwork.cpp.
Definition at line 67 of file nServerInfo.cpp.
Referenced by nServerInfo::GetFromMaster(), and nServerInfoBase::NetReadThis().
int sn_allowSameIPCountHard = 8 |
Definition at line 484 of file nNetwork.cpp.
tSettingItem< int > sn_allowSameIPCountHardConf("MAX_CLIENTS_SAME_IP_HARD", sn_allowSameIPCountHard) [static] |
int sn_allowSameIPCountSoft = 4 |
Definition at line 481 of file nNetwork.cpp.
tSettingItem< int > sn_allowSameIPCountSoftConf("MAX_CLIENTS_SAME_IP_SOFT", sn_allowSameIPCountSoft) [static] |
REAL sn_autobanFactor = 10 [static] |
Definition at line 4300 of file nNetwork.cpp.
tSettingItem< REAL > sn_autobanFactorSetting("NETWORK_AUTOBAN_FACTOR", sn_autobanFactor) [static] |
REAL sn_autobanMaxKPH = 30 [static] |
Definition at line 4301 of file nNetwork.cpp.
tSettingItem< REAL > sn_autobanMaxKPHSetting("NETWORK_AUTOBAN_MAX_KPH", sn_autobanMaxKPH) [static] |
REAL sn_autobanOffset = 5 [static] |
Definition at line 4299 of file nNetwork.cpp.
tSettingItem< REAL > sn_autobanOffsetSetting("NETWORK_AUTOBAN_OFFSET", sn_autobanOffset) [static] |
const int sn_backwardCompatibleProtocolVersion = 0 [static] |
Definition at line 231 of file nNetwork.cpp.
tConfItemFunc sn_banConf("BAN_IP",&sn_BanConf) [static] |
Definition at line 3473 of file nNetwork.cpp.
Referenced by main(), sg_HostGame(), sn_Listen(), nServerInfo::TellMasterAboutMe(), update_settings(), and gNetIdler::Wait().
tAccessLevelSetter sn_CenterConfLevel(CenterMessage_c, tAccessLevel_Moderator) [static] |
nConnectionInfo sn_Connections[MAXCLIENTS+2] |
Definition at line 206 of file nNetwork.cpp.
Referenced by eVoteItem::AcceptNewVote(), nServerLag::Balance(), Cheater(), nNetObject::ClearAllDeleted(), gNetPlayerWall::CopyIntoGrid(), ePlayerNetID::CreateVoter(), nNetObject::DoBroadcastExistence(), ePlayerNetID::ePlayerNetID(), GameLoop(), nServerInfo::GetBigServerInfoCommon(), nServerInfo::GiveBigServerInfo(), nServerInfo::GiveSmallServerInfo(), next_free(), nNetObject::Object(), nServerLag::Ping(), eTimer::ReadSync(), ready_handler(), gNetPlayerWall::RealWallReceived(), eVoteItem::ReBroadcast(), nServerInfo::RunMaster(), se_BroadcastChat(), se_BroadcastChatLine(), se_GetPing(), se_ReadUser(), se_sendEventNotification(), sg_FullscreenMessage(), sn_GetTimeout(), sn_Sync(), gGame::StateUpdate(), nNetObject::SyncAll(), gGame::SyncState(), nServerInfo::TellMasterAboutMe(), gCycleMovement::TimestepCore(), and gCycle::TimestepCore().
tAccessLevelSetter sn_ConsoleConfLevel(ConsoleOut_c, tAccessLevel_Moderator) [static] |
nDescriptor sn_ConsoleOut_nd(8, sn_ConsoleOut_handler,"sn_ConsoleOut") [static] |
const int sn_currentProtocolVersion = sn_GetCurrentProtocolVersion() [static] |
Definition at line 230 of file nNetwork.cpp.
nVersion sn_currentVersion(sn_myVersion) [static] |
int sn_defaultDelay = 10000 |
const unsigned int sn_defaultPort = 4534 |
Definition at line 115 of file nNetwork.cpp.
Definition at line 1433 of file nNetwork.cpp.
Referenced by ConnectToServerCore(), and sg_NetworkError().
nConnectError sn_Error = nOK [static] |
Definition at line 143 of file nNetwork.cpp.
bool sn_filterColorStrings = false |
Definition at line 1049 of file nNetwork.cpp.
tConfItemFunc sn_listBanConf("BAN_LIST",&sn_ListBanConf) [static] |
tSettingItem< bool > sn_lockOut028TestConf("NETWORK_LOCK_OUT_028_TEST", sn_lockOut028tTest) [static] |
bool sn_lockOut028tTest = true [static] |
Definition at line 1626 of file nNetwork.cpp.
char const* sn_machinesFileName = "bans.txt" [static] |
Definition at line 4457 of file nNetwork.cpp.
int sn_MaxBackwardsCompatibility = 1000 [static] |
Definition at line 221 of file nNetwork.cpp.
int sn_maxClients = MAXCLIENTS |
Definition at line 477 of file nNetwork.cpp.
tSettingItem< int > sn_maxClientsConf("MAX_CLIENTS", sn_maxClients) [static] |
int sn_maxNoAck = 100 |
int sn_maxRateIn = 8 |
int sn_maxRateOut = 8 |
Definition at line 1619 of file nNetwork.cpp.
tSettingItem< REAL > sn_minBanSetting("NETWORK_MIN_BAN", sn_minBan) [static] |
tSettingItem<int> sn_mxc("BACKWARD_COMPATIBILITY", sn_MaxBackwardsCompatibility) [static] |
tString sn_myAddress("*.*.*.*:*") [static] |
Referenced by login_accept_handler().
int sn_myNetID = 0 |
Definition at line 491 of file nNetwork.cpp.
Referenced by nNetObject::ClearKnows(), nNetObject::DoBroadcastExistence(), gCycle::DoTurn(), gCycle::EdgeIsDangerous(), new_destination_handler(), nNetObject::nNetObject(), gCycleMovement::OnNotifyNewDestination(), gCycle::OnNotifyNewDestination(), nNetObject::Owner(), gCycle::ReadSync(), gNetPlayerWall::RealWallReceived(), nNetObject::RelabelOnConnect(), nNetObject::RequestSync(), se_ChatState(), se_GetLocalPlayer(), se_GetPing(), eNetGameObject::SendControl(), ePlayerNetID::SetTeamWish(), nNetObject::SyncAll(), gCycle::SyncEnemy(), eNetGameObject::SyncIsNew(), gCycle::Timestep(), eNetGameObject::Timestep(), ePlayerNetID::Update(), and nNetObject::~nNetObject().
const nVersion sn_myVersion(sn_backwardCompatibleProtocolVersion, sn_currentProtocolVersion) [static] |
int sn_newFeatureDelay = 0 [static] |
Definition at line 224 of file nNetwork.cpp.
tSettingItem<int> sn_nfd("NEW_FEATURE_DELAY", sn_newFeatureDelay) [static] |
bool sn_noReset = false [static] |
Definition at line 2519 of file nNetwork.cpp.
REAL sn_OrderPriority = 0 [static] |
Definition at line 1882 of file nNetwork.cpp.
tList<nWaitForAck> sn_pendingAcks [static] |
Definition at line 640 of file nNetwork.cpp.
bool sn_printBans = true [static] |
Definition at line 4339 of file nNetwork.cpp.
tString sn_programVersion(TRUE_ARMAGETRONAD_VERSION) |
Referenced by nServerInfo::DoGetFrom(), main(), and MainMenu().
int sn_ReceivedBytes = 0 |
Definition at line 1887 of file nNetwork.cpp.
int sn_ReceivedPackets = 0 |
Definition at line 1888 of file nNetwork.cpp.
std::auto_ptr< nServerInfoBase > sn_redirectTo [static] |
Definition at line 1375 of file nNetwork.cpp.
tConfItemLine sn_sbtip("SERVER_IP", net_hostip) [static] |
int sn_SentBytes = 0 |
Definition at line 1885 of file nNetwork.cpp.
int sn_SentPackets = 0 |
Definition at line 1886 of file nNetwork.cpp.
tString sn_serverName("Unnamed Server") |
Referenced by nServerInfo::DoGetFrom(), and sg_HostGameMenu().
unsigned int sn_serverPort = 4534 |
tConfItemLine sn_sn("SERVER_NAME", sn_serverName) [static] |
REAL sn_spectatorTime = 0 [static] |
Definition at line 4265 of file nNetwork.cpp.
tSettingItem< REAL > sn_spectatorTimeConf("NETWORK_SPECTATOR_TIME", sn_spectatorTime) [static] |
tConfItem<int> sn_sport("SERVER_PORT", reinterpret_cast< int & >(sn_serverPort)) [static] |
Definition at line 1889 of file nNetwork.cpp.
tConfItemFunc sn_unBanConf("UNBAN_IP",&sn_UnBanConf) [static] |
nVersionFeature sn_ZeroMessageCrashfix(1) [static] |
int timeouts[MAXCLIENTS+2] [static] |
Definition at line 209 of file nNetwork.cpp.
nDescriptor versionControl(10, handle_version_control,"version") |
REAL zeroTimeout = .01 [static] |
Definition at line 159 of file nNetwork.cpp.