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

Exclude tactics parameters from non-CheckTactics proxy announce requests

Rod Hynes 1 год назад
Родитель
Сommit
149259b2cf
3 измененных файлов с 18 добавлено и 13 удалено
  1. 1 1
      psiphon/common/inproxy/inproxy_test.go
  2. 10 7
      psiphon/common/inproxy/proxy.go
  3. 7 5
      psiphon/controller.go

+ 1 - 1
psiphon/common/inproxy/inproxy_test.go

@@ -435,7 +435,7 @@ func runTestInproxy(doMustUpgrade bool) error {
 				return brokerClient, nil
 			},
 
-			GetBaseAPIParameters: func() (common.APIParameters, string, error) {
+			GetBaseAPIParameters: func(bool) (common.APIParameters, string, error) {
 				return baseAPIParameters, tacticsNetworkID, nil
 			},
 

+ 10 - 7
psiphon/common/inproxy/proxy.go

@@ -101,7 +101,8 @@ type ProxyConfig struct {
 	// application and build version information. GetBaseAPIParameters also
 	// returns the network ID, corresponding to the parameters, to be used in
 	// tactics logic; the network ID is not sent to the broker.
-	GetBaseAPIParameters func() (common.APIParameters, string, error)
+	GetBaseAPIParameters func(includeTacticsParameters bool) (
+		common.APIParameters, string, error)
 
 	// MakeWebRTCDialCoordinator provides a WebRTCDialCoordinator which
 	// specifies WebRTC-related dial parameters, including selected STUN
@@ -567,6 +568,10 @@ func (p *Proxy) proxyOneClient(
 
 	brokerCoordinator := brokerClient.GetBrokerDialCoordinator()
 
+	// Only the first worker, which has signalAnnounceDone configured, checks
+	// for tactics.
+	checkTactics := signalAnnounceDone != nil
+
 	// Get the base Psiphon API parameters and additional proxy metrics,
 	// including performance information, which is sent to the broker in the
 	// proxy announcment.
@@ -578,7 +583,7 @@ func (p *Proxy) proxyOneClient(
 	// with the original network ID.
 
 	metrics, tacticsNetworkID, err := p.getMetrics(
-		brokerCoordinator, webRTCCoordinator)
+		checkTactics, brokerCoordinator, webRTCCoordinator)
 	if err != nil {
 		return backOff, errors.Trace(err)
 	}
@@ -624,10 +629,6 @@ func (p *Proxy) proxyOneClient(
 	}
 	p.nextAnnounceMutex.Unlock()
 
-	// Only the first worker, which has signalAnnounceDone configured, checks
-	// for tactics.
-	checkTactics := signalAnnounceDone != nil
-
 	// A proxy ID is implicitly sent with requests; it's the proxy's session
 	// public key.
 	//
@@ -983,13 +984,15 @@ func (p *Proxy) proxyOneClient(
 }
 
 func (p *Proxy) getMetrics(
+	includeTacticsParameters bool,
 	brokerCoordinator BrokerDialCoordinator,
 	webRTCCoordinator WebRTCDialCoordinator) (*ProxyMetrics, string, error) {
 
 	// tacticsNetworkID records the exact network ID that corresponds to the
 	// tactics tag sent in the base parameters, and is used when applying any
 	// new tactics returned by the broker.
-	baseParams, tacticsNetworkID, err := p.config.GetBaseAPIParameters()
+	baseParams, tacticsNetworkID, err := p.config.GetBaseAPIParameters(
+		includeTacticsParameters)
 	if err != nil {
 		return nil, "", errors.Trace(err)
 	}

+ 7 - 5
psiphon/controller.go

@@ -3109,7 +3109,7 @@ func (controller *Controller) inproxyGetProxyBrokerClient() (*inproxy.BrokerClie
 	return brokerClient, nil
 }
 
-func (controller *Controller) inproxyGetProxyAPIParameters() (
+func (controller *Controller) inproxyGetProxyAPIParameters(includeTacticsParameters bool) (
 	common.APIParameters, string, error) {
 
 	// TODO: include broker fronting dial parameters to be logged by the
@@ -3130,10 +3130,12 @@ func (controller *Controller) inproxyGetProxyAPIParameters() (
 
 	networkID := controller.config.GetNetworkID()
 
-	err := tactics.SetTacticsAPIParameters(
-		GetTacticsStorer(controller.config), networkID, params)
-	if err != nil {
-		return nil, "", errors.Trace(err)
+	if includeTacticsParameters {
+		err := tactics.SetTacticsAPIParameters(
+			GetTacticsStorer(controller.config), networkID, params)
+		if err != nil {
+			return nil, "", errors.Trace(err)
+		}
 	}
 
 	return params, networkID, nil