cmd/discosrv: Accept host names in announced addresses

GitHub-Pull-Request: https://github.com/syncthing/discosrv/pull/48
This commit is contained in:
Majed Abdulaziz 2016-05-27 14:14:27 +00:00 committed by Jakob Borg
parent ff0cd413e6
commit b1205db7ac

View File

@ -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() {
host = remote.String()
}
uri.Host = net.JoinHostPort(host, port)
if err := s.updateAddress(ctx, tx, deviceID, uri.String()); err != nil {
internalErr = err
return