1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-08-08 22:36:48 +02:00

fix for older python versions that don't provide the netmask attribute when a decimal ip is used

This commit is contained in:
Kelly Brazil
2022-08-28 11:58:51 -07:00
parent 980fc77812
commit c7fc2e3b92

View File

@ -573,7 +573,12 @@ def parse(
hostmask_ipobj = ipaddress.ip_address(hostmask_string)
netmask_string = str(interface.with_netmask).split('/')[1]
# older versions of python (e.g. 3.6) don't provide netmask when a decimal IP is entered
try:
netmask_string = str(interface.netmask)
except AttributeError:
netmask_string = '255.255.255.255'
netmask_ipobj = ipaddress.ip_address(netmask_string)
bare_ip_string = str(interface.ip)