lib/nat, lib/connections: Fix a few issues with NAT traversal
1. For the same internal port we ask for the same external port on all devices. This can be a problem if one device speaks over two protocols. 2. Always add a nil address even if we managed to get external address of the gateway, just because the gateway might be in DMZ behind another gateway. GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3196
This commit is contained in:
@@ -137,6 +137,15 @@ func (t *tcpListener) WANAddresses() []*url.URL {
|
||||
// Does net.JoinHostPort internally
|
||||
uri.Host = addr.String()
|
||||
uris = append(uris, &uri)
|
||||
|
||||
// For every address with a specified IP, add one without an IP,
|
||||
// just in case the specified IP is still internal (router behind DMZ).
|
||||
if len(addr.IP) != 0 && !addr.IP.IsUnspecified() {
|
||||
uri = *t.uri
|
||||
addr.IP = nil
|
||||
uri.Host = addr.String()
|
||||
uris = append(uris, &uri)
|
||||
}
|
||||
}
|
||||
}
|
||||
t.mut.RUnlock()
|
||||
|
||||
Reference in New Issue
Block a user