From 92427201f12733dfad9304df1bd7462c2103cb4a Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 22 Dec 2017 12:38:48 -0800 Subject: [PATCH] inspircd: track module (un)loading Closes #555. --- protocols/inspircd.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/protocols/inspircd.py b/protocols/inspircd.py index b51349d..e0b3927 100644 --- a/protocols/inspircd.py +++ b/protocols/inspircd.py @@ -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): """