From 8170e777e8193478ba5be9279fb7501cbecbbbfa Mon Sep 17 00:00:00 2001 From: James Lu Date: Wed, 30 Aug 2017 19:39:57 -0700 Subject: [PATCH] protocols: move setting irc.connected to endburst --- protocols/clientbot.py | 7 +++---- protocols/hybrid.py | 3 +++ protocols/inspircd.py | 5 ++--- protocols/p10.py | 2 +- protocols/ts6.py | 7 ++++--- protocols/unreal.py | 5 ++--- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/protocols/clientbot.py b/protocols/clientbot.py index 00b1daf..b763e14 100644 --- a/protocols/clientbot.py +++ b/protocols/clientbot.py @@ -633,10 +633,9 @@ class ClientbotWrapperProtocol(IRCCommonProtocol): self.send(line) # Virtual endburst hook. - self.connected.set() # Note, this should always be set before sending ENDBURST - if not self.has_eob: - self.has_eob = True - return {'parse_as': 'ENDBURST'} + self.connected.set() # Note, this should always be set before the actual ENDBURST hook + self.servers[self.uplink].has_eob = True + return {'parse_as': 'ENDBURST'} handle_422 = handle_376 diff --git a/protocols/hybrid.py b/protocols/hybrid.py index f09e1a6..60df8de 100644 --- a/protocols/hybrid.py +++ b/protocols/hybrid.py @@ -230,6 +230,9 @@ class HybridProtocol(TS6Protocol): if not self.servers[numeric].has_eob: # Don't fight with TS6's generic PING-as-EOB self.servers[numeric].has_eob = True + + if numeric == self.uplink: + self.connected.set() return {} def handle_svsmode(self, numeric, command, args): diff --git a/protocols/inspircd.py b/protocols/inspircd.py index 8fd9087..1e3bfa0 100644 --- a/protocols/inspircd.py +++ b/protocols/inspircd.py @@ -520,9 +520,6 @@ class InspIRCdProtocol(TS6BaseProtocol): log.debug('(%s) self.prefixmodes set to %r', self.name, self.prefixmodes) - # Finally, set the irc.connected (protocol negotiation complete) - # state to True. - self.connected.set() elif args[0] == 'MODSUPPORT': # <- CAPAB MODSUPPORT :m_alltime.so m_check.so m_chghost.so m_chgident.so m_chgname.so m_fullversion.so m_gecosban.so m_knock.so m_muteban.so m_nicklock.so m_nopartmsg.so m_opmoderated.so m_sajoin.so m_sanick.so m_sapart.so m_serverban.so m_services_account.so m_showwhois.so m_silence.so m_swhois.so m_uninvite.so m_watch.so self.modsupport = args[-1].split() @@ -717,6 +714,8 @@ class InspIRCdProtocol(TS6BaseProtocol): def handle_endburst(self, numeric, command, args): """ENDBURST handler; sends a hook with empty contents.""" self.servers[numeric].has_eob = True + if numeric == self.uplink: + self.connected.set() return {} def handle_away(self, numeric, command, args): diff --git a/protocols/p10.py b/protocols/p10.py index abd3cbb..4af3421 100644 --- a/protocols/p10.py +++ b/protocols/p10.py @@ -824,7 +824,6 @@ class P10Protocol(IRCS2SProtocol): self.send('SERVER %s 1 %s %s J10 %s]]] +s6 :%s' % (name, ts, ts, sid, desc)) self._send_with_prefix(sid, "EB") - self.connected.set() def handle_server(self, source, command, args): """Handles incoming server introductions.""" @@ -1119,6 +1118,7 @@ class P10Protocol(IRCS2SProtocol): # and needed if we want to be able to receive channel messages, etc. if source == self.uplink: self._send_with_prefix(self.sid, 'EA') + self.connected.set() self.servers[source].has_eob = True return {} diff --git a/protocols/ts6.py b/protocols/ts6.py index 93c83c0..aab7dd4 100644 --- a/protocols/ts6.py +++ b/protocols/ts6.py @@ -419,9 +419,6 @@ class TS6Protocol(TS6BaseProtocol): if 'SERVICES' in caps: self.cmodes['regonly'] = 'r' - log.debug('(%s) self.connected set!', self.name) - self.connected.set() - def handle_ping(self, source, command, args): """Handles incoming PING commands.""" # PING: @@ -446,6 +443,10 @@ class TS6Protocol(TS6BaseProtocol): # https://github.com/charybdis-ircd/charybdis/blob/dc336d1/modules/core/m_server.c#L484-L485 self.servers[source].has_eob = True + if source == self.uplink: + log.debug('(%s) self.connected set!', self.name) + self.connected.set() + # Return the endburst hook. return {'parse_as': 'ENDBURST'} diff --git a/protocols/unreal.py b/protocols/unreal.py index 985faa8..ad9b2d2 100644 --- a/protocols/unreal.py +++ b/protocols/unreal.py @@ -380,6 +380,8 @@ class UnrealProtocol(TS6BaseProtocol): def handle_eos(self, numeric, command, args): """EOS is used to denote end of burst.""" self.servers[numeric].has_eob = True + if numeric == self.uplink: + self.connected.set() return {} def handle_uid(self, numeric, command, args): @@ -483,9 +485,6 @@ class UnrealProtocol(TS6BaseProtocol): "(Unreal 4.x), got %s)" % (self.min_proto_ver, protover)) self.servers[numeric] = Server(self, None, sname, desc=sdesc) - # Set irc.connected to True, meaning that protocol negotiation passed. - log.debug('(%s) self.connected set!', self.name) - self.connected.set() else: # Legacy (non-SID) servers can still be introduced using the SERVER command. # <- :services.int SERVER a.bc 2 :(H) [GL] a