我注意到使用 IPv6 时 netaddr 中 IPRange 的 cidrs() 方法存在问题。
如果我定义较小的 IPv6 范围,它可以正常工作:
r1=IPRange('1fe::2','1fe::100')
r1.cidrs()
[IPNetwork('1fe::2/127'), IPNetwork('1fe::4/126'), IPNetwork('1fe::8/125'), IPNetwork('1fe::10/124'), IPNetwork('1fe::20/123'), IPNetwork('1fe::40/122'), IPNetwork('1fe::80/121'), IPNetwork('1fe::100/128')]
如果我定义一个大范围集,我会收到一个回溯:
r1=IPRange('1fe::2','2fe::1')
r1.cidrs()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/netaddr/ip/__init__.py", line 1337,
in cidrs
return iprange_to_cidrs(self._start, self._end)
File "/usr/lib/python2.7/dist-packages/netaddr/ip/__init__.py", line 1798,
in iprange_to_cidrs
cidr_remainder = cidr_exclude(cidr_list.pop(), ip)
IndexError: pop from empty list
有谁知道这是否是 cidrs() 的限制或错误?
最佳答案
关于python - IPRange IPv6 和 cidrs(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43745046/