From ac831444cea3232f2a36ce954a81ea3650fef7ad Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Sun, 28 Aug 2022 11:40:53 -0700 Subject: [PATCH] fix for older python versions that don't handle decimal ip's cleanly --- jc/parsers/ip_address.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/jc/parsers/ip_address.py b/jc/parsers/ip_address.py index e470d08e..7789e552 100644 --- a/jc/parsers/ip_address.py +++ b/jc/parsers/ip_address.py @@ -468,7 +468,7 @@ import jc.utils class info(): """Provides parser metadata (version, author, etc.)""" - version = '1.0' + version = '1.1' description = 'IPv4 and IPv6 Address string parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' @@ -565,7 +565,12 @@ def parse( broadcast_string = str(network.broadcast_address) broadcast_ipobj = ipaddress.ip_address(broadcast_string) - hostmask_string = str(interface.with_hostmask).split('/')[1] + # older versions of python (e.g. 3.6) don't provide hostmask when a decimal IP is entered + try: + hostmask_string = str(interface.hostmask) + except AttributeError: + hostmask_string = '0.0.0.0' + hostmask_ipobj = ipaddress.ip_address(hostmask_string) netmask_string = str(interface.with_netmask).split('/')[1]