1
0
Fork 0

(svn r22368) -Codechange: move the IP address field from the ClientInfo to ClientSocket

release/1.2
rubidium 2011-04-22 16:03:48 +00:00
parent 146d532d51
commit 2cae0cd54c
5 changed files with 9 additions and 14 deletions

View File

@ -484,7 +484,7 @@ void ParseConnectionString(const char **company, const char **port, char *connec
SetWindowDirty(WC_CLIENT_LIST, 0); SetWindowDirty(WC_CLIENT_LIST, 0);
ServerNetworkGameSocketHandler *cs = new ServerNetworkGameSocketHandler(s); ServerNetworkGameSocketHandler *cs = new ServerNetworkGameSocketHandler(s);
cs->GetInfo()->client_address = address; // Save the IP of the client cs->client_address = address; // Save the IP of the client
} }
/** /**
@ -684,11 +684,6 @@ static void NetworkInitGameInfo()
assert(NetworkClientInfo::CanAllocateItem()); assert(NetworkClientInfo::CanAllocateItem());
NetworkClientInfo *ci = new NetworkClientInfo(CLIENT_ID_SERVER); NetworkClientInfo *ci = new NetworkClientInfo(CLIENT_ID_SERVER);
ci->client_playas = _network_dedicated ? COMPANY_SPECTATOR : _local_company; ci->client_playas = _network_dedicated ? COMPANY_SPECTATOR : _local_company;
/* Give the server a valid IP; banning it is pointless anyways */
sockaddr_in sock;
memset(&sock, 0, sizeof(sock));
sock.sin_family = AF_INET;
ci->client_address = NetworkAddress((sockaddr*)&sock, sizeof(sock));
strecpy(ci->client_name, _settings_client.network.client_name, lastof(ci->client_name)); strecpy(ci->client_name, _settings_client.network.client_name, lastof(ci->client_name));
} }

View File

@ -212,7 +212,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientInfo(const NetworkC
const NetworkClientInfo *ci = cs->GetInfo(); const NetworkClientInfo *ci = cs->GetInfo();
p->Send_uint32(ci->client_id); p->Send_uint32(ci->client_id);
p->Send_string(const_cast<NetworkAddress &>(ci->client_address).GetHostname()); p->Send_string(const_cast<NetworkAddress &>(cs->client_address).GetHostname());
p->Send_string(ci->client_name); p->Send_string(ci->client_name);
p->Send_uint8 (ci->client_lang); p->Send_uint8 (ci->client_lang);
p->Send_uint32(ci->join_date); p->Send_uint32(ci->join_date);

View File

@ -27,7 +27,6 @@ struct NetworkClientInfo : NetworkClientInfoPool::PoolItem<&_networkclientinfo_p
char client_name[NETWORK_CLIENT_NAME_LENGTH]; ///< Name of the client char client_name[NETWORK_CLIENT_NAME_LENGTH]; ///< Name of the client
byte client_lang; ///< The language of the client byte client_lang; ///< The language of the client
CompanyID client_playas; ///< As which company is this client playing (CompanyID) CompanyID client_playas; ///< As which company is this client playing (CompanyID)
NetworkAddress client_address; ///< IP-address of the client (so he can be banned)
Date join_date; ///< Gamedate the client has joined Date join_date; ///< Gamedate the client has joined
NetworkClientInfo(ClientID client_id = INVALID_CLIENT_ID) : client_id(client_id) {} NetworkClientInfo(ClientID client_id = INVALID_CLIENT_ID) : client_id(client_id) {}

View File

@ -1813,7 +1813,7 @@ void NetworkServerDailyLoop()
*/ */
const char *ServerNetworkGameSocketHandler::GetClientIP() const char *ServerNetworkGameSocketHandler::GetClientIP()
{ {
return this->GetInfo()->client_address.GetHostname(); return this->client_address.GetHostname();
} }
void NetworkServerShowStatusToConsole() void NetworkServerShowStatusToConsole()
@ -1936,11 +1936,11 @@ uint NetworkServerKickOrBanIP(const char *ip, bool ban)
uint n = 0; uint n = 0;
/* There can be multiple clients with the same IP, kick them all */ /* There can be multiple clients with the same IP, kick them all */
NetworkClientInfo *ci; NetworkClientSocket *cs;
FOR_ALL_CLIENT_INFOS(ci) { FOR_ALL_CLIENT_SOCKETS(cs) {
if (ci->client_id == CLIENT_ID_SERVER) continue; if (cs->client_id == CLIENT_ID_SERVER) continue;
if (ci->client_address.IsInNetmask(const_cast<char *>(ip))) { if (cs->client_address.IsInNetmask(const_cast<char *>(ip))) {
NetworkServerKickClient(ci->client_id); NetworkServerKickClient(cs->client_id);
n++; n++;
} }
} }

View File

@ -76,6 +76,7 @@ public:
Packet *savegame_packets; ///< Packet queue of the savegame; send these "slowly" to the client. Packet *savegame_packets; ///< Packet queue of the savegame; send these "slowly" to the client.
struct PacketWriter *savegame; ///< Writer used to write the savegame. struct PacketWriter *savegame; ///< Writer used to write the savegame.
ThreadMutex *savegame_mutex; ///< Mutex for making threaded saving safe. ThreadMutex *savegame_mutex; ///< Mutex for making threaded saving safe.
NetworkAddress client_address; ///< IP-address of the client (so he can be banned)
ServerNetworkGameSocketHandler(SOCKET s); ServerNetworkGameSocketHandler(SOCKET s);
~ServerNetworkGameSocketHandler(); ~ServerNetworkGameSocketHandler();