summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-03-06 22:00:42 +0000
committerrubidium <rubidium@openttd.org>2007-03-06 22:00:42 +0000
commita2b5b74b83e213f1e32e8f2cafe40f3527f018a5 (patch)
treea90b27beb2d4d1de059a5cdb393a6be2250d9dda
parent68020bfa6d8679087af98c36cdf9a2dade4a196b (diff)
downloadopenttd-a2b5b74b83e213f1e32e8f2cafe40f3527f018a5.tar.xz
(svn r9038) -Fix [FS#115]: inactive connections are not automatically kicked, i.e. people who only open a telnet (or similar) connection to a server.
-rw-r--r--src/console_cmds.cpp1
-rw-r--r--src/network/core/tcp.h1
-rw-r--r--src/network/network_server.cpp11
3 files changed, 13 insertions, 0 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 4d3ac74fa..128c1f0b3 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -544,6 +544,7 @@ DEF_CONSOLE_CMD(ConStatus)
{
static const char* const stat_str[] = {
"inactive",
+ "authorizing",
"authorized",
"waiting",
"loading map",
diff --git a/src/network/core/tcp.h b/src/network/core/tcp.h
index 27df6e03d..a667ab099 100644
--- a/src/network/core/tcp.h
+++ b/src/network/core/tcp.h
@@ -73,6 +73,7 @@ typedef struct CommandPacket {
/** Status of a client */
typedef enum {
STATUS_INACTIVE, ///< The client is not connected nor active
+ STATUS_AUTHORIZING,///< The client is authorizing
STATUS_AUTH, ///< The client is authorized
STATUS_MAP_WAIT, ///< The client is waiting as someone else is downloading the map
STATUS_MAP, ///< The client is downloading the map
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index ce9b9f881..5762550c9 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -214,6 +214,11 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_NEED_PASSWORD)(NetworkTCPSocketHandl
// uint8: Type of password
//
+ /* Invalid packet when status is AUTH or higher */
+ if (cs->status >= STATUS_AUTH) return;
+
+ cs->status = STATUS_AUTHORIZING;
+
Packet *p = NetworkSend_Init(PACKET_SERVER_NEED_PASSWORD);
p->Send_uint8(type);
cs->Send_Packet(p);
@@ -1533,6 +1538,12 @@ void NetworkServer_Tick(bool send_frame)
IConsolePrintF(_icolour_err,"Client #%d is dropped because it took longer than %d ticks for him to join", cs->index, _network_max_join_time);
NetworkCloseClient(cs);
}
+ } else if (cs->status == STATUS_INACTIVE) {
+ int lag = NetworkCalculateLag(cs);
+ if (lag > 4 * DAY_TICKS) {
+ IConsolePrintF(_icolour_err,"Client #%d is dropped because it took longer than %d ticks to start the joining process", cs->index, 4 * DAY_TICKS);
+ NetworkCloseClient(cs);
+ }
}
if (cs->status >= STATUS_PRE_ACTIVE) {