lib/connections: Try TCP punchthrough (fixes #4259) (#5753)

This commit is contained in:
Audrius Butkevicius
2020-06-16 09:17:07 +02:00
committed by GitHub
parent d09c8f0d0a
commit f619a7f4cc
14 changed files with 288 additions and 150 deletions
+6
View File
@@ -13,6 +13,7 @@ import (
"os"
"time"
"github.com/syncthing/syncthing/lib/util"
"golang.org/x/net/proxy"
)
@@ -60,6 +61,11 @@ func socksDialerFunction(u *url.URL, forward proxy.Dialer) (proxy.Dialer, error)
return proxy.SOCKS5("tcp", u.Host, auth, forward)
}
// Sort available addresses, preferring unspecified address.
func tcpAddrLess(i interface{}, j interface{}) bool {
return util.AddressUnspecifiedLess(i.(*net.TCPAddr), j.(*net.TCPAddr))
}
// dialerConn is needed because proxy dialed connections have RemoteAddr() pointing at the proxy,
// which then screws up various things such as IsLAN checks, and "let's populate the relay invitation address from
// existing connection" shenanigans.