3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-27 21:19:31 +01:00

Fix wrong logging for CIDR ranges in match_host

(cherry picked from commit 761d3ef500)
This commit is contained in:
James Lu 2017-08-15 21:26:18 -07:00
parent 90884924a8
commit d1f8358159

View File

@ -1220,18 +1220,16 @@ class Irc(utils.DeprecatedAttributesObject):
# HACK: support CIDR hosts in the hosts portion
try:
header, cidrtarget = glob.split('@', 1)
log.debug('(%s) Processing CIDRs for %s (full host: %s)', self.name,
cidrtarget, glob)
# Try to parse the host portion as a CIDR range
network = ipaddress.ip_network(cidrtarget)
log.debug('(%s) Found CIDR for %s, replacing target host with IP %s', self.name,
realhost, target)
real_ip = self.users[target].ip
if ipaddress.ip_address(real_ip) in network:
# If the CIDR matches, hack around the host matcher by pretending that
# the lookup target was the IP and not the CIDR range!
glob = '@'.join((header, real_ip))
log.debug('(%s) Found matching CIDR %s for %s, replacing target host with IP %s', self.name,
cidrtarget, target, real_ip)
except ValueError:
pass