Ver Fonte

Skip replay for unknown GeoIP

Rod Hynes há 5 anos atrás
pai
commit
f453caaad5

+ 2 - 0
psiphon/common/parameters/parameters.go

@@ -252,6 +252,7 @@ const (
 	FeedbackUploadTimeoutSeconds                     = "FeedbackUploadTimeoutSeconds"
 	ServerReplayPacketManipulation                   = "ServerReplayPacketManipulation"
 	ServerReplayFragmentor                           = "ServerReplayFragmentor"
+	ServerReplayUnknownGeoIP                         = "ServerReplayUnknownGeoIP"
 	ServerReplayTTL                                  = "ServerReplayTTL"
 	ServerReplayTargetWaitDuration                   = "ServerReplayTargetWaitDuration"
 	ServerReplayTargetTunnelDuration                 = "ServerReplayTargetTunnelDuration"
@@ -537,6 +538,7 @@ var defaultParameters = map[string]struct {
 
 	ServerReplayPacketManipulation:    {value: true, flags: serverSideOnly},
 	ServerReplayFragmentor:            {value: true, flags: serverSideOnly},
+	ServerReplayUnknownGeoIP:          {value: false, flags: serverSideOnly},
 	ServerReplayTTL:                   {value: time.Duration(0), minimum: time.Duration(0), flags: serverSideOnly},
 	ServerReplayTargetWaitDuration:    {value: time.Duration(0), minimum: time.Duration(0), flags: serverSideOnly},
 	ServerReplayTargetTunnelDuration:  {value: time.Duration(0), minimum: time.Duration(0), flags: serverSideOnly},

+ 8 - 0
psiphon/server/replay.go

@@ -135,6 +135,14 @@ func (r *ReplayCache) GetReplayTargetDuration(
 		return false, 0, 0
 	}
 
+	if !p.Bool(parameters.ServerReplayUnknownGeoIP) &&
+		geoIPData.Country == GEOIP_UNKNOWN_VALUE &&
+		geoIPData.ISP == GEOIP_UNKNOWN_VALUE {
+		// Unless configured otherwise, skip replay for unknown GeoIP, since clients
+		// may not have equivilent network conditions.
+		return false, 0, 0
+	}
+
 	TTL := p.Duration(parameters.ServerReplayTTL)
 
 	if TTL == 0 {

+ 1 - 0
psiphon/server/replay_test.go

@@ -88,6 +88,7 @@ func runServerReplayTest(
           "ServerProtocolPacketManipulations": {"%s" : ["test-packetman-spec"]},
           "ServerReplayPacketManipulation" : true,
           "ServerReplayFragmentor" : true,
+          "ServerReplayUnknownGeoIP" : true,
           "ServerReplayTTL" : "3s",
           "ServerReplayTargetWaitDuration" : "200ms",
           "ServerReplayTargetTunnelDuration" : "100ms",