Skip to content

Commit

Permalink
Merge pull request Psiphon-Labs#699 from rod-hynes/master
Browse files Browse the repository at this point in the history
Skip client-side transforms.Specs validation
  • Loading branch information
rod-hynes authored Oct 28, 2024
2 parents 2aa02c9 + 4a89366 commit 87458f4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
14 changes: 14 additions & 0 deletions psiphon/common/parameters/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion psiphon/common/tactics/tactics.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const (
AGGREGATION_MINIMUM = "Minimum"
AGGREGATION_MAXIMUM = "Maximum"
AGGREGATION_MEDIAN = "Median"
PAYLOAD_CACHE_SIZE = 256
PAYLOAD_CACHE_SIZE = 1024
)

var (
Expand Down
4 changes: 1 addition & 3 deletions psiphon/server/tactics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down

0 comments on commit 87458f4

Please sign in to comment.