mirror of https://github.com/OpenTTD/OpenTTD
(svn r22365) -Codechange: add overload of NetworkServerKickOrBanIP using the ClientID, which later resolves the IP address to ban. This to consolidate the knowledge about resolving IP addresses
parent
1c419d99bc
commit
caf02450fb
|
@ -490,7 +490,7 @@ DEF_CONSOLE_CMD(ConClearBuffer)
|
||||||
|
|
||||||
static bool ConKickOrBan(const char *argv, bool ban)
|
static bool ConKickOrBan(const char *argv, bool ban)
|
||||||
{
|
{
|
||||||
const char *ip = argv;
|
uint n;
|
||||||
|
|
||||||
if (strchr(argv, '.') == NULL && strchr(argv, ':') == NULL) { // banning with ID
|
if (strchr(argv, '.') == NULL && strchr(argv, ':') == NULL) { // banning with ID
|
||||||
ClientID client_id = (ClientID)atoi(argv);
|
ClientID client_id = (ClientID)atoi(argv);
|
||||||
|
@ -513,10 +513,11 @@ static bool ConKickOrBan(const char *argv, bool ban)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* When banning, kick+ban all clients with that IP */
|
/* When banning, kick+ban all clients with that IP */
|
||||||
ip = GetClientIP(ci);
|
n = NetworkServerKickOrBanIP(client_id, ban);
|
||||||
|
} else {
|
||||||
|
n = NetworkServerKickOrBanIP(argv, ban);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint n = NetworkServerKickOrBanIP(ip, ban);
|
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
IConsolePrint(CC_DEFAULT, ban ? "Client not online, address added to banlist" : "Client not found");
|
IConsolePrint(CC_DEFAULT, ban ? "Client not online, address added to banlist" : "Client not found");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -75,6 +75,7 @@ void NetworkServerSendRcon(ClientID client_id, TextColour colour_code, const cha
|
||||||
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const char *msg, ClientID from_id, int64 data = 0, bool from_admin = false);
|
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const char *msg, ClientID from_id, int64 data = 0, bool from_admin = false);
|
||||||
|
|
||||||
void NetworkServerKickClient(ClientID client_id);
|
void NetworkServerKickClient(ClientID client_id);
|
||||||
|
uint NetworkServerKickOrBanIP(ClientID client_id, bool ban);
|
||||||
uint NetworkServerKickOrBanIP(const char *ip, bool ban);
|
uint NetworkServerKickOrBanIP(const char *ip, bool ban);
|
||||||
|
|
||||||
void NetworkInitChatMessage();
|
void NetworkInitChatMessage();
|
||||||
|
|
|
@ -1717,7 +1717,7 @@ static void ClientList_Kick(const NetworkClientInfo *ci)
|
||||||
|
|
||||||
static void ClientList_Ban(const NetworkClientInfo *ci)
|
static void ClientList_Ban(const NetworkClientInfo *ci)
|
||||||
{
|
{
|
||||||
NetworkServerKickOrBanIP(GetClientIP(const_cast<NetworkClientInfo *>(ci)), true);
|
NetworkServerKickOrBanIP(ci->client_id, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ClientList_GiveMoney(const NetworkClientInfo *ci)
|
static void ClientList_GiveMoney(const NetworkClientInfo *ci)
|
||||||
|
|
|
@ -1919,6 +1919,11 @@ void NetworkServerKickClient(ClientID client_id)
|
||||||
NetworkServerSendError(client_id, NETWORK_ERROR_KICKED);
|
NetworkServerSendError(client_id, NETWORK_ERROR_KICKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint NetworkServerKickOrBanIP(ClientID client_id, bool ban)
|
||||||
|
{
|
||||||
|
return NetworkServerKickOrBanIP(GetClientIP(NetworkClientInfo::GetByClientID(client_id)), ban);
|
||||||
|
}
|
||||||
|
|
||||||
uint NetworkServerKickOrBanIP(const char *ip, bool ban)
|
uint NetworkServerKickOrBanIP(const char *ip, bool ban)
|
||||||
{
|
{
|
||||||
/* Add address to ban-list */
|
/* Add address to ban-list */
|
||||||
|
|
Loading…
Reference in New Issue