diff options
author | Audrius Butkevicius <audrius.butkevicius@gmail.com> | 2016-04-24 16:30:20 +0000 |
---|---|---|
committer | Jakob Borg <jakob@nym.se> | 2016-04-24 16:30:20 +0000 |
commit | 2467678bd4f2aa0fecd18ba1bd3df4ae867c627a (patch) | |
tree | 5fc3ef956d49811b276e6469c12ef1869d4d16a0 | |
parent | e87c1abd4e4391a450681b75be08f10ff9ce6869 (diff) |
lib/dialer: Add env var to disable proxy fallback (fixes #3006)
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3009
-rw-r--r-- | lib/dialer/internal.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/dialer/internal.go b/lib/dialer/internal.go index 1678187384..9cf071fbf9 100644 --- a/lib/dialer/internal.go +++ b/lib/dialer/internal.go @@ -23,6 +23,7 @@ var ( l = logger.DefaultLogger.NewFacility("dialer", "Dialing connections") proxyDialer = getDialer(proxy.Direct) usingProxy = proxyDialer != proxy.Direct + noFallback = os.Getenv("ALL_PROXY_NO_FALLBACK") != "" ) type dialFunc func(network, addr string) (net.Conn, error) @@ -40,6 +41,9 @@ func init() { go func() { time.Sleep(500 * time.Millisecond) l.Infoln("Proxy settings detected") + if noFallback { + l.Infoln("Proxy fallback disabled") + } }() } else { go func() { @@ -62,6 +66,10 @@ func dialWithFallback(proxyDialFunc dialFunc, fallbackDialFunc dialFunc, network } l.Debugf("Dialing %s address %s via proxy - error %s", network, addr, err) + if noFallback { + return conn, err + } + conn, err = fallbackDialFunc(network, addr) if err == nil { l.Debugf("Dialing %s address %s via fallback - success, %s -> %s", network, addr, conn.LocalAddr(), conn.RemoteAddr()) |