Просмотр исходного кода

Merge branch 'master' of github.com:Psiphon-Labs/psiphon-tunnel-core

Michael Goldberger 10 лет назад
Родитель
Сommit
c9154b79d9
2 измененных файлов с 11 добавлено и 6 удалено
  1. 10 6
      psiphon/TCPConn.go
  2. 1 0
      psiphon/upstreamproxy/proxy_socks4.go

+ 10 - 6
psiphon/TCPConn.go

@@ -61,12 +61,16 @@ func makeTCPDialer(config *DialConfig) func(network, addr string) (net.Conn, err
 		if err != nil {
 			return nil, ContextError(err)
 		}
-		if config.ResolvedIPCallback != nil {
-			host, _, err := net.SplitHostPort(conn.RemoteAddr().String())
-			if err == nil {
-				config.ResolvedIPCallback(host)
-			}
-		}
+		// Note: when an upstream proxy is used, we don't know what IP address
+		// was resolved, by the proxy, for that destination.
+		if config.ResolvedIPCallback != nil && config.UpstreamProxyUrl == "" {
+			remoteAddr := conn.RemoteAddr()
+			if remoteAddr != nil {
+				host, _, err := net.SplitHostPort(conn.RemoteAddr().String())
+				if err == nil {
+					config.ResolvedIPCallback(host)
+				}
+			}		}
 		return conn, nil
 	}
 }

+ 1 - 0
psiphon/upstreamproxy/proxy_socks4.go

@@ -107,6 +107,7 @@ func (s *socks4Proxy) Dial(network, addr string) (net.Conn, error) {
 		// try to put an invalid IP into DSTIP field and
 		// append domain name terminated by '\x00' at the end of request
 		ip = net.IPv4(0, 0, 0, 1)
+		domainDest = hostStr
 	}
 	ip4 := ip.To4()
 	if ip4 == nil {