# coding:utf-8
class Ipv6:
def __init__(self):
pass
def get_end_ipv6_with_mask(self, ipv6, mask):
start_ipv6 = self.ipv6_2_dec(ipv6)
return start_ipv6 + 2 ** (128 - int(mask)) - 1
def ipv6_2_dec(self, ipv6):
has_compress = ipv6.find('::') > -1
has_ipv4 = ipv6.find('.') > -1
if not has_compress and not has_ipv4:
return self._ipv6_2_dec_without_compress(ipv6)
elif has_compress and not has_ipv4:
return self._ipv6_2_dec_with_compress(ipv6)
elif not has_compress and has_ipv4:
ipv4, ipv6 = self._split_ipv4_ipv6(ipv6)
return self._ipv4_2_dec(ipv4) + self._ipv6_2_dec_without_compress(ipv6)
ipv4, ipv6 = self._split_ipv4_ipv6(ipv6)
return self._ipv4_2_dec(ipv4) + self._ipv6_2_dec_with_compress(ipv6)
@staticmethod
def _ipv4_2_dec(ip):
dec_value &#