3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-01-24 19:24:13 +01:00

changehost: port most options to get_service_option(s) (#611, #642)

This commit is contained in:
James Lu 2019-10-10 20:57:51 -07:00
parent 1623462b73
commit da67d6c42f
2 changed files with 14 additions and 15 deletions

View File

@ -697,12 +697,15 @@ changehost:
# Sets the masks that Changehost enforcement should ignore: these can be users with certain # Sets the masks that Changehost enforcement should ignore: these can be users with certain
# hosts, exttargets, etc. # hosts, exttargets, etc.
# Since PyLink 2.1, you can also add to this list on a per-network basis by adding options under
# "servers::<server name>::changehost_enforce_exceptions".
enforce_exceptions: enforce_exceptions:
- "*!*@yournet/staff/*" - "*!*@yournet/staff/*"
#- "$account" #- "$account"
# Determines whether Changehost rules should also match the host portion of a mask by IP and # Determines whether Changehost rules should also match the host portion of a mask by IP and
# real hosts. These default to false. # real hosts. These default to false. You can override these on a per-network basis by setting
# "servers::<server name>::changehost_match_ip" or "servers::<server name>::changehost_match_realhosts".
#match_ip: false #match_ip: false
#match_realhosts: false #match_realhosts: false
@ -711,18 +714,16 @@ changehost:
# text defined. The following substitutions are available here: # text defined. The following substitutions are available here:
# $uid, $ts (time of connection), $nick, $realhost, $ident, and $ip. # $uid, $ts (time of connection), $nick, $realhost, $ident, and $ip.
# Invalid characters in hosts are replaced with a "-". # Invalid characters in hosts are replaced with a "-".
# Also, make sure you quote each entry so the YAML parser treats them as # Also, make sure you quote each entry so the YAML parser treats them as raw strings.
# raw strings. # Since PyLink 2.1, you can also add to this list on a per-network basis by adding options under
# "servers::<server name>::changehost_hosts".
hosts: hosts:
# Here are some examples. Note that to keep your users' details private, you should probably refrain
# Here are some examples. Note that to keep your users' details # from using $ip or $realhost, in these hostmasks, unless cloaking is already disabled.
# private, you should probably refrain from using $ip or $realhost,
# in these hostmasks, unless cloaking is already disabled.
"*!yourname@*.yournet.com": "$nick.opers.yournet.com" "*!yourname@*.yournet.com": "$nick.opers.yournet.com"
"*!*@localhost": "some-server.hostname" "*!*@localhost": "some-server.hostname"
# Freenode-style masks are possible with this (though without the # Freenode-style masks are possible with this (though without the hashing)
# hashing)
"*!*@bnc-server.yournet.com": "yournet/bnc-users/$ident" "*!*@bnc-server.yournet.com": "yournet/bnc-users/$ident"
"*!*@ircip?.mibbit.com": "$ident.$realhost" "*!*@ircip?.mibbit.com": "$ident.$realhost"
"WebchatUser*!*@*": "webchat/users/$ident" "WebchatUser*!*@*": "webchat/users/$ident"

View File

@ -27,13 +27,11 @@ def _changehost(irc, target):
# We're not enabled on the network, break. # We're not enabled on the network, break.
return return
match_ip = changehost_conf.get('match_ip', False) match_ip = irc.get_service_option('changehost', 'match_ip', default=False)
match_realhosts = changehost_conf.get('match_realhosts', False) match_realhosts = irc.get_service_option('changehost', 'match_realhosts', default=False)
changehost_hosts = changehost_conf.get('hosts') changehost_hosts = irc.get_service_options('changehost', 'hosts', dict)
if not changehost_hosts: if not changehost_hosts:
log.warning("(%s) No hosts were defined in changehost::hosts; "
"Changehost will not function correctly!", irc.name)
return return
args = irc.users[target].get_fields() args = irc.users[target].get_fields()
@ -102,7 +100,7 @@ def handle_chghost(irc, sender, command, args):
log.debug('(%s) Enforce for network is on, re-checking host for target %s/%s', log.debug('(%s) Enforce for network is on, re-checking host for target %s/%s',
irc.name, target, irc.get_friendly_name(target)) irc.name, target, irc.get_friendly_name(target))
for ex in changehost_conf.get("enforce_exceptions", []): for ex in irc.get_service_options("changehost", "enforce_exceptions", list):
if irc.match_host(ex, target): if irc.match_host(ex, target):
log.debug('(%s) Skipping host change for target %s; they are exempted by mask %s', log.debug('(%s) Skipping host change for target %s; they are exempted by mask %s',
irc.name, target, ex) irc.name, target, ex)