1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-23 14:39:08 +00:00

(svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work

This commit is contained in:
smatz
2010-05-13 16:00:50 +00:00
parent 241dd9a9f5
commit 80fd67a314
4 changed files with 64 additions and 84 deletions

View File

@@ -79,7 +79,7 @@ void NetworkServerSendError(ClientID client_id, NetworkErrorCode error);
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const char *msg, ClientID from_id, int64 data = 0);
void NetworkServerKickClient(ClientID client_id);
void NetworkServerBanIP(const char *banip);
uint NetworkServerKickOrBanIP(const char *ip, bool ban);
void NetworkInitChatMessage();
void CDECL NetworkAddChatMessage(TextColour colour, uint8 duration, const char *message, ...) WARN_FORMAT(3, 4);

View File

@@ -1786,7 +1786,7 @@ static void ClientList_Ban(byte client_no)
if (ci == NULL) return;
NetworkServerBanIP(GetClientIP(ci));
NetworkServerKickOrBanIP(GetClientIP(ci), true);
}
static void ClientList_GiveMoney(byte client_no)

View File

@@ -1808,19 +1808,24 @@ void NetworkServerKickClient(ClientID client_id)
NetworkServerSendError(client_id, NETWORK_ERROR_KICKED);
}
void NetworkServerBanIP(const char *banip)
uint NetworkServerKickOrBanIP(const char *ip, bool ban)
{
NetworkClientInfo *ci;
/* Add address to ban-list */
if (ban) *_network_ban_list.Append() = strdup(ip);
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_address.IsInNetmask(const_cast<char *>(banip))) {
if (ci->client_id == CLIENT_ID_SERVER) continue;
if (ci->client_address.IsInNetmask(const_cast<char *>(ip))) {
NetworkServerKickClient(ci->client_id);
n++;
}
}
/* Add user to ban-list */
*_network_ban_list.Append() = strdup(banip);
return n;
}
bool NetworkCompanyHasClients(CompanyID company)