Skip to content
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: Failed net.LookupAddr in ipv6 wrt leading zeroes #8996

Closed
gopherbot opened this issue Oct 24, 2014 · 6 comments

Comments

Projects
None yet
6 participants
@gopherbot
Copy link

commented Oct 24, 2014

by viriketo:

IPv6 addresses may have leading zeros or not. They are optional. The address comparisons
for net.LookupAddr work by string comparison, so they may fail in case of the /etc/hosts
entry not matching exactly the LookupAddr parameter.

For example, these are equivalent addresses:
fce6:d1ad:ca44:9625:e589:3806:0248:8591
fce6:d1ad:ca44:9625:e589:3806:248:8591

The related code: http://golang.org/src/pkg/net/hosts.go
@gopherbot

This comment has been minimized.

Copy link
Author

commented Oct 24, 2014

Comment 1 by viriketo:

The same can be said of ipv4 addresses in fact. They can have leading zeroes.
@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Oct 24, 2014

Comment 2:

Labels changed: added repo-main, release-go1.5.

@gopherbot gopherbot added new labels Oct 24, 2014

@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014

@odeke-em

This comment has been minimized.

Copy link
Member

commented Feb 16, 2015

If anyone has a way to, would you mind providing some test cases in direct relation to this issue? This is because I've been looking at this and so far I have built an independent package for ip comparison. Thank you.

@nightlyone

This comment has been minimized.

Copy link
Contributor

commented Feb 16, 2015

An alternative aproach would be to look for ":0" or ".0" in the provided address and call net.ParseIP() followed by String() on it to normalize such rare cases and do the lookup with that result instead.

@odeke-em

This comment has been minimized.

Copy link
Member

commented Mar 8, 2015

Nice, thank you for that @nightlyone. For some reason, I assumed that since this hadn't been implemented in the standard library, that there were problems with the parsing itself. Turns out your approach is way simpler and cleaner.

@rsc rsc removed the repo-main label Apr 14, 2015

@gopherbot

This comment has been minimized.

Copy link
Author

commented May 21, 2015

CL https://golang.org/cl/10306 mentions this issue.

@mikioh mikioh closed this in 9378493 Jun 2, 2015

@golang golang locked and limited conversation to collaborators Jun 25, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.