mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-24 11:42:51 +01:00
protocols: return uplink field in SQUIT handlers
This commit is contained in:
parent
1a6bb714ac
commit
d2956c3d00
@ -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.
|
||||
|
||||
|
@ -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."""
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user