3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-29 06:02:38 +01:00

inspircd: track module (un)loading

Closes #555.
This commit is contained in:
James Lu 2017-12-22 12:38:48 -08:00
parent c62580d228
commit 92427201f1

View File

@ -273,7 +273,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
else:
# It is a client on another server, use CHGIDENT/HOST/NAME.
if field == 'IDENT':
if 'm_chgident.so' not in self.modsupport:
if 'm_chgident.so' not in self._modsupport:
log.warning('(%s) Failed to change ident of %s to %r: load m_chgident.so!', self.name, target, text)
return
@ -284,7 +284,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
self.call_hooks([self.sid, 'CHGIDENT',
{'target': target, 'newident': text}])
elif field == 'HOST':
if 'm_chghost.so' not in self.modsupport:
if 'm_chghost.so' not in self._modsupport:
log.warning('(%s) Failed to change host of %s to %r: load m_chghost.so!', self.name, target, text)
return
@ -295,7 +295,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
{'target': target, 'newhost': text}])
elif field in ('REALNAME', 'GECOS'):
if 'm_chgname.so' not in self.modsupport:
if 'm_chgname.so' not in self._modsupport:
log.warning('(%s) Failed to change real name of %s to %r: load m_chgname.so!', self.name, target, text)
return
self.users[target].realname = text
@ -395,7 +395,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
ts = self.start_ts
# Track the modules supported by the uplink.
self.modsupport = []
self._modsupport = set()
f = self.send
f('CAPAB START %s' % self.proto_ver)
@ -528,7 +528,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
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()
self._modsupport |= set(args[-1].split())
def handle_ping(self, source, command, args):
"""Handles incoming PING commands, so we don't time out."""
@ -770,6 +770,18 @@ class InspIRCdProtocol(TS6BaseProtocol):
# Sets the services login name of the client.
self.call_hooks([uid, 'CLIENT_SERVICES_LOGIN', {'text': args[-1]}])
elif args[1] == 'modules':
# <- :70M METADATA * modules :-m_chghost.so
# <- :70M METADATA * modules :+m_chghost.so
for module in args[-1].split():
if module.startswith('-'):
log.debug('(%s) Removing module %s', self.name, module[1:])
self._modsupport.discard(module[1:])
elif module.startswith('+'):
log.debug('(%s) Adding module %s', self.name, module[1:])
self._modsupport.add(module[1:])
else:
log.warning('(%s) Got unknown METADATA modules string: %r', self.name, args[-1])
def handle_version(self, numeric, command, args):
"""