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

Skip use of fragmentor with protocols that it may break

Rod Hynes 6 лет назад
Родитель
Сommit
4f40b494b1
2 измененных файлов с 15 добавлено и 0 удалено
  1. 5 0
      psiphon/common/fragmentor/fragmentor.go
  2. 10 0
      psiphon/common/protocol/protocol.go

+ 5 - 0
psiphon/common/fragmentor/fragmentor.go

@@ -32,6 +32,7 @@ import (
 	"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common"
 	"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/parameters"
 	"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/prng"
+	"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/protocol"
 )
 
 const (
@@ -74,6 +75,10 @@ func newConfig(
 	tunnelProtocol string,
 	seed *prng.Seed) *Config {
 
+	if !protocol.TunnelProtocolIsCompatibleWithFragmentor(tunnelProtocol) {
+		return nil
+	}
+
 	probability := parameters.FragmentorProbability
 	limitProtocols := parameters.FragmentorLimitProtocols
 	minTotalBytes := parameters.FragmentorMinTotalBytes

+ 10 - 0
psiphon/common/protocol/protocol.go

@@ -190,6 +190,16 @@ func TunnelProtocolIsResourceIntensive(protocol string) bool {
 		TunnelProtocolUsesTapdance(protocol)
 }
 
+func TunnelProtocolIsCompatibleWithFragmentor(protocol string) bool {
+	return protocol == TUNNEL_PROTOCOL_SSH ||
+		protocol == TUNNEL_PROTOCOL_OBFUSCATED_SSH ||
+		protocol == TUNNEL_PROTOCOL_UNFRONTED_MEEK ||
+		protocol == TUNNEL_PROTOCOL_UNFRONTED_MEEK_HTTPS ||
+		protocol == TUNNEL_PROTOCOL_UNFRONTED_MEEK_SESSION_TICKET ||
+		protocol == TUNNEL_PROTOCOL_FRONTED_MEEK ||
+		protocol == TUNNEL_PROTOCOL_FRONTED_MEEK_HTTP
+}
+
 func UseClientTunnelProtocol(
 	clientProtocol string,
 	serverProtocols TunnelProtocols) bool {