From 0b2d65bbb8c5921bd479399ed900a5522256fb68 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 5 Oct 2012 16:54:05 -0400 Subject: [PATCH] Time out if IRCd fails during handshake. --- irkerd | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/irkerd b/irkerd index 1cb1c0f..fe68100 100755 --- a/irkerd +++ b/irkerd @@ -30,6 +30,7 @@ PORT = 6659 NAMESTYLE = "irker%03d" # IRC nick template - must contain '%d' XMIT_TTL = (3 * 60 * 60) # Time to live, seconds from last transmit PING_TTL = (15 * 60) # Time to live, seconds from last PING +HANDSHAKE_TIMEOUT = 60 # Time to live, seconds from nick transmit CHANNEL_TTL = (3 * 60 * 60) # Time to live, seconds from last transmit DISCONNECT_TTL = (24 * 60 * 60) # Time to live, seconds from last connect UNSEEN_TTL = 60 # Time to live, seconds since first request @@ -137,6 +138,7 @@ class Connection: # Randomness prevents a malicious user or bot from antcipating the # next trial name in order to block us from completing the handshake. self.nick_trial += random.randint(1, 3) + self.last_xmit = time.time() self.connection.nick(self.nickname()) def handle_disconnect(self): "Server disconnected us for flooding or some other reason." @@ -217,9 +219,12 @@ class Connection: except irc.client.ServerConnectionError: self.status = "disconnected" elif self.status == "handshaking": - # Don't buzz on the empty-queue test while we're - # handshaking - time.sleep(ANTI_BUZZ_DELAY) + if time.time() > self.last_xmit + HANDSHAKE_TTL: + self.status = "expired" + else: + # Don't buzz on the empty-queue test while we're + # handshaking + time.sleep(ANTI_BUZZ_DELAY) elif self.status == "disconnected" \ and time.time() > self.last_xmit + DISCONNECT_TTL: # Queue is nonempty, but the IRC server might be -- 2.26.2