Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions libcloud/compute/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
import os
import socket
import binascii
import platform

from libcloud.utils.py3 import b
from libcloud.utils.py3 import b, PY2

import libcloud.compute.ssh
from libcloud.pricing import get_size_price
Expand Down Expand Up @@ -1294,10 +1295,19 @@ def is_supported(address):
"""
Return True for supported address.
"""
if force_ipv4 and not is_valid_ip_address(address=address,
family=socket.AF_INET):
return False
return True
if PY2 and os.name == 'nt' and platform.python_implementation() == 'CPython':
# Addressing non-backported fix, reported/patched: https://bugs.python.org/issue7171
if force_ipv4:
try:
socket.inet_aton(address)
except socket.error:
return False
return True
else:
raise NotImplementedError('IPv6 address validation unsupported on Windows CPython 2')

return is_valid_ip_address(address=address,
family=socket.AF_INET if force_ipv4 else socket.AF_INET6)

def filter_addresses(addresses):
"""
Expand Down
2 changes: 0 additions & 2 deletions libcloud/utils/py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@
PY2_pre_279 = PY2 and sys.version_info < (2, 7, 9)
PY3_pre_32 = PY3 and sys.version_info < (3, 2)

PY2 = False
PY25 = False
PY26 = False
PY27 = False
PY3 = False
PY32 = False

if sys.version_info >= (2, 0) and sys.version_info < (3, 0):
Expand Down