3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-01-11 20:52:42 +01:00

relay: allow toggling netsplit hiding

This commit is contained in:
James Lu 2016-06-25 13:47:59 -07:00
parent a3b9c55de6
commit 1ce6102ae8
2 changed files with 28 additions and 1 deletions

View File

@ -382,6 +382,10 @@ relay:
# opers), and "none" (disabled). Defaults to none if not specified.
whois_show_server: opers
# Determines whether netsplits should be hidden as *.net *.split over the relay.
# Defaults to False.
show_netsplits: false
games:
# Sets the nick of the Games service, if you're using it.
nick: Games

View File

@ -834,24 +834,47 @@ def handle_quit(irc, numeric, command, args):
utils.add_hook(handle_quit, 'QUIT')
def handle_squit(irc, numeric, command, args):
"""
Handles SQUITs over relay.
"""
users = args['users']
target = args['target']
# Someone /SQUIT one of our relay subservers. Bad! Rejoin them!
if target in relayservers[irc.name].values():
sname = args['name']
remotenet = sname.split('.', 1)[0]
del relayservers[irc.name][remotenet]
for userpair in relayusers:
if userpair[0] == remotenet and irc.name in relayusers[userpair]:
del relayusers[userpair][irc.name]
remoteirc = world.networkobjects[remotenet]
initializeAll(remoteirc)
else:
# Some other netsplit happened on the network, we'll have to fake
# some *.net *.split quits for that.
for user in users:
log.debug('(%s) relay.handle_squit: sending handle_quit on %s', irc.name, user)
handle_quit(irc, user, command, {'text': '*.net *.split'})
try: # Allow netsplit hiding to be toggled
show_splits = irc.conf['relay']['show_netsplits']
except KeyError:
show_splits = False
text = '*.net *.split'
if show_splits:
uplink = args['uplink']
try:
text = '%s %s' % (irc.servers[uplink].name, args['name'])
except (KeyError, AttributeError):
log.warning("(%s) relay.handle_squit: Failed to get server name for %s",
irc.name, uplink)
handle_quit(irc, user, command, {'text': text})
utils.add_hook(handle_squit, 'SQUIT')
def handle_nick(irc, numeric, command, args):