mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-28 13:42:37 +01:00
changehost: only send a host change if new host != original
(cherry picked from commit 13be40e08b
)
This commit is contained in:
parent
81bf6480df
commit
c7e4c05cbd
@ -41,6 +41,13 @@ def _changehost(irc, target, args):
|
|||||||
return
|
return
|
||||||
|
|
||||||
args = args.copy()
|
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'):
|
if not changehost_conf.get('force_host_expansion'):
|
||||||
del args['host']
|
del args['host']
|
||||||
|
|
||||||
@ -57,16 +64,6 @@ def _changehost(irc, target, args):
|
|||||||
# Substitute using the fields provided the hook data. This means
|
# Substitute using the fields provided the hook data. This means
|
||||||
# that the following variables are available for substitution:
|
# that the following variables are available for substitution:
|
||||||
# $uid, $ts, $nick, $realhost, $ident, and $ip.
|
# $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:
|
try:
|
||||||
new_host = template.substitute(args)
|
new_host = template.substitute(args)
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
@ -78,6 +75,8 @@ def _changehost(irc, target, args):
|
|||||||
if char not in allowed_chars:
|
if char not in allowed_chars:
|
||||||
new_host = new_host.replace(char, '-')
|
new_host = new_host.replace(char, '-')
|
||||||
|
|
||||||
|
# Only send a host change if something has changed
|
||||||
|
if new_host != irc.users[target].host:
|
||||||
irc.update_client(target, 'HOST', new_host)
|
irc.update_client(target, 'HOST', new_host)
|
||||||
|
|
||||||
# Only operate on the first match.
|
# Only operate on the first match.
|
||||||
|
Loading…
Reference in New Issue
Block a user