Browse Source

Merge pull request #699 from rod-hynes/master

Skip client-side transforms.Specs validation
Rod Hynes 1 year ago
parent
commit
87458f4502

+ 14 - 0
psiphon/common/parameters/parameters.go

@@ -1239,6 +1239,15 @@ func (p *Parameters) Set(
 	}
 	inproxyAllCommonCompartmentIDs, _ := inproxyAllCommonCompartmentIDsValue.([]string)
 
+	// Special case: skip validation of transforms.Specs on the client side,
+	// since the regen operations may be slow. transforms.Specs are still
+	// validated on the server side, before being sent to clients. If a
+	// client's transforms.Spec is somehow corrupted, the tunnel dial
+	// applying the transform will error out -- transforms.Specs.Validate
+	// simply invokes the same apply operations.
+
+	validateTransformSpecs := serverSide
+
 	for i := 0; i < len(applyParameters); i++ {
 
 		count := 0
@@ -1431,6 +1440,11 @@ func (p *Parameters) Set(
 					return nil, errors.Trace(err)
 				}
 			case transforms.Specs:
+
+				if !validateTransformSpecs {
+					break
+				}
+
 				prefixMode := false
 				if name == OSSHPrefixSpecs || name == ServerOSSHPrefixSpecs {
 					prefixMode = true

+ 1 - 1
psiphon/common/tactics/tactics.go

@@ -191,7 +191,7 @@ const (
 	AGGREGATION_MINIMUM                = "Minimum"
 	AGGREGATION_MAXIMUM                = "Maximum"
 	AGGREGATION_MEDIAN                 = "Median"
-	PAYLOAD_CACHE_SIZE                 = 256
+	PAYLOAD_CACHE_SIZE                 = 1024
 )
 
 var (

+ 1 - 3
psiphon/server/tactics.go

@@ -136,7 +136,7 @@ func (c *ServerTacticsParametersCache) Get(
 	// Construct parameters from tactics.
 
 	// Note: since ServerTacticsParametersCache was implemented,
-	// tactics.Server.cachedTacticsData was added. This new cache is
+	// tactics.Server.cachedTacticsData was added. That new cache is
 	// primarily intended to reduce server allocations and computations
 	// when _clients_ request tactics. cachedTacticsData also impacts
 	// GetTacticsWithTag.
@@ -157,8 +157,6 @@ func (c *ServerTacticsParametersCache) Get(
 		return nilAccessor, nil
 	}
 
-	// Tactics.Probability is ignored for server-side tactics.
-
 	params, err := parameters.NewParameters(nil)
 	if err != nil {
 		return nilAccessor, errors.Trace(err)