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

Add DeviceRegion config parameter

Rod Hynes 10 лет назад
Родитель
Сommit
3cd7090692
4 измененных файлов с 15 добавлено и 0 удалено
  1. 8 0
      psiphon/config.go
  2. 1 0
      psiphon/controller.go
  3. 5 0
      psiphon/net.go
  4. 1 0
      psiphon/tunnel.go

+ 8 - 0
psiphon/config.go

@@ -281,6 +281,14 @@ type Config struct {
 	// 1-2 minutes, when the tunnel is idle. If the SSH keepalive times out, the tunnel
 	// is considered to have failed.
 	DisablePeriodicSshKeepAlive bool
+
+	// DeviceRegion is the optional, reported region the host device is running in.
+	// This input value should be a ISO 3166-1 alpha-2 country code. The device region
+	// is reported to the server in the connected request and recorded for Psiphon
+	// stats.
+	// When provided, this value may be used, pre-connection, to select performance
+	// or circumvention optimization strategies for the given region.
+	DeviceRegion string
 }
 
 // LoadConfig parses and validates a JSON format Psiphon config JSON

+ 1 - 0
psiphon/controller.go

@@ -91,6 +91,7 @@ func NewController(config *Config) (controller *Controller, err error) {
 		DnsServerGetter:               config.DnsServerGetter,
 		UseIndistinguishableTLS:       config.UseIndistinguishableTLS,
 		TrustedCACertificatesFilename: config.TrustedCACertificatesFilename,
+		DeviceRegion:                  config.DeviceRegion,
 	}
 
 	controller = &Controller{

+ 5 - 0
psiphon/net.go

@@ -83,6 +83,11 @@ type DialConfig struct {
 	// SSL_CTX_load_verify_locations.
 	// Only applies to UseIndistinguishableTLS connections.
 	TrustedCACertificatesFilename string
+
+	// DeviceRegion is the reported region the host device is running in.
+	// When set, this value may be used, pre-connection, to select performance
+	// or circumvention optimization strategies for the given region.
+	DeviceRegion string
 }
 
 // DeviceBinder defines the interface to the external BindToDevice provider

+ 1 - 0
psiphon/tunnel.go

@@ -408,6 +408,7 @@ func dialSsh(
 		DnsServerGetter:               config.DnsServerGetter,
 		UseIndistinguishableTLS:       config.UseIndistinguishableTLS,
 		TrustedCACertificatesFilename: config.TrustedCACertificatesFilename,
+		DeviceRegion:                  config.DeviceRegion,
 	}
 	if useMeek {
 		conn, err = DialMeek(serverEntry, sessionId, useMeekHttps, frontingAddress, dialConfig)