Răsfoiți Sursa

Support enabling tactics in ConsoleClient

Rod Hynes 7 ani în urmă
părinte
comite
39295606b7
2 a modificat fișierele cu 25 adăugiri și 0 ștergeri
  1. 18 0
      ConsoleClient/main.go
  2. 7 0
      psiphon/config.go

+ 18 - 0
ConsoleClient/main.go

@@ -272,6 +272,16 @@ func main() {
 		defer tunDeviceFile.Close()
 		defer tunDeviceFile.Close()
 	}
 	}
 
 
+	// Enable tactics when a NetworkID is specified
+	//
+	// Limitation: unlike psi.NetworkIDGetter, which calls back to platform
+	// APIs, this method of network identification is not dynamic and will not
+	// reflect network changes that occur while running.
+
+	if config.NetworkID != "" {
+		config.NetworkIDGetter = &networkGetter{networkID: config.NetworkID}
+	}
+
 	// Run Psiphon
 	// Run Psiphon
 
 
 	controller, err := psiphon.NewController(config)
 	controller, err := psiphon.NewController(config)
@@ -351,3 +361,11 @@ func (p *tunProvider) GetPrimaryDnsServer() string {
 func (p *tunProvider) GetSecondaryDnsServer() string {
 func (p *tunProvider) GetSecondaryDnsServer() string {
 	return p.secondaryDNS
 	return p.secondaryDNS
 }
 }
+
+type networkGetter struct {
+	networkID string
+}
+
+func (n *networkGetter) GetNetworkID() string {
+	return n.networkID
+}

+ 7 - 0
psiphon/config.go

@@ -226,6 +226,13 @@ type Config struct {
 	// This parameter is only applicable to library deployments.
 	// This parameter is only applicable to library deployments.
 	NetworkIDGetter NetworkIDGetter
 	NetworkIDGetter NetworkIDGetter
 
 
+	// NetworkID, when specified, is used as the identifier for the host's
+	// current active network.
+	//
+	// This parameter is only applicable to non-library deployments which
+	// do not use NetworkIDGetter.
+	NetworkID string
+
 	// DisableTactics disables tactics operations including requests, payload
 	// DisableTactics disables tactics operations including requests, payload
 	// handling, and application of parameters.
 	// handling, and application of parameters.
 	DisableTactics bool
 	DisableTactics bool