python - IPRange IPv6 和 cidrs()

标签 python ipv6

我注意到使用 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() 的限制或错误?

最佳答案

这是一个 bug在 netaddr 的 0.7.10 版本中,该问题已在版本 0.7.11 中修复。对于您的示例中的 IP 范围,所有后续版本似乎都按预期工作。

关于python - IPRange IPv6 和 cidrs(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43745046/

相关文章:

python - ipv6 dns 名称无法从 ipv4 网络解析

python - 如何在SQLAlchemy子查询中指定FROM表?

python - 在 Python 3.4 中生成具有重复项的随机数的随机列表

python - 如何查找文件/字符串中字符串之间的字符串数 - python

api - 如何将 IPv6 地址添加到 Google API 凭据?

python - 在 Python 中发送和接收 IPv6 链路本地多播 UDP 数据报?

perl - 想要在 Perl 中通过 IPv6 链接本地 IP 发送 UDP 数据包

python - Django 选择不同的字段不起作用

python - Pandas 重新映射到列中的范围

java - 创建 IPv6 header