From f99be51515f1235856f433c77909e47f024b9b8a Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 10 Oct 2019 21:10:01 -0700 Subject: [PATCH] changehost: add enable and enforce as network specific options. Closes #611. --- example-conf.yml | 11 +++++++---- plugins/changehost.py | 12 +++--------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/example-conf.yml b/example-conf.yml index 401a240..a395986 100644 --- a/example-conf.yml +++ b/example-conf.yml @@ -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::::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::::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. diff --git a/plugins/changehost.py b/plugins/changehost.py index 2b8a604..c429d68 100644 --- a/plugins/changehost.py +++ b/plugins/changehost.py @@ -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))