|
@@ -40,6 +40,7 @@ const (
|
|
|
proxyAnnounceLogSamplePeriod = 30 * time.Minute
|
|
proxyAnnounceLogSamplePeriod = 30 * time.Minute
|
|
|
proxyWebRTCAnswerTimeout = 20 * time.Second
|
|
proxyWebRTCAnswerTimeout = 20 * time.Second
|
|
|
proxyDestinationDialTimeout = 20 * time.Second
|
|
proxyDestinationDialTimeout = 20 * time.Second
|
|
|
|
|
+ proxyRelayInactivityTimeout = 5 * time.Minute
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
// Proxy is the in-proxy proxying component, which relays traffic from a
|
|
// Proxy is the in-proxy proxying component, which relays traffic from a
|
|
@@ -794,7 +795,9 @@ func (p *Proxy) proxyOneClient(
|
|
|
// dial destination is a Psiphon server.
|
|
// dial destination is a Psiphon server.
|
|
|
|
|
|
|
|
destinationDialContext, destinationDialCancelFunc := context.WithTimeout(
|
|
destinationDialContext, destinationDialCancelFunc := context.WithTimeout(
|
|
|
- ctx, common.ValueOrDefault(webRTCCoordinator.ProxyDestinationDialTimeout(), proxyDestinationDialTimeout))
|
|
|
|
|
|
|
+ ctx,
|
|
|
|
|
+ common.ValueOrDefault(
|
|
|
|
|
+ webRTCCoordinator.ProxyDestinationDialTimeout(), proxyDestinationDialTimeout))
|
|
|
defer destinationDialCancelFunc()
|
|
defer destinationDialCancelFunc()
|
|
|
|
|
|
|
|
// Use the custom resolver when resolving destination hostnames, such as
|
|
// Use the custom resolver when resolving destination hostnames, such as
|
|
@@ -855,12 +858,21 @@ func (p *Proxy) proxyOneClient(
|
|
|
|
|
|
|
|
// Hook up bytes transferred counting for activity updates.
|
|
// Hook up bytes transferred counting for activity updates.
|
|
|
|
|
|
|
|
- // The ActivityMonitoredConn inactivity timeout is not configured, since
|
|
|
|
|
- // the Psiphon server will close its connection to inactive clients on
|
|
|
|
|
- // its own schedule.
|
|
|
|
|
|
|
+ // The ActivityMonitoredConn inactivity timeout is configured. For
|
|
|
|
|
+ // upstream TCP connections, the destinationConn will close when the TCP
|
|
|
|
|
+ // connection to the Psiphon server closes. But for upstream UDP flows,
|
|
|
|
|
+ // the relay does not know when the upstream "connection" has closed.
|
|
|
|
|
+ // Well-behaved clients will close the WebRTC half of the relay when
|
|
|
|
|
+ // those clients know the UDP-based tunnel protocol connection is closed;
|
|
|
|
|
+ // the inactivity timeout handles the remaining cases.
|
|
|
|
|
+
|
|
|
|
|
+ inactivityTimeout :=
|
|
|
|
|
+ common.ValueOrDefault(
|
|
|
|
|
+ webRTCCoordinator.ProxyRelayInactivityTimeout(),
|
|
|
|
|
+ proxyRelayInactivityTimeout)
|
|
|
|
|
|
|
|
destinationConn, err = common.NewActivityMonitoredConn(
|
|
destinationConn, err = common.NewActivityMonitoredConn(
|
|
|
- destinationConn, 0, false, nil, p.activityUpdateWrapper)
|
|
|
|
|
|
|
+ destinationConn, inactivityTimeout, false, nil, p.activityUpdateWrapper)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return backOff, errors.Trace(err)
|
|
return backOff, errors.Trace(err)
|
|
|
}
|
|
}
|