Commit a51918d2 by Sheng

Added to_ip_address to utils

parent 1e51d690
...@@ -30,10 +30,13 @@ def to_int(string): ...@@ -30,10 +30,13 @@ def to_int(string):
pass pass
def to_ip_address(ipstr):
return ipaddress.ip_address(to_str(ipstr))
def is_valid_ip_address(ipstr): def is_valid_ip_address(ipstr):
ipstr = to_str(ipstr)
try: try:
ipaddress.ip_address(ipstr) to_ip_address(ipstr)
except ValueError: except ValueError:
return False return False
return True return True
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment