Skip to content

Commit

Permalink
minor bugfix in re
Browse files Browse the repository at this point in the history
  • Loading branch information
atheurer committed May 17, 2024
1 parent ff467f0 commit ca72fb0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion endpoints/remotehosts/remotehosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,13 +846,14 @@ def is_ip(ip_address):
Returns:
True or False
"""
print("#checking to see if ('%s') is IP" % (ip_address))
# check for IPv4
m = re.search(r"[1-9][0-9]{0,2}\.[1-9][0-9]{0,2}\.[1-9][0-9]{0,2}\.[1-9][0-9]{0,2}", ip_address)
if m:
return True

# check for IPv6
m.re.search(r"[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]", ip_address)
m = re.search(r"[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]", ip_address)
if m:
return True

Expand Down

0 comments on commit ca72fb0

Please sign in to comment.