3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-01-11 12:42:34 +01:00

changehost: add options to match users by IP and realhost

This commit is contained in:
James Lu 2016-11-20 12:34:11 -08:00
parent 476f84a181
commit a57f194123
2 changed files with 11 additions and 1 deletions

View File

@ -423,6 +423,11 @@ changehost:
- "*!*@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.
#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:

View File

@ -30,6 +30,9 @@ def _changehost(irc, target, args):
# 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)
changehost_hosts = changehost_conf.get('hosts')
if not changehost_hosts:
log.warning("(%s) No hosts were defined in changehost::hosts; "
@ -43,7 +46,9 @@ def _changehost(irc, target, args):
log.debug('(%s) Changehost args: %s', irc.name, args)
for host_glob, host_template in changehost_hosts.items():
if irc.matchHost(host_glob, target):
log.debug('(%s) Changehost: checking mask %s', irc.name, host_glob)
if irc.matchHost(host_glob, target, ip=match_ip, realhost=match_realhosts):
log.debug('(%s) Changehost matched mask %s', irc.name, host_glob)
# This uses template strings for simple substitution:
# https://docs.python.org/3/library/string.html#template-strings
template = string.Template(host_template)