Browse Source

If ProxyURIString is empty the NewProxyDialFunc returns ForwardDialFunc

Eugene Fryntov 11 years ago
parent
commit
f2af69428e
2 changed files with 6 additions and 4 deletions
  1. 1 2
      psiphon/upstreamproxy/README.md
  2. 5 2
      psiphon/upstreamproxy/upstreamProxy.go

+ 1 - 2
psiphon/upstreamproxy/README.md

@@ -18,5 +18,4 @@ proxyDialer = NewProxyDialFunc((
             })
 ```
 
-
-
+Note: `NewProxyDialFunc` returns `ForwardDialFunc` if `ProxyURIString` is empty

+ 5 - 2
psiphon/upstreamproxy/upstreamProxy.go

@@ -1,10 +1,10 @@
 package upstreamproxy
 
 import (
+	"fmt"
 	"golang.org/x/net/proxy"
 	"net"
 	"net/url"
-        "fmt"
 )
 
 type DialFunc func(string, string) (net.Conn, error)
@@ -21,10 +21,13 @@ func (u *UpstreamProxyConfig) Dial(network, addr string) (net.Conn, error) {
 }
 
 func NewProxyDialFunc(config *UpstreamProxyConfig) DialFunc {
+	if config.ProxyURIString == "" {
+		return config.ForwardDialFunc
+	}
 	proxyURI, err := url.Parse(config.ProxyURIString)
 	if err != nil {
 		return func(network, addr string) (net.Conn, error) {
-                    return nil,  fmt.Errorf("Upstream proxy URI parsing error: %v", err)
+			return nil, fmt.Errorf("Upstream proxy URI parsing error: %v", err)
 		}
 	}