3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-24 19:52:53 +01:00

changehost: add enable and enforce as network specific options.

Closes #611.
This commit is contained in:
James Lu 2019-10-10 21:10:01 -07:00
parent da67d6c42f
commit f99be51515
2 changed files with 10 additions and 13 deletions

View File

@ -685,13 +685,17 @@ changehost:
# Sets the networks where Changehost should be enabled. Please note: changehost does NOT support
# arbitrarily cloaking clients introduced by PyLink (e.g. relay clients), as doing so would make
# ban matching impossible. In these cases, it is the remote admin's job to turn on cloaking on
# their IRCd!
# their IRCd.
# You can also add to this list of enabled networks by setting "servers::<server name>::changehost_enable"
# to true.
enabled_nets:
- inspnet
- ts6net
# Sets the networks where Changehost hosts should be enforced: that is, any attempts
# by the user or other services to overwrite a host will be reverted.
# You can also add to this list of enabled networks by setting "servers::<server name>::changehost_enforce"
# to true.
#enforced_nets:
# - inspnet
@ -709,9 +713,8 @@ changehost:
#match_ip: false
#match_realhosts: false
# This sets the hostmasks that Changehost should look for. Whenever someone
# with a matching nick!user@host connects, their host will be set to the
# text defined. The following substitutions are available here:
# This sets the hostmasks that Changehost should look for. Whenever someone with a matching nick!user@host
# connects, their host will be set to the text defined. The following substitutions are available here:
# $uid, $ts (time of connection), $nick, $realhost, $ident, and $ip.
# Invalid characters in hosts are replaced with a "-".
# Also, make sure you quote each entry so the YAML parser treats them as raw strings.

View File

@ -19,11 +19,7 @@ def _changehost(irc, target):
log.debug('(%s) Skipping changehost on internal client %s', irc.name, target)
return
if not changehost_conf:
log.warning("(%s) Missing 'changehost:' configuration block; "
"Changehost will not function correctly!", irc.name)
return
elif irc.name not in changehost_conf.get('enabled_nets'):
if irc.name not in changehost_conf.get('enabled_nets') and not irc.serverdata.get('changehost_enable'):
# We're not enabled on the network, break.
return
@ -89,14 +85,12 @@ def handle_chghost(irc, sender, command, args):
"""
Handles incoming CHGHOST requests for optional host-change enforcement.
"""
changehost_conf = conf.conf.get("changehost")
if not changehost_conf:
return
changehost_conf = conf.conf.get("changehost", {})
target = args['target']
if (not irc.is_internal_client(sender)) and (not irc.is_internal_server(sender)):
if irc.name in changehost_conf.get('enforced_nets', []):
if irc.name in changehost_conf.get('enforced_nets', []) or irc.serverdata.get('changehost_enforce'):
log.debug('(%s) Enforce for network is on, re-checking host for target %s/%s',
irc.name, target, irc.get_friendly_name(target))