From c7e4c05cbd2ced670d1fab378dfb0c9f2a933a82 Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 9 Apr 2019 19:01:35 -0700 Subject: [PATCH] changehost: only send a host change if new host != original (cherry picked from commit 13be40e08bf4ca842b3908ec9b15ee9008ef95b9) --- plugins/changehost.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/plugins/changehost.py b/plugins/changehost.py index 1e29f3e..98a36a0 100644 --- a/plugins/changehost.py +++ b/plugins/changehost.py @@ -41,6 +41,13 @@ def _changehost(irc, target, args): return args = args.copy() + + # $host is explicitly forbidden by default because it can cause recursive + # loops when IP or real host masks are used to match a target. vHost + # updates do not affect these fields, so any further host application will + # cause the vHost to grow rapidly in size. + # That said, it is possible to get away with this expansion if you're + # careful enough, and that's why this hidden option exists. if not changehost_conf.get('force_host_expansion'): del args['host'] @@ -57,16 +64,6 @@ def _changehost(irc, target, args): # Substitute using the fields provided the hook data. This means # that the following variables are available for substitution: # $uid, $ts, $nick, $realhost, $ident, and $ip. - - # $host is explicitly forbidden by default because it can cause - # recursive loops when IP or real host masks are used to match a - # target. vHost updates do not affect these fields, so any further - # execution of 'applyhosts' will cause $host to expand again to - # the user's new host, causing the vHost to grow rapidly in size. - # That said, it is possible to get away with this expansion if - # you're careful with what you're doing, and that is why this - # hidden option exists. -GLolol - try: new_host = template.substitute(args) except KeyError as e: @@ -78,7 +75,9 @@ def _changehost(irc, target, args): if char not in allowed_chars: new_host = new_host.replace(char, '-') - irc.update_client(target, 'HOST', new_host) + # Only send a host change if something has changed + if new_host != irc.users[target].host: + irc.update_client(target, 'HOST', new_host) # Only operate on the first match. break