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

Refactor: prefix Controller ClientSessionCache with associated protocol

Amir Khan 1 год назад
Родитель
Сommit
412bc77322
2 измененных файлов с 11 добавлено и 9 удалено
  1. 6 4
      psiphon/common/tlsCache.go
  2. 5 5
      psiphon/controller.go

+ 6 - 4
psiphon/common/tlsCache.go

@@ -34,8 +34,9 @@ type TLSClientSessionCacheWrapper struct {
 	sessionKey string
 }
 
-// WrapClientSessionCache wraps a tls.ClientSessionCache with a hard-coded key
-// derived from the ipAddress and dialPortNumber.
+// WrapClientSessionCache wraps a tls.ClientSessionCache with an alternative
+// key, ignoring the SNI-based key that crypto/tls passes to Put/Get, which
+// may be incompatible with SNI obfuscation transforms.
 func WrapClientSessionCache(
 	cache tls.ClientSessionCache,
 	hardCodedSessionKey string,
@@ -75,8 +76,9 @@ type UtlsClientSessionCacheWrapper struct {
 	sessionKey string
 }
 
-// WrapUtlsClientSessionCache wraps a utls.ClientSessionCache with a hard-coded key
-// derived from the ipAddress and dialPortNumber.
+// WrapUtlsClientSessionCache wraps a utls.ClientSessionCache with an alternative
+// key, ignoring the SNI-based key that crypto/tls passes to Put/Get, which
+// may be incompatible with SNI obfuscation transforms.
 func WrapUtlsClientSessionCache(
 	cache utls.ClientSessionCache,
 	hardCodedSessionKey string,

+ 5 - 5
psiphon/controller.go

@@ -93,8 +93,8 @@ type Controller struct {
 	staggerMutex                            sync.Mutex
 	resolver                                *resolver.Resolver
 	steeringIPCache                         *lrucache.Cache
-	tlsClientSessionCache                   tls.ClientSessionCache
-	utlsClientSessionCache                  utls.ClientSessionCache
+	tlsClientSessionCache                   utls.ClientSessionCache
+	quicTLSClientSessionCache               tls.ClientSessionCache
 	inproxyProxyBrokerClientManager         *InproxyBrokerClientManager
 	inproxyClientBrokerClientManager        *InproxyBrokerClientManager
 	inproxyNATStateManager                  *InproxyNATStateManager
@@ -170,8 +170,8 @@ func NewController(config *Config) (controller *Controller, err error) {
 			1*time.Minute,
 			steeringIPCacheMaxEntries),
 
-		tlsClientSessionCache:  tls.NewLRUClientSessionCache(0),
-		utlsClientSessionCache: utls.NewLRUClientSessionCache(0),
+		tlsClientSessionCache:     utls.NewLRUClientSessionCache(0),
+		quicTLSClientSessionCache: tls.NewLRUClientSessionCache(0),
 	}
 
 	// Initialize untunneledDialConfig, used by untunneled dials including
@@ -2344,8 +2344,8 @@ loop:
 		dialParams, err := MakeDialParameters(
 			controller.config,
 			controller.steeringIPCache,
+			controller.quicTLSClientSessionCache,
 			controller.tlsClientSessionCache,
-			controller.utlsClientSessionCache,
 			upstreamProxyErrorCallback,
 			canReplay,
 			selectProtocol,