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

Fix: restore ResolvedIPCallback/meek_resolved_ip_address broken in 42556e0

Rod Hynes 7 лет назад
Родитель
Сommit
603a4adaa3
1 измененных файлов с 13 добавлено и 3 удалено
  1. 13 3
      psiphon/dialParameters.go

+ 13 - 3
psiphon/dialParameters.go

@@ -502,6 +502,10 @@ func MakeDialParameters(
 		FragmentorConfig:              fragmentor.NewUpstreamConfig(p, dialParams.TunnelProtocol, dialParams.FragmentorSeed),
 	}
 
+	// Unconditionally initialize MeekResolvedIPAddress, so a valid string can
+	// always be read.
+	dialParams.MeekResolvedIPAddress.Store("")
+
 	if protocol.TunnelProtocolUsesMeek(dialParams.TunnelProtocol) {
 
 		dialParams.meekConfig = &MeekConfig{
@@ -520,14 +524,20 @@ func MakeDialParameters(
 			MeekObfuscatorPaddingSeed:     dialParams.MeekObfuscatorPaddingSeed,
 		}
 
+		// Use an asynchronous callback to record the resolved IP address when
+		// dialing a domain name. Note that DialMeek doesn't immediately
+		// establish any HTTP connections, so the resolved IP address won't be
+		// reported in all cases until after SSH traffic is relayed or a
+		// endpoint request is made over the meek connection.
+		dialParams.dialConfig.ResolvedIPCallback = func(IPAddress string) {
+			dialParams.MeekResolvedIPAddress.Store(IPAddress)
+		}
+
 		if isTactics {
 			dialParams.meekConfig.RoundTripperOnly = true
 		}
 	}
 
-	// Initialize MeekResolvedIPAddress, so a valid string can always be read.
-	dialParams.MeekResolvedIPAddress.Store("")
-
 	return dialParams, nil
 }