summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2005-10-19 19:38:35 +0000
committerDarkvater <darkvater@openttd.org>2005-10-19 19:38:35 +0000
commite611fee4e50ac5447e5ede0a78d578c031530a6a (patch)
tree642308a8906862b991147b781f65099cb90bbcea
parentece9b9b2b6a2feb43c9215c3073e2c09f9f72ae9 (diff)
downloadopenttd-e611fee4e50ac5447e5ede0a78d578c031530a6a.tar.xz
(svn r3067) - Feature: allow unbanning players based on banlist-id (as well as IP).
- Feature: 'status' and 'clients' now show the IP of the players
-rw-r--r--console_cmds.c19
-rw-r--r--network_server.c2
-rw-r--r--network_server.h2
3 files changed, 14 insertions, 9 deletions
diff --git a/console_cmds.c b/console_cmds.c
index 93253b2e3..b4926e1b0 100644
--- a/console_cmds.c
+++ b/console_cmds.c
@@ -404,20 +404,24 @@ DEF_CONSOLE_CMD(ConBan)
DEF_CONSOLE_CMD(ConUnBan)
{
- uint i;
+ uint i, index;
if (argc == 0) {
- IConsoleHelp("Unban a player from a network game. Usage: 'unban <ip>'");
+ IConsoleHelp("Unban a player from a network game. Usage: 'unban <ip\\id>'");
+ IConsoleHelp("For a list of banned IP's, see the command 'banlist'");
return true;
}
if (argc != 2) return false;
+ index = (strrchr(argv[1], '.') == '\0') ? atoi(argv[1]) : 0;
+ index--;
+
for (i = 0; i < lengthof(_network_ban_list); i++) {
if (_network_ban_list[i] == NULL || _network_ban_list[i][0] == '\0')
continue;
- if (strncmp(_network_ban_list[i], argv[1], strlen(_network_ban_list[i])) == 0) {
+ if (strncmp(_network_ban_list[i], argv[1], strlen(_network_ban_list[i])) == 0 || index == i) {
_network_ban_list[i][0] = '\0';
IConsolePrint(_icolour_def, "IP unbanned.");
return true;
@@ -511,8 +515,8 @@ DEF_CONSOLE_CMD(ConStatus)
const NetworkClientInfo *ci = DEREF_CLIENT_INFO(cs);
status = (cs->status <= STATUS_ACTIVE) ? stat_str[cs->status] : "unknown";
- IConsolePrintF(8, "Client #%d/%s status: %s frame-lag: %d play-as: %d unique-id: %s",
- cs->index, ci->client_name, status, lag, ci->client_playas, ci->unique_id);
+ IConsolePrintF(8, "Client #%1d name: '%s' status: '%s' frame-lag: %3d company: %1d IP: %s unique-id: '%s'",
+ cs->index, ci->client_name, status, lag, ci->client_playas, GetPlayerIP(ci), ci->unique_id);
}
return true;
@@ -613,13 +617,14 @@ DEF_CONSOLE_CMD(ConNetworkClients)
NetworkClientInfo *ci;
if (argc == 0) {
- IConsoleHelp("Get a list of connected clients including their ID, name, and company-id. Usage: 'clients'");
+ IConsoleHelp("Get a list of connected clients including their ID, name, company-id, and IP. Usage: 'clients'");
return true;
}
for (ci = _network_client_info; ci != &_network_client_info[MAX_CLIENT_INFO]; ci++) {
if (ci->client_index != NETWORK_EMPTY_INDEX) {
- IConsolePrintF(8, "Client #%d name: %s play-as company: %d", ci->client_index, ci->client_name, ci->client_playas);
+ IConsolePrintF(8, "Client #%1d name: '%s' company: %1d IP: %s",
+ ci->client_index, ci->client_name, ci->client_playas, GetPlayerIP(ci));
}
}
diff --git a/network_server.c b/network_server.c
index 28d32475d..cbfa0c19e 100644
--- a/network_server.c
+++ b/network_server.c
@@ -762,8 +762,6 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_MAP_OK)
}
}
-static inline const char* GetPlayerIP(const NetworkClientInfo *ci) {return inet_ntoa(*(struct in_addr *)&ci->client_ip);}
-
/** Enforce the command flags.
* Eg a server-only command can only be executed by a server, etc.
* @param *cp the commandpacket that is going to be checked
diff --git a/network_server.h b/network_server.h
index e603acb64..2c14b8c4e 100644
--- a/network_server.h
+++ b/network_server.h
@@ -20,6 +20,8 @@ void NetworkServer_Tick(bool send_frame);
void NetworkServerMonthlyLoop(void);
void NetworkServerYearlyLoop(void);
+static inline const char* GetPlayerIP(const NetworkClientInfo *ci) {return inet_ntoa(*(struct in_addr *)&ci->client_ip);}
+
#endif /* ENABLE_NETWORK */
#endif /* NETWORK_SERVER_H */