New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: apply ICANN/IANA-managed semantics to IP.IsGlobalUnicast #11772

Open
Mike-Joseph opened this Issue Jul 18, 2015 · 5 comments

Comments

Projects
None yet
4 participants
@Mike-Joseph

Mike-Joseph commented Jul 18, 2015

net.IP.IsGlobalUnicast() applies incorrect address semantics. The current implementation returns True if the address is not Unspecified, Loopback, LinkLocal, or Multicast. However, a Global Unicast address, by definition, excludes more than just those categories. Class E space is to be excluded, as is all of RFC1918 & RFC6598.

This manifests in a few significant ways:

net.ParseIP("255.255.255.255").IsGlobalUnicast() currently returns True
net.ParseIP("10.1.2.3").IsGlobalUnicast() currently returns True

I would propose the following changes:

  • Rename IsGlobalUnicast() to IsUnicast()
  • Add a check to IsUnicast() to exclude Class E and broadcast addresses
  • Create a new IsGlobalUnicast() which extends IsUnicast() by also excluding RFC1918 & RFC6598 addresses

Ideally, it would be even better to extend both further using the tables in RFC6890 as a guideline.

@Mike-Joseph Mike-Joseph changed the title from net.IP.IsGlobalUnicast to net.IP.IsGlobalUnicast applies incorrect address semantics Jul 18, 2015

@Mike-Joseph Mike-Joseph reopened this Jul 18, 2015

@Mike-Joseph Mike-Joseph changed the title from net.IP.IsGlobalUnicast applies incorrect address semantics to net.IP.IsGlobalUnicast() applies incorrect address semantics Jul 18, 2015

@bradfitz

This comment has been minimized.

Member

bradfitz commented Jul 18, 2015

/cc @mikioh

@mikioh mikioh changed the title from net.IP.IsGlobalUnicast() applies incorrect address semantics to net: IP.IsGlobalUnicast() applies incorrect address semantics Jul 21, 2015

@mikioh mikioh added this to the Unplanned milestone Jul 21, 2015

@mikioh

This comment has been minimized.

Contributor

mikioh commented Jul 21, 2015

Go 1.5 includes the fix for #11585, for the case of IPv4 limited broadcast address.

@mikioh mikioh changed the title from net: IP.IsGlobalUnicast() applies incorrect address semantics to net: apply ICANN/IANA-managed semantics to IP.IsGlobalUnicast Jul 21, 2015

@rekby

This comment has been minimized.

rekby commented Nov 23, 2016

False positive for
net.ParseIP("FC00::1").IsGlobalUnicast() currently return true
but https://tools.ietf.org/html/rfc4193 define prefix FC00::/7 as local unicast.

@mikioh

This comment has been minimized.

Contributor

mikioh commented Nov 24, 2016

@rekby,

The IsGlobalUnicast method of IP struct simply follows RFC 4291 when the IP is an IPv6 address. That means that the method just uses address type identification of https://tools.ietf.org/html/rfc4291#section-2.5.4 because it's hard to identify various IPv6 addresses without context; for example, in the case of constructing sort of IPv4-IPv6 translator applications using addresses defined in RFC 6052.

There are a few options: a) just updating documentation like "it just follows RFC 4291", b) making IsGlobalUnicast on unique local IPv6 unicast addresses return false, c) adding IsUniqueLocalUnicast method to IP, though I have no strong opinion about the latter two.

@mikioh

This comment has been minimized.

Contributor

mikioh commented Nov 24, 2016

though I have no strong opinion about the latter two.

To be honest, I'd like to see some package that provides both IPv4 and IPv6 address identification using IETF addressing architectures, IANA registries and application context as an external package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment