mirror of
				https://github.com/jlu5/PyLink.git
				synced 2025-11-04 08:57:25 +01:00 
			
		
		
		
	changehost: add options to match users by IP and realhost
This commit is contained in:
		
							parent
							
								
									476f84a181
								
							
						
					
					
						commit
						a57f194123
					
				@ -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:
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user