diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/network/network.cpp | 7 | ||||
-rw-r--r-- | src/network/network_admin.cpp | 2 | ||||
-rw-r--r-- | src/network/network_base.h | 1 | ||||
-rw-r--r-- | src/network/network_server.cpp | 12 | ||||
-rw-r--r-- | src/network/network_server.h | 1 |
5 files changed, 9 insertions, 14 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp index 81988e83b..317b2d59f 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -484,7 +484,7 @@ void ParseConnectionString(const char **company, const char **port, char *connec SetWindowDirty(WC_CLIENT_LIST, 0); 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()); NetworkClientInfo *ci = new NetworkClientInfo(CLIENT_ID_SERVER); 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)); } diff --git a/src/network/network_admin.cpp b/src/network/network_admin.cpp index 9fa244f21..a5726093c 100644 --- a/src/network/network_admin.cpp +++ b/src/network/network_admin.cpp @@ -212,7 +212,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientInfo(const NetworkC const NetworkClientInfo *ci = cs->GetInfo(); 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_uint8 (ci->client_lang); p->Send_uint32(ci->join_date); diff --git a/src/network/network_base.h b/src/network/network_base.h index 4540ca962..427065fa8 100644 --- a/src/network/network_base.h +++ b/src/network/network_base.h @@ -27,7 +27,6 @@ struct NetworkClientInfo : NetworkClientInfoPool::PoolItem<&_networkclientinfo_p char client_name[NETWORK_CLIENT_NAME_LENGTH]; ///< Name of the client byte client_lang; ///< The language of the client 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 NetworkClientInfo(ClientID client_id = INVALID_CLIENT_ID) : client_id(client_id) {} diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index f8f966e76..cc3fd09d0 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -1813,7 +1813,7 @@ void NetworkServerDailyLoop() */ const char *ServerNetworkGameSocketHandler::GetClientIP() { - return this->GetInfo()->client_address.GetHostname(); + return this->client_address.GetHostname(); } void NetworkServerShowStatusToConsole() @@ -1936,11 +1936,11 @@ uint NetworkServerKickOrBanIP(const char *ip, bool ban) uint n = 0; /* There can be multiple clients with the same IP, kick them all */ - NetworkClientInfo *ci; - FOR_ALL_CLIENT_INFOS(ci) { - if (ci->client_id == CLIENT_ID_SERVER) continue; - if (ci->client_address.IsInNetmask(const_cast<char *>(ip))) { - NetworkServerKickClient(ci->client_id); + NetworkClientSocket *cs; + FOR_ALL_CLIENT_SOCKETS(cs) { + if (cs->client_id == CLIENT_ID_SERVER) continue; + if (cs->client_address.IsInNetmask(const_cast<char *>(ip))) { + NetworkServerKickClient(cs->client_id); n++; } } diff --git a/src/network/network_server.h b/src/network/network_server.h index 599ee3abf..8fb19b53c 100644 --- a/src/network/network_server.h +++ b/src/network/network_server.h @@ -76,6 +76,7 @@ public: Packet *savegame_packets; ///< Packet queue of the savegame; send these "slowly" to the client. struct PacketWriter *savegame; ///< Writer used to write the savegame. 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(); |