3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-01-24 11:14:07 +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
# 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:
- "*!*@yournet/staff/*"
#- "$account"
# 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_realhosts: false
@ -711,18 +714,16 @@ changehost:
# 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.
# Also, make sure you quote each entry so the YAML parser treats them as 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:
# Here are some examples. Note that to keep your users' details
# private, you should probably refrain from using $ip or $realhost,
# in these hostmasks, unless cloaking is already disabled.
# Here are some examples. Note that to keep your users' details 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"
"*!*@localhost": "some-server.hostname"
# Freenode-style masks are possible with this (though without the
# hashing)
# Freenode-style masks are possible with this (though without the hashing)
"*!*@bnc-server.yournet.com": "yournet/bnc-users/$ident"
"*!*@ircip?.mibbit.com": "$ident.$realhost"
"WebchatUser*!*@*": "webchat/users/$ident"

View File

@ -27,13 +27,11 @@ def _changehost(irc, target):
# We're not enabled on the network, break.
return
match_ip = changehost_conf.get('match_ip', False)
match_realhosts = changehost_conf.get('match_realhosts', False)
match_ip = irc.get_service_option('changehost', 'match_ip', default=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:
log.warning("(%s) No hosts were defined in changehost::hosts; "
"Changehost will not function correctly!", irc.name)
return
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',
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):
log.debug('(%s) Skipping host change for target %s; they are exempted by mask %s',
irc.name, target, ex)