forked from ungleich-public/cdist
ugly -> bad
This commit is contained in:
parent
8c53ce78f5
commit
e6fc74c081
4 changed files with 146 additions and 94 deletions
|
|
@ -55,3 +55,29 @@ def resolve_target_addresses(host):
|
|||
host_fqdn = ''
|
||||
|
||||
return (host, host_name, host_fqdn)
|
||||
|
||||
|
||||
# check whether addr is IPv6
|
||||
try:
|
||||
# python 3.3+
|
||||
import ipaddress
|
||||
|
||||
def is_ipv6(addr):
|
||||
try:
|
||||
return ipaddress.ip_address(addr).version == 6
|
||||
except ValueError:
|
||||
return False
|
||||
except ImportError:
|
||||
# fallback for older python versions
|
||||
def is_ipv6(addr):
|
||||
try:
|
||||
socket.inet_aton(addr)
|
||||
return False
|
||||
except socket.error:
|
||||
pass
|
||||
try:
|
||||
socket.inet_pton(socket.AF_INET6, addr)
|
||||
return True
|
||||
except socket.error:
|
||||
pass
|
||||
return False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue