3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 09:19:23 +01:00

inspircd: add FJOIN, IJOIN, KICK handling for InspIRCd 3

IJOIN is new. Strip membership IDs from incoming FJOIN and KICK for now.
This commit is contained in:
James Lu 2019-05-02 17:27:48 -07:00
parent 08386a8ef7
commit ad4cb9561c

View File

@ -32,7 +32,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
self.hook_map = {'FJOIN': 'JOIN', 'RSQUIT': 'SQUIT', 'FMODE': 'MODE', self.hook_map = {'FJOIN': 'JOIN', 'RSQUIT': 'SQUIT', 'FMODE': 'MODE',
'FTOPIC': 'TOPIC', 'OPERTYPE': 'MODE', 'FHOST': 'CHGHOST', 'FTOPIC': 'TOPIC', 'OPERTYPE': 'MODE', 'FHOST': 'CHGHOST',
'FIDENT': 'CHGIDENT', 'FNAME': 'CHGNAME', 'SVSTOPIC': 'TOPIC', 'FIDENT': 'CHGIDENT', 'FNAME': 'CHGNAME', 'SVSTOPIC': 'TOPIC',
'SAKICK': 'KICK'} 'SAKICK': 'KICK', 'IJOIN': 'JOIN'}
ircd_target = self.serverdata.get('target_version', self.DEFAULT_IRCD).lower() ircd_target = self.serverdata.get('target_version', self.DEFAULT_IRCD).lower()
if ircd_target == 'insp20': if ircd_target == 'insp20':
@ -605,6 +605,16 @@ class InspIRCdProtocol(TS6BaseProtocol):
# <- 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 # <- 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 |= set(args[-1].split()) self._modsupport |= set(args[-1].split())
def handle_kick(self, source, command, args):
"""Handles incoming KICKs."""
# InspIRCD 3 adds membership IDs to KICK messages when forwarding across servers
# <- :3INAAAAAA KICK #endlessvoid 3INAAAAAA :test (local)
# <- :3INAAAAAA KICK #endlessvoid 7PYAAAAAA 0 :test (remote)
if self.remote_proto_ver >= 1205 and len(args) > 3:
del args[2]
return super().handle_kick(source, command, args)
def handle_ping(self, source, command, args): def handle_ping(self, source, command, args):
"""Handles incoming PING commands, so we don't time out.""" """Handles incoming PING commands, so we don't time out."""
# <- :70M PING 70M 0AL # <- :70M PING 70M 0AL
@ -616,7 +626,10 @@ class InspIRCdProtocol(TS6BaseProtocol):
def handle_fjoin(self, servernumeric, command, args): def handle_fjoin(self, servernumeric, command, args):
"""Handles incoming FJOIN commands (InspIRCd equivalent of JOIN/SJOIN).""" """Handles incoming FJOIN commands (InspIRCd equivalent of JOIN/SJOIN)."""
# :70M FJOIN #chat 1423790411 +AFPfjnt 6:5 7:5 9:5 :o,1SRAABIT4 v,1IOAAF53R <...> # insp2:
# <- :70M FJOIN #chat 1423790411 +AFPfjnt 6:5 7:5 9:5 :o,1SRAABIT4 v,1IOAAF53R <...>
# insp3:
# <- :3IN FJOIN #test 1556842195 +nt :o,3INAAAAAA:4
channel = args[0] channel = args[0]
chandata = self._channels[channel].deepcopy() chandata = self._channels[channel].deepcopy()
# InspIRCd sends each channel's users in the form of 'modeprefix(es),UID' # InspIRCd sends each channel's users in the form of 'modeprefix(es),UID'
@ -632,6 +645,10 @@ class InspIRCdProtocol(TS6BaseProtocol):
for user in userlist: for user in userlist:
modeprefix, user = user.split(',', 1) modeprefix, user = user.split(',', 1)
if self.remote_proto_ver >= 1205:
# XXX: we don't handle membership IDs yet
user = user.split(':', 1)[0]
# Don't crash when we get an invalid UID. # Don't crash when we get an invalid UID.
if user not in self.users: if user not in self.users:
log.debug('(%s) handle_fjoin: tried to introduce user %s not in our user list, ignoring...', log.debug('(%s) handle_fjoin: tried to introduce user %s not in our user list, ignoring...',
@ -659,6 +676,18 @@ class InspIRCdProtocol(TS6BaseProtocol):
return {'channel': channel, 'users': namelist, 'modes': parsedmodes, 'ts': their_ts, return {'channel': channel, 'users': namelist, 'modes': parsedmodes, 'ts': their_ts,
'channeldata': chandata} 'channeldata': chandata}
def handle_ijoin(self, source, command, args):
"""Handles InspIRCd 3 joins with membership ID."""
# insp3:
# <- :3INAAAAAA IJOIN #valhalla 6
# For now we don't care about the membership ID
channel = args[0]
self.users[source].channels.add(channel)
self._channels[channel].users.add(source)
return {'channel': channel, 'users': [source], 'modes':
self._channels[channel].modes}
def handle_uid(self, numeric, command, args): def handle_uid(self, numeric, command, args):
"""Handles incoming UID commands (user introduction).""" """Handles incoming UID commands (user introduction)."""
# :70M UID 70MAAAAAB 1429934638 GL 0::1 hidden-7j810p.9mdf.lrek.0000.0000.IP gl 0::1 1429934638 +Wioswx +ACGKNOQXacfgklnoqvx :realname # :70M UID 70MAAAAAB 1429934638 GL 0::1 hidden-7j810p.9mdf.lrek.0000.0000.IP gl 0::1 1429934638 +Wioswx +ACGKNOQXacfgklnoqvx :realname