Explorar o código

Use IPv6Synthesizer for IPv4 DNS resolver addresses

Rod Hynes %!s(int64=8) %!d(string=hai) anos
pai
achega
8585b6b068
Modificáronse 1 ficheiros con 13 adicións e 0 borrados
  1. 13 0
      psiphon/LookupIP.go

+ 13 - 0
psiphon/LookupIP.go

@@ -76,6 +76,19 @@ func bindLookupIP(host, dnsServer string, config *DialConfig) (addrs []net.IP, e
 		return nil, common.ContextError(errors.New("invalid IP address"))
 	}
 
+	// When configured, attempt to synthesize an IPv6 address from
+	// an IPv4 address for compatibility on DNS64/NAT64 networks.
+	// If synthesize fails, try the original address.
+	if config.IPv6Synthesizer != nil && ipAddr.To4() != nil {
+		synthesizedIPAddress := config.IPv6Synthesizer.IPv6Synthesize(dnsServer)
+		if synthesizedIPAddress != "" {
+			synthesizedAddr := net.ParseIP(synthesizedIPAddress)
+			if synthesizedAddr != nil {
+				ipAddr = synthesizedAddr
+			}
+		}
+	}
+
 	var ipv4 [4]byte
 	var ipv6 [16]byte
 	var domain int