diff --git a/docs/technical/hooks-reference.md b/docs/technical/hooks-reference.md index b23974b..6bb307b 100644 --- a/docs/technical/hooks-reference.md +++ b/docs/technical/hooks-reference.md @@ -96,7 +96,7 @@ The following hooks represent regular IRC commands sent between servers. - **QUIT**: `{'text': 'Quit: Bye everyone!'}` - `text` corresponds to the quit reason. -- **SQUIT**: `{'target': '800', 'users': ['UID1', 'UID2', 'UID6'], 'name': 'some.server'}` +- **SQUIT**: `{'target': '800', 'users': ['UID1', 'UID2', 'UID6'], 'name': 'some.server', 'uplink': '24X'}` - `target` is the SID of the server being split, while `name` is the server's name. - `users` is a list of all UIDs affected by the netsplit. diff --git a/protocols/nefarious.py b/protocols/nefarious.py index 468f8cd..8cb3d7e 100644 --- a/protocols/nefarious.py +++ b/protocols/nefarious.py @@ -1212,10 +1212,12 @@ class P10Protocol(Protocol): self.removeClient(user) sname = self.irc.servers[split_server].name + uplink = self.irc.servers[split_server].uplink del self.irc.servers[split_server] log.debug('(%s) Netsplit affected users: %s', self.irc.name, affected_users) - return {'target': split_server, 'users': affected_users, 'name': sname} + return {'target': split_server, 'users': affected_users, 'name': sname, + 'uplink': uplink} def handle_topic(self, source, command, args): """Handles TOPIC changes.""" diff --git a/protocols/ts6_common.py b/protocols/ts6_common.py index a6544eb..4b2bcb4 100644 --- a/protocols/ts6_common.py +++ b/protocols/ts6_common.py @@ -383,6 +383,9 @@ class TS6BaseProtocol(Protocol): if split_server not in self.irc.servers: log.warning("(%s) Tried to split a server (%s) that didn't exist!", self.irc.name, split_server) return + + uplink = self.irc.servers[split_server].uplink + # Prevent RuntimeError: dictionary changed size during iteration old_servers = self.irc.servers.copy() for sid, data in old_servers.items(): @@ -390,14 +393,18 @@ class TS6BaseProtocol(Protocol): log.debug('Server %s also hosts server %s, removing those users too...', split_server, sid) args = self.handle_squit(sid, 'SQUIT', [sid, "PyLink: Automatically splitting leaf servers of %s" % sid]) affected_users += args['users'] + for user in self.irc.servers[split_server].users.copy(): affected_users.append(user) log.debug('Removing client %s (%s)', user, self.irc.users[user].nick) self.removeClient(user) + sname = self.irc.servers[split_server].name del self.irc.servers[split_server] + log.debug('(%s) Netsplit affected users: %s', self.irc.name, affected_users) - return {'target': split_server, 'users': affected_users, 'name': sname} + return {'target': split_server, 'users': affected_users, 'name': sname, + 'uplink': uplink} def handle_topic(self, numeric, command, args): """Handles incoming TOPIC changes from clients. For topic bursts,