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

Add diagnostic notices indicating selected fronting provider ID

- For TransferURL cases when FrontingSpecs are used
- Also add fronting metric fields to remoteServerListStatParams for psiphond logging
Rod Hynes 2 лет назад
Родитель
Сommit
b28786c905
5 измененных файлов с 67 добавлено и 11 удалено
  1. 6 1
      psiphon/feedback.go
  2. 38 7
      psiphon/net.go
  3. 6 1
      psiphon/remoteServerList.go
  4. 11 1
      psiphon/server/api.go
  5. 6 1
      psiphon/upgradeDownload.go

+ 6 - 1
psiphon/feedback.go

@@ -205,7 +205,12 @@ func SendFeedback(ctx context.Context, config *Config, diagnostics, uploadPath s
 			untunneledDialConfig,
 			uploadURL.SkipVerify,
 			config.DisableSystemRootCAs,
-			uploadURL.FrontingSpecs)
+			uploadURL.FrontingSpecs,
+			func(frontingProviderID string) {
+				NoticeInfo(
+					"SendFeedback: selected fronting provider %s for %s",
+					frontingProviderID, uploadURL.URL)
+			})
 		if err != nil {
 			return errors.Trace(err)
 		}

+ 38 - 7
psiphon/net.go

@@ -400,13 +400,29 @@ func UntunneledResolveIP(
 //
 // The context is applied to underlying TCP dials. The caller is responsible
 // for applying the context to requests made with the returned http.Client.
-func makeUntunneledFrontedHTTPClient(ctx context.Context, config *Config, untunneledDialConfig *DialConfig, frontingSpecs parameters.FrontingSpecs, skipVerify, disableSystemRootCAs bool) (*http.Client, func() common.APIParameters, error) {
-
-	frontingProviderID, meekFrontingDialAddress, meekSNIServerName, meekVerifyServerName, meekVerifyPins, meekFrontingHost, err := parameters.FrontingSpecs(frontingSpecs).SelectParameters()
+func makeUntunneledFrontedHTTPClient(
+	ctx context.Context,
+	config *Config,
+	untunneledDialConfig *DialConfig,
+	frontingSpecs parameters.FrontingSpecs,
+	selectedFrontingProviderID func(string),
+	skipVerify bool,
+	disableSystemRootCAs bool) (*http.Client, func() common.APIParameters, error) {
+
+	frontingProviderID,
+		meekFrontingDialAddress,
+		meekSNIServerName,
+		meekVerifyServerName,
+		meekVerifyPins,
+		meekFrontingHost, err := parameters.FrontingSpecs(frontingSpecs).SelectParameters()
 	if err != nil {
 		return nil, nil, errors.Trace(err)
 	}
 
+	if selectedFrontingProviderID != nil {
+		selectedFrontingProviderID(frontingProviderID)
+	}
+
 	meekDialAddress := net.JoinHostPort(meekFrontingDialAddress, "443")
 	meekHostHeader := meekFrontingHost
 
@@ -631,13 +647,21 @@ func MakeUntunneledHTTPClient(
 	untunneledDialConfig *DialConfig,
 	skipVerify bool,
 	disableSystemRootCAs bool,
-	frontingSpecs parameters.FrontingSpecs) (*http.Client, func() common.APIParameters, error) {
+	frontingSpecs parameters.FrontingSpecs,
+	selectedFrontingProviderID func(string)) (*http.Client, func() common.APIParameters, error) {
 
 	if len(frontingSpecs) > 0 {
 
 		// Ignore skipVerify because it only applies when there are no
 		// fronting specs.
-		httpClient, getParams, err := makeUntunneledFrontedHTTPClient(ctx, config, untunneledDialConfig, frontingSpecs, false, disableSystemRootCAs)
+		httpClient, getParams, err := makeUntunneledFrontedHTTPClient(
+			ctx,
+			config,
+			untunneledDialConfig,
+			frontingSpecs,
+			selectedFrontingProviderID,
+			false,
+			disableSystemRootCAs)
 		if err != nil {
 			return nil, nil, errors.Trace(err)
 		}
@@ -731,7 +755,8 @@ func MakeDownloadHTTPClient(
 	untunneledDialConfig *DialConfig,
 	skipVerify,
 	disableSystemRootCAs bool,
-	frontingSpecs parameters.FrontingSpecs) (*http.Client, bool, func() common.APIParameters, error) {
+	frontingSpecs parameters.FrontingSpecs,
+	selectedFrontingProviderID func(string)) (*http.Client, bool, func() common.APIParameters, error) {
 
 	var httpClient *http.Client
 	var getParams func() common.APIParameters
@@ -749,7 +774,13 @@ func MakeDownloadHTTPClient(
 
 	} else {
 		httpClient, getParams, err = MakeUntunneledHTTPClient(
-			ctx, config, untunneledDialConfig, skipVerify, disableSystemRootCAs, frontingSpecs)
+			ctx,
+			config,
+			untunneledDialConfig,
+			skipVerify,
+			disableSystemRootCAs,
+			frontingSpecs,
+			selectedFrontingProviderID)
 		if err != nil {
 			return nil, false, nil, errors.Trace(err)
 		}

+ 6 - 1
psiphon/remoteServerList.go

@@ -468,7 +468,12 @@ func downloadRemoteServerListFile(
 		untunneledDialConfig,
 		skipVerify,
 		disableSystemRootCAs,
-		frontingSpecs)
+		frontingSpecs,
+		func(frontingProviderID string) {
+			NoticeInfo(
+				"downloadRemoteServerListFile: selected fronting provider %s for %s",
+				frontingProviderID, sourceURL)
+		})
 	if err != nil {
 		return "", nil, errors.Trace(err)
 	}

+ 11 - 1
psiphon/server/api.go

@@ -532,7 +532,17 @@ var remoteServerListStatParams = append(
 		{"etag", isAnyString, 0},
 		{"bytes", isIntString, requestParamOptional | requestParamLogStringAsInt},
 		{"duration", isIntString, requestParamOptional | requestParamLogStringAsInt},
-		{"authenticated", isBooleanFlag, requestParamOptional | requestParamLogFlagAsBool}},
+		{"authenticated", isBooleanFlag, requestParamOptional | requestParamLogFlagAsBool},
+		{"fronting_provider_id", isAnyString, requestParamOptional},
+		{"meek_dial_address", isDialAddress, requestParamOptional | requestParamLogOnlyForFrontedMeekOrConjure},
+		{"meek_resolved_ip_address", isIPAddress, requestParamOptional | requestParamLogOnlyForFrontedMeekOrConjure},
+		{"meek_sni_server_name", isDomain, requestParamOptional},
+		{"meek_host_header", isHostHeader, requestParamOptional | requestParamNotLoggedForUnfrontedMeekNonTransformedHeader},
+		{"meek_transformed_host_name", isBooleanFlag, requestParamOptional | requestParamLogFlagAsBool},
+		{"user_agent", isAnyString, requestParamOptional},
+		{"tls_profile", isAnyString, requestParamOptional},
+		{"tls_version", isAnyString, requestParamOptional}},
+
 	baseSessionParams...)
 
 // Backwards compatibility case: legacy clients do not include these fields in

+ 6 - 1
psiphon/upgradeDownload.go

@@ -94,7 +94,12 @@ func DownloadUpgrade(
 		untunneledDialConfig,
 		downloadURL.SkipVerify,
 		config.DisableSystemRootCAs,
-		downloadURL.FrontingSpecs)
+		downloadURL.FrontingSpecs,
+		func(frontingProviderID string) {
+			NoticeInfo(
+				"DownloadUpgrade: selected fronting provider %s for %s",
+				frontingProviderID, downloadURL.URL)
+		})
 	if err != nil {
 		return errors.Trace(err)
 	}