-
Notifications
You must be signed in to change notification settings - Fork 40
Is<property>() methods disagree with net.IP for 4in6 addresses #183
Comments
Python 3.9.5 ipaddress (for the properties it has in common) agrees with netaddr Codeimport ipaddress
import platform
print(f"Python {platform.python_version()}")
addresses = [
"::ffff:e000:0",
"::ffff:e00f:0",
"::ffff:7f00:1",
]
attributes = [
"is_multicast",
"is_loopback",
]
for s in addresses:
ip = ipaddress.ip_address(s)
print(f"\t\t{ip}")
for attr in attributes:
result = getattr(ip, attr)
print(f"{attr}\t{result}")
|
More background research
Last updated: 2021-06-10 TODO
|
@moreati, thanks for the info! I think we want to keep all the IsFoo methods not unwrapping. The 4-in-6 handling being too aggressive in Go std's net package was one of the problems we wanted to fix with netaddr. (see the third bullet under Motivation at https://pkg.go.dev/inet.af/netaddr) But, yeah, we can document it. @danderson, @mdlayher, @josharian, sound good? |
Agreed. +1 to documenting but I still think 4-in-6 mapping is too niche for the prominence it has in the current stdlib. |
Might be useful for this issue: IsPrivate from the latest Go changelog: https://tip.golang.org/doc/go1.17 |
For IPv4 addresses mapped to IPv6 (e.g. ::ffff:127.0.0.1)
netaddr.IP
methods (e.g.IsLoopback()
) returnfalse
, butnet.IP
returnstrue
(tested with go 1.16.4).Given the goal of compatibility with net.IP this should probably be documented or fixed within this module. My presumption is fix, but I'm programmer, not a network expert.
This is one category found by #182.
https://play.golang.org/p/z2KVy-FsKmD
The text was updated successfully, but these errors were encountered: