def __init__(self, address: str, mask: int=32):
"""
:param address: The IP address
:param mask: this is the mask it should take for the number of hosts that you are planning to access
the mask can be a valid host mask or a valid net_mask or a num_digit slash.
host mask starts with 0 and contain either 0's and 255's
net masks start with 255 and contain either 0's and 255's
"""
try:
self.ip_address = Resolve(address)
self.__mask = mask
addr = self.ip_address + str(mask)
self.mask_addr = ipaddress.IPv4Network(addr, strict=False) if self.ip_address.version == "IPv4" else \
ipaddress.IPv6Network(addr, strict=False)
except UnResolvedException as unRes:
print(unRes.args[1])
sys.exit()
评论列表
文章目录