mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
protocols: consistently track ENDBURST on sub-servers too
This commit is contained in:
parent
87639ddeb2
commit
9a84dbde71
@ -17,13 +17,11 @@ class HybridProtocol(TS6Protocol):
|
||||
self.casemapping = 'ascii'
|
||||
self.caps = {}
|
||||
self.hook_map = {'EOB': 'ENDBURST', 'TBURST': 'TOPIC', 'SJOIN': 'JOIN'}
|
||||
self.has_eob = False
|
||||
self.protocol_caps -= {'slash-in-hosts'}
|
||||
|
||||
def post_connect(self):
|
||||
"""Initializes a connection to a server."""
|
||||
ts = self.start_ts
|
||||
self.has_eob = False
|
||||
f = self.send
|
||||
|
||||
# https://github.com/grawity/irc-docs/blob/master/server/ts6.txt#L80
|
||||
@ -227,12 +225,13 @@ class HybridProtocol(TS6Protocol):
|
||||
return {'channel': channel, 'setter': setter, 'ts': ts, 'text': topic}
|
||||
|
||||
def handle_eob(self, numeric, command, args):
|
||||
log.debug('(%s) end of burst received', self.name)
|
||||
if not self.has_eob: # Only call ENDBURST hooks if we haven't already.
|
||||
"""EOB (end-of-burst) handler."""
|
||||
log.debug('(%s) end of burst received from %s', self.name, numeric)
|
||||
if not self.servers[numeric].has_eob:
|
||||
# Don't fight with TS6's generic PING-as-EOB
|
||||
self.servers[numeric].has_eob = True
|
||||
return {}
|
||||
|
||||
self.has_eob = True
|
||||
|
||||
def handle_svsmode(self, numeric, command, args):
|
||||
"""
|
||||
Handles SVSMODE, which is used for sending services metadata
|
||||
|
@ -716,6 +716,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
|
||||
def handle_endburst(self, numeric, command, args):
|
||||
"""ENDBURST handler; sends a hook with empty contents."""
|
||||
self.servers[numeric].has_eob = True
|
||||
return {}
|
||||
|
||||
def handle_away(self, numeric, command, args):
|
||||
|
@ -504,16 +504,20 @@ class NgIRCdProtocol(IRCS2SProtocol):
|
||||
assert 'IRC+' in args[1], "Linking to non-ngIRCd server using this protocol module is not supported"
|
||||
|
||||
def handle_ping(self, source, command, args):
|
||||
if source == self.uplink:
|
||||
self._send_with_prefix(self.sid, 'PONG %s :%s' % (self._expandPUID(self.sid), args[-1]), queue=False)
|
||||
"""
|
||||
Handles incoming PINGs (and implicit end of burst).
|
||||
"""
|
||||
self._send_with_prefix(self.sid, 'PONG %s :%s' % (self._expandPUID(self.sid), args[-1]), queue=False)
|
||||
|
||||
if not self.has_eob:
|
||||
# Treat the first PING we receive as end of burst.
|
||||
self.has_eob = True
|
||||
if not self.servers[source].has_eob:
|
||||
# Treat the first PING we receive as end of burst.
|
||||
self.servers[source].has_eob = True
|
||||
|
||||
if source == self.uplink:
|
||||
self.connected.set()
|
||||
|
||||
# Return the endburst hook.
|
||||
return {'parse_as': 'ENDBURST'}
|
||||
# Return the endburst hook.
|
||||
return {'parse_as': 'ENDBURST'}
|
||||
|
||||
def handle_server(self, source, command, args):
|
||||
"""
|
||||
|
@ -1110,15 +1110,18 @@ class P10Protocol(IRCS2SProtocol):
|
||||
|
||||
return {'channel': channel, 'users': [source], 'modes':
|
||||
self._channels[channel].modes, 'ts': ts or int(time.time())}
|
||||
|
||||
handle_create = handle_join
|
||||
|
||||
def handle_end_of_burst(self, source, command, args):
|
||||
"""Handles end of burst from our uplink."""
|
||||
"""Handles end of burst from servers."""
|
||||
|
||||
# Send EOB acknowledgement; this is required by the P10 specification,
|
||||
# and needed if we want to be able to receive channel messages, etc.
|
||||
if source == self.uplink:
|
||||
self._send_with_prefix(self.sid, 'EA')
|
||||
return {}
|
||||
|
||||
self.servers[source].has_eob = True
|
||||
return {}
|
||||
|
||||
def handle_kick(self, source, command, args):
|
||||
"""Handles incoming KICKs."""
|
||||
|
@ -20,9 +20,6 @@ class TS6Protocol(TS6BaseProtocol):
|
||||
self.hook_map = {'SJOIN': 'JOIN', 'TB': 'TOPIC', 'TMODE': 'MODE', 'BMASK': 'MODE',
|
||||
'EUID': 'UID', 'RSFNC': 'SVSNICK', 'ETB': 'TOPIC', 'USERMODE': 'MODE'}
|
||||
|
||||
# Track whether we've received end-of-burst from the uplink.
|
||||
self.has_eob = False
|
||||
|
||||
self.required_caps = {'EUID', 'SAVE', 'TB', 'ENCAP', 'QS', 'CHW'}
|
||||
|
||||
# From ChatIRCd: https://github.com/ChatLounge/ChatIRCd/blob/master/doc/technical/ChatIRCd-extra.txt
|
||||
@ -264,7 +261,6 @@ class TS6Protocol(TS6BaseProtocol):
|
||||
def post_connect(self):
|
||||
"""Initializes a connection to a server."""
|
||||
ts = self.start_ts
|
||||
self.has_eob = False
|
||||
|
||||
f = self.send
|
||||
|
||||
@ -445,10 +441,10 @@ class TS6Protocol(TS6BaseProtocol):
|
||||
if self.is_internal_server(destination):
|
||||
self._send_with_prefix(destination, 'PONG %s %s' % (destination, source), queue=False)
|
||||
|
||||
if destination == self.sid and not self.has_eob:
|
||||
# Charybdis' endburst is just sending a PING to the other server.
|
||||
if not self.servers[source].has_eob:
|
||||
# TS6 endburst is just sending a PING to the other server.
|
||||
# https://github.com/charybdis-ircd/charybdis/blob/dc336d1/modules/core/m_server.c#L484-L485
|
||||
self.has_eob = True
|
||||
self.servers[source].has_eob = True
|
||||
|
||||
# Return the endburst hook.
|
||||
return {'parse_as': 'ENDBURST'}
|
||||
|
@ -379,6 +379,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
||||
|
||||
def handle_eos(self, numeric, command, args):
|
||||
"""EOS is used to denote end of burst."""
|
||||
self.servers[numeric].has_eob = True
|
||||
return {}
|
||||
|
||||
def handle_uid(self, numeric, command, args):
|
||||
|
Loading…
Reference in New Issue
Block a user