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

Add UnthrottleFirstTunnelOnly option

Rod Hynes 7 лет назад
Родитель
Сommit
667b3b0908
1 измененных файлов с 14 добавлено и 3 удалено
  1. 14 3
      psiphon/server/trafficRules.go

+ 14 - 3
psiphon/server/trafficRules.go

@@ -101,8 +101,6 @@ type TrafficRules struct {
 
 
 	// RateLimits specifies data transfer rate limits for the
 	// RateLimits specifies data transfer rate limits for the
 	// client traffic.
 	// client traffic.
-	// Any RateLimits.ReadUnthrottledBytes/WriteUnthrottledBytes
-	// apply only to the first tunnel in a session.
 	RateLimits RateLimits
 	RateLimits RateLimits
 
 
 	// DialTCPPortForwardTimeoutMilliseconds is the timeout period
 	// DialTCPPortForwardTimeoutMilliseconds is the timeout period
@@ -181,6 +179,11 @@ type RateLimits struct {
 	WriteUnthrottledBytes *int64
 	WriteUnthrottledBytes *int64
 	WriteBytesPerSecond   *int64
 	WriteBytesPerSecond   *int64
 	CloseAfterExhausted   *bool
 	CloseAfterExhausted   *bool
+
+	// UnthrottleFirstTunnelOnly specifies whether any
+	// ReadUnthrottledBytes/WriteUnthrottledBytes apply
+	// only to the first tunnel in a session.
+	UnthrottleFirstTunnelOnly *bool
 }
 }
 
 
 // CommonRateLimits converts a RateLimits to a common.RateLimits.
 // CommonRateLimits converts a RateLimits to a common.RateLimits.
@@ -320,6 +323,10 @@ func (set *TrafficRulesSet) GetTrafficRules(
 		trafficRules.RateLimits.CloseAfterExhausted = new(bool)
 		trafficRules.RateLimits.CloseAfterExhausted = new(bool)
 	}
 	}
 
 
+	if trafficRules.RateLimits.UnthrottleFirstTunnelOnly == nil {
+		trafficRules.RateLimits.UnthrottleFirstTunnelOnly = new(bool)
+	}
+
 	intPtr := func(i int) *int {
 	intPtr := func(i int) *int {
 		return &i
 		return &i
 	}
 	}
@@ -453,6 +460,10 @@ func (set *TrafficRulesSet) GetTrafficRules(
 			trafficRules.RateLimits.CloseAfterExhausted = filteredRules.Rules.RateLimits.CloseAfterExhausted
 			trafficRules.RateLimits.CloseAfterExhausted = filteredRules.Rules.RateLimits.CloseAfterExhausted
 		}
 		}
 
 
+		if filteredRules.Rules.RateLimits.UnthrottleFirstTunnelOnly != nil {
+			trafficRules.RateLimits.UnthrottleFirstTunnelOnly = filteredRules.Rules.RateLimits.UnthrottleFirstTunnelOnly
+		}
+
 		if filteredRules.Rules.DialTCPPortForwardTimeoutMilliseconds != nil {
 		if filteredRules.Rules.DialTCPPortForwardTimeoutMilliseconds != nil {
 			trafficRules.DialTCPPortForwardTimeoutMilliseconds = filteredRules.Rules.DialTCPPortForwardTimeoutMilliseconds
 			trafficRules.DialTCPPortForwardTimeoutMilliseconds = filteredRules.Rules.DialTCPPortForwardTimeoutMilliseconds
 		}
 		}
@@ -488,7 +499,7 @@ func (set *TrafficRulesSet) GetTrafficRules(
 		break
 		break
 	}
 	}
 
 
-	if !isFirstTunnelInSession {
+	if *trafficRules.RateLimits.UnthrottleFirstTunnelOnly && !isFirstTunnelInSession {
 		*trafficRules.RateLimits.ReadUnthrottledBytes = 0
 		*trafficRules.RateLimits.ReadUnthrottledBytes = 0
 		*trafficRules.RateLimits.WriteUnthrottledBytes = 0
 		*trafficRules.RateLimits.WriteUnthrottledBytes = 0
 	}
 	}