Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions ipcalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ def __init__(self, ip, mask=None, version=0):
self.mask = (limit - count)
else:
raise ValueError('Invalid netmask')

#hard fix https://github.com/tehmaze/ipcalc/issues/67
if self.v != 6 and (len(self.dq) > 15 or ':' in self.dq):
self.v = 6

# Validate subnet size
if self.v == 6:
self.dq = self._itodq(self.ip)
Expand Down Expand Up @@ -291,9 +296,12 @@ def _dqtoi_ipv6(self, dq):
hx.insert(ix, '0')
elif dq.endswith('::'):
pass
elif '' in hx:
raise ValueError('%s: IPv6 address invalid: '
'compressed format detected in full notation' % dq)

# hide to fix https://github.com/tehmaze/ipcalc/issues/68
# elif '' in hx:
# raise ValueError('%s: IPv6 address invalid: '
# 'compressed format detected in full notation' % dq)

ip = ''
hx = [x == '' and '0' or x for x in hx]
for h in hx:
Expand Down