xenu_nntp/lib/nntp/tiny/host.py

23 lines
450 B
Python
Raw Normal View History

class Host():
@staticmethod
def is_ipv6(value: str):
return value.find(':') >= 0
@staticmethod
def is_ipv4(value: str):
parts = value.split('.')
if len(parts) > 4 or len(parts) == 0:
return False
for part in parts:
if not part.isdecimal():
return False
num = int(part)
if num > 255:
return False
return True