3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-04-29 19:30:44 +02:00

relay: fake revert mode changes we couldn't bounce ()

This allows services to revert mode changes CLAIM was not happy with, instead of causing another mode war during this process.
This commit is contained in:
James Lu 2019-06-21 15:38:49 -07:00
parent dcab011673
commit ed4404bf4b

@ -1884,23 +1884,22 @@ def handle_mode(irc, numeric, command, args):
for named_modepair in modedelta_modes])) for named_modepair in modedelta_modes]))
if not check_claim(irc, target, numeric, chanobj=oldchan): if not check_claim(irc, target, numeric, chanobj=oldchan):
if _claim_should_bounce(irc, target): # Mode change blocked by CLAIM.
# Mode change blocked by CLAIM. reversed_modes = irc.reverse_modes(target, modes, oldobj=oldchan)
reversed_modes = irc.reverse_modes(target, modes, oldobj=oldchan)
if irc.is_privileged_service(numeric): if irc.is_privileged_service(numeric):
# Special hack for "U-lined" servers - ignore changes to SIMPLE modes and # Special hack for "U-lined" servers - ignore changes to SIMPLE modes and
# attempts to op its own clients (trying to change status for others # attempts to op its own clients (trying to change status for others
# SHOULD be reverted). # SHOULD be reverted).
# This is for compatibility with Anope's DEFCON for the most part, as well as # This is for compatibility with Anope's DEFCON for the most part, as well as
# silly people who try to register a channel multiple times via relay. # silly people who try to register a channel multiple times via relay.
reversed_modes = [modepair for modepair in reversed_modes if reversed_modes = [modepair for modepair in reversed_modes if
# Include prefix modes if target isn't also U-lined # Include prefix modes if target isn't also U-lined
((modepair[0][-1] in irc.prefixmodes and not ((modepair[0][-1] in irc.prefixmodes and not
irc.is_privileged_service(modepair[1])) irc.is_privileged_service(modepair[1]))
# Include all list modes (bans, etc.) # Include all list modes (bans, etc.)
or modepair[0][-1] in irc.cmodes['*A']) or modepair[0][-1] in irc.cmodes['*A'])
] ]
modes.clear() # Clear the mode list so nothing is relayed below modes.clear() # Clear the mode list so nothing is relayed below
for modepair in modes.copy(): for modepair in modes.copy():
@ -1931,9 +1930,14 @@ def handle_mode(irc, numeric, command, args):
irc.name, str(modepair), target) irc.name, str(modepair), target)
if reversed_modes: if reversed_modes:
log.debug('(%s) relay.handle_mode: Reversing mode changes of %r with %r.', if _claim_should_bounce(irc, target):
irc.name, args['modes'], reversed_modes) log.debug('(%s) relay.handle_mode: Reversing mode changes %r on %s with %r.',
irc.mode(irc.sid, target, reversed_modes) irc.name, args['modes'], target, reversed_modes)
irc.mode(irc.sid, target, reversed_modes)
else:
log.debug('(%s) relay.handle_mode: Fake reversing mode changes %r on %s with %r.',
irc.name, args['modes'], target, reversed_modes)
irc.apply_modes(target, reversed_modes)
if modes: if modes:
iterate_all(irc, _handle_mode_loop, extra_args=(numeric, command, target, modes)) iterate_all(irc, _handle_mode_loop, extra_args=(numeric, command, target, modes))