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

Fix: UseClientTunnelProtocol is true for all fronted meek protocols

Rod Hynes 6 лет назад
Родитель
Сommit
465f1bd17f
2 измененных файлов с 18 добавлено и 12 удалено
  1. 17 11
      psiphon/common/protocol/protocol.go
  2. 1 1
      psiphon/server/tunnelServer.go

+ 17 - 11
psiphon/common/protocol/protocol.go

@@ -183,17 +183,23 @@ func UseClientTunnelProtocol(
 	clientProtocol string,
 	serverProtocols TunnelProtocols) bool {
 
-	// When the server is running _both_ fronted HTTP and
-	// fronted HTTPS, use the client's reported tunnel
-	// protocol since some CDNs forward both to the same
-	// server port; in this case the server port is not
-	// sufficient to distinguish these protocols.
-	if (clientProtocol == TUNNEL_PROTOCOL_FRONTED_MEEK ||
-		clientProtocol == TUNNEL_PROTOCOL_FRONTED_MEEK_HTTP) &&
-		common.Contains(serverProtocols, TUNNEL_PROTOCOL_FRONTED_MEEK) &&
-		common.Contains(serverProtocols, TUNNEL_PROTOCOL_FRONTED_MEEK_HTTP) {
-
-		return true
+	// When the server is running multiple fronted protocols, and the client
+	// reports a fronted protocol, use the client's reported tunnel protocol
+	// since some CDNs forward several protocols to the same server port; in this
+	// case the server port is not sufficient to distinguish these protocols.
+
+	if !TunnelProtocolUsesFrontedMeek(clientProtocol) {
+		return false
+	}
+
+	frontedProtocolCount := 0
+	for _, protocol := range serverProtocols {
+		if TunnelProtocolUsesFrontedMeek(protocol) {
+			frontedProtocolCount += 1
+			if frontedProtocolCount > 1 {
+				return true
+			}
+		}
 	}
 
 	return false

+ 1 - 1
psiphon/server/tunnelServer.go

@@ -437,7 +437,7 @@ func (sshServer *sshServer) runListener(
 		// throttling, etc. When the tunnel protocol can be determined
 		// unambiguously from the listening port, use that protocol and
 		// don't use any client-declared value. Only use the client's
-		// value, if present, in special cases where the listenting port
+		// value, if present, in special cases where the listening port
 		// cannot distinguish the protocol.
 		tunnelProtocol := listenerTunnelProtocol
 		if clientTunnelProtocol != "" &&