Detect IPv6 addresses in INI inventory

Prevents parts of the IPv6 address from being interpreted as a port
(for example, :80).

Fixes #3888
pull/4413/head
James Cammarata 11 years ago
parent f7cbf66d48
commit 948d019fef

@ -84,17 +84,21 @@ class InventoryParser(object):
continue
hostname = tokens[0]
port = C.DEFAULT_REMOTE_PORT
# Two cases to check:
# Three cases to check:
# 0. A hostname that contains a range pesudo-code and a port
# 1. A hostname that contains just a port
if (hostname.find("[") != -1 and
if hostname.count(":") > 1:
# probably an IPv6 addresss, so check for the format
# XXX:XXX::XXX.port, otherwise we'll just assume no
# port is set
if hostname.find(".") != -1:
(hostname, port) = hostname.rsplit(".", 1)
elif (hostname.find("[") != -1 and
hostname.find("]") != -1 and
hostname.find(":") != -1 and
(hostname.rindex("]") < hostname.rindex(":")) or
(hostname.find("]") == -1 and hostname.find(":") != -1)):
tokens2 = hostname.rsplit(":", 1)
hostname = tokens2[0]
port = tokens2[1]
(hostname, port) = hostname.rsplit(":", 1)
hostnames = []
if detect_range(hostname):

Loading…
Cancel
Save