3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-24 03:33:10 +01:00

changehost: add optional vHost enforcement

This commit is contained in:
James Lu 2016-11-20 11:53:55 -08:00
parent ffc271a53a
commit 501647805c
2 changed files with 25 additions and 0 deletions

View File

@ -412,6 +412,11 @@ changehost:
- 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.
#enforced_nets:
# - inspnet
# 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

@ -81,6 +81,26 @@ def handle_uid(irc, sender, command, args):
utils.add_hook(handle_uid, 'UID')
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
target = args['target']
if (not irc.isInternalClient(sender)) and (not irc.isInternalServer(sender)):
if irc.name in changehost_conf.get('enforced_nets', []):
log.debug('(%s) Enforce for network is on, re-checking host for target %s/%s',
irc.name, target, irc.getFriendlyName(target))
userdata = irc.users.get(target)
if userdata:
_changehost(irc, target, userdata.__dict__)
utils.add_hook(handle_chghost, 'CHGHOST')
@utils.add_cmd
def applyhosts(irc, sender, args):
"""[<network>]