Merge "netutils: Explicitly require INET_ATON"

This commit is contained in:
Zuul 2024-06-14 03:46:52 +00:00 committed by Gerrit Code Review
commit 1a707b443b
2 changed files with 4 additions and 3 deletions

View File

@ -24,6 +24,7 @@ import socket
from urllib import parse
import netaddr
from netaddr.core import INET_ATON
from netaddr.core import INET_PTON
import netifaces
@ -100,7 +101,7 @@ def is_valid_ipv4(address, strict=None):
(``a.b.c.d``, ``a.b.c``, ``a.b``, ``a``).
"""
if strict is not None:
flag = INET_PTON if strict else 0
flag = INET_PTON if strict else INET_ATON
try:
return netaddr.valid_ipv4(address, flags=flag)
except netaddr.AddrFormatError:
@ -111,7 +112,7 @@ def is_valid_ipv4(address, strict=None):
if netaddr.valid_ipv4(address, flags=INET_PTON):
return True
else:
if netaddr.valid_ipv4(address):
if netaddr.valid_ipv4(address, flags=INET_ATON):
LOG.warning(
'Converting in non strict mode is deprecated. '
'You should pass strict=False if you want to '

View File

@ -6,7 +6,7 @@
iso8601>=0.1.11 # MIT
oslo.i18n>=3.15.3 # Apache-2.0
pytz>=2013.6;python_version<"3.9" # MIT
netaddr>=0.7.18 # BSD
netaddr>=0.10.0 # BSD
netifaces>=0.10.4 # MIT
debtcollector>=1.2.0 # Apache-2.0
pyparsing>=2.1.0 # MIT