Agent: strip whitespace from IP's when generating a list of ip's

This fixes a bug where get_range_object("10.0.0.0 - 10.0.0.6") doesn't work because of the whitespaces
This commit is contained in:
VakarisZ 2021-12-08 16:34:52 +02:00 committed by vakarisz
parent 23a0f74b2b
commit a0d679285c
1 changed files with 1 additions and 0 deletions

View File

@ -54,6 +54,7 @@ class NetworkRange(object, metaclass=ABCMeta):
def check_if_range(address_str): def check_if_range(address_str):
if -1 != address_str.find("-"): if -1 != address_str.find("-"):
ips = address_str.split("-") ips = address_str.split("-")
ips = [ip.strip() for ip in ips]
try: try:
ipaddress.ip_address(ips[0]) and ipaddress.ip_address(ips[1]) ipaddress.ip_address(ips[0]) and ipaddress.ip_address(ips[1])
except ValueError: except ValueError: