Merge "netutils: Explicitly require INET_ATON"
This commit is contained in:
commit
1a707b443b
@ -24,6 +24,7 @@ import socket
|
|||||||
from urllib import parse
|
from urllib import parse
|
||||||
|
|
||||||
import netaddr
|
import netaddr
|
||||||
|
from netaddr.core import INET_ATON
|
||||||
from netaddr.core import INET_PTON
|
from netaddr.core import INET_PTON
|
||||||
import netifaces
|
import netifaces
|
||||||
|
|
||||||
@ -100,7 +101,7 @@ def is_valid_ipv4(address, strict=None):
|
|||||||
(``a.b.c.d``, ``a.b.c``, ``a.b``, ``a``).
|
(``a.b.c.d``, ``a.b.c``, ``a.b``, ``a``).
|
||||||
"""
|
"""
|
||||||
if strict is not None:
|
if strict is not None:
|
||||||
flag = INET_PTON if strict else 0
|
flag = INET_PTON if strict else INET_ATON
|
||||||
try:
|
try:
|
||||||
return netaddr.valid_ipv4(address, flags=flag)
|
return netaddr.valid_ipv4(address, flags=flag)
|
||||||
except netaddr.AddrFormatError:
|
except netaddr.AddrFormatError:
|
||||||
@ -111,7 +112,7 @@ def is_valid_ipv4(address, strict=None):
|
|||||||
if netaddr.valid_ipv4(address, flags=INET_PTON):
|
if netaddr.valid_ipv4(address, flags=INET_PTON):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
if netaddr.valid_ipv4(address):
|
if netaddr.valid_ipv4(address, flags=INET_ATON):
|
||||||
LOG.warning(
|
LOG.warning(
|
||||||
'Converting in non strict mode is deprecated. '
|
'Converting in non strict mode is deprecated. '
|
||||||
'You should pass strict=False if you want to '
|
'You should pass strict=False if you want to '
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
iso8601>=0.1.11 # MIT
|
iso8601>=0.1.11 # MIT
|
||||||
oslo.i18n>=3.15.3 # Apache-2.0
|
oslo.i18n>=3.15.3 # Apache-2.0
|
||||||
pytz>=2013.6;python_version<"3.9" # MIT
|
pytz>=2013.6;python_version<"3.9" # MIT
|
||||||
netaddr>=0.7.18 # BSD
|
netaddr>=0.10.0 # BSD
|
||||||
netifaces>=0.10.4 # MIT
|
netifaces>=0.10.4 # MIT
|
||||||
debtcollector>=1.2.0 # Apache-2.0
|
debtcollector>=1.2.0 # Apache-2.0
|
||||||
pyparsing>=2.1.0 # MIT
|
pyparsing>=2.1.0 # MIT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user