mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-22 22:58:25 +00:00
Don't resolve destination address until we need to (fixes #2671)
This commit is contained in:
parent
bc2ed60b92
commit
576c365753
@ -23,6 +23,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func tcpDialer(uri *url.URL, tlsCfg *tls.Config) (*tls.Conn, error) {
|
func tcpDialer(uri *url.URL, tlsCfg *tls.Config) (*tls.Conn, error) {
|
||||||
|
// Check that there is a port number in uri.Host, otherwise add one.
|
||||||
host, port, err := net.SplitHostPort(uri.Host)
|
host, port, err := net.SplitHostPort(uri.Host)
|
||||||
if err != nil && strings.HasPrefix(err.Error(), "missing port") {
|
if err != nil && strings.HasPrefix(err.Error(), "missing port") {
|
||||||
// addr is on the form "1.2.3.4"
|
// addr is on the form "1.2.3.4"
|
||||||
@ -32,13 +33,9 @@ func tcpDialer(uri *url.URL, tlsCfg *tls.Config) (*tls.Conn, error) {
|
|||||||
uri.Host = net.JoinHostPort(host, "22000")
|
uri.Host = net.JoinHostPort(host, "22000")
|
||||||
}
|
}
|
||||||
|
|
||||||
raddr, err := net.ResolveTCPAddr("tcp", uri.Host)
|
// Don't try to resolve the address before dialing. The dialer may be a
|
||||||
if err != nil {
|
// proxy, and we should let the proxy do the resolving in that case.
|
||||||
l.Debugln(err)
|
conn, err := dialer.Dial("tcp", uri.Host)
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
conn, err := dialer.Dial(raddr.Network(), raddr.String())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Debugln(err)
|
l.Debugln(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user