Browse Source

Fix CustomTLSProfiles names validation case

Rod Hynes 6 years ago
parent
commit
51aaed8f84
2 changed files with 7 additions and 4 deletions
  1. 6 3
      psiphon/common/parameters/clientParameters.go
  2. 1 1
      psiphon/tlsDialer_test.go

+ 6 - 3
psiphon/common/parameters/clientParameters.go

@@ -584,11 +584,14 @@ func (p *ClientParameters) Set(
 	var customTLSProfileNames []string
 
 	customTLSProfilesValue := parameters[CustomTLSProfiles]
-	for i := 0; i < len(applyParameters); i++ {
-		customTLSProfilesValue = applyParameters[i][CustomTLSProfiles]
+	for i := len(applyParameters) - 1; i >= 0; i++ {
+		if v := applyParameters[i][CustomTLSProfiles]; v != nil {
+			customTLSProfilesValue = v
+			break
+		}
 	}
 	if customTLSProfiles, ok := customTLSProfilesValue.(protocol.CustomTLSProfiles); ok {
-		customTLSProfileNames := make([]string, len(customTLSProfiles))
+		customTLSProfileNames = make([]string, len(customTLSProfiles))
 		for i := 0; i < len(customTLSProfiles); i++ {
 			customTLSProfileNames[i] = customTLSProfiles[i].Name
 		}

+ 1 - 1
psiphon/tlsDialer_test.go

@@ -296,7 +296,7 @@ func TestSelectTLSProfile(t *testing.T) {
 
 	frontingProviderID := "frontingProviderID"
 
-	clientParameters = makeCustomTLSProfilesClientParameters(t, true, frontingProviderID)
+	clientParameters = makeCustomTLSProfilesClientParameters(t, false, frontingProviderID)
 	disableTLSProfiles := clientParameters.Get().LabeledTLSProfiles(
 		parameters.DisableFrontingProviderTLSProfiles, frontingProviderID)