-
Notifications
You must be signed in to change notification settings - Fork 55
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
Accept host names in announced addresses #48
Conversation
@@ -329,10 +329,12 @@ func (s *querysrv) handleAnnounce(ctx context.Context, remote net.IP, deviceID p | |||
} | |||
|
|||
ip := net.ParseIP(host) | |||
if len(ip) == 0 || ip.IsUnspecified() { | |||
uri.Host = net.JoinHostPort(remote.String(), port) | |||
if host == "" || ip.IsUnspecified() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nil ip is not unspecified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Judging by go lang source, ip.IsUnspecified
returns false
for nil ip
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, hence why the len(ip)==0 was there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But net.ParseIP(host)
returns nil
for FQDN's as well, becuase they are not IP's. The if
condition is specific for empty host names xxx://:port
and unspecified IP addresses xxx://0.0.0.0:port
. Any other value for the host part will be kept as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I think about it, tcp6://:port
and tcp6://[::]:port
addresses might not be mapped correctly to IPv6 client address with this implementation..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, it should be fine. I'll leave for @calmh to merge, looks good to me.
@st-review merge it |
GitHub-Pull-Request: syncthing/discosrv#48
Fixes #46. Now correctly maps
xxx://:port
andxxx://0.0.0.0:port
toxxx://<client remote address>:port