Proxy stats log only what occurred that time interval

Modify the periodic stats output by standalone snowflake proxies to only
include the data transferred during the time interval being logged. This
is an improvement of previous behaviour that logged the total data
transferred by all proxy connections that were closed within the time
interval being logged..

Closes #40302:
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40302
This commit is contained in:
Cecylia Bocovich 2023-10-28 16:45:22 -04:00
parent 354cb65432
commit 018bbd6d65
No known key found for this signature in database
GPG key ID: 009DE379FD9B7B90
3 changed files with 16 additions and 28 deletions

View file

@ -14,7 +14,6 @@ import (
"github.com/pion/ice/v2"
"github.com/pion/sdp/v3"
"github.com/pion/webrtc/v3"
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/event"
)
const maxBufferedAmount uint64 = 512 * 1024 // 512 KB
@ -36,19 +35,17 @@ type webRTCConn struct {
isClosing bool
bytesLogger bytesLogger
eventLogger event.SnowflakeEventReceiver
inactivityTimeout time.Duration
activity chan struct{}
sendMoreCh chan struct{}
cancelTimeoutLoop context.CancelFunc
bytesLogger bytesLogger
}
func newWebRTCConn(pc *webrtc.PeerConnection, dc *webrtc.DataChannel, pr *io.PipeReader, eventLogger event.SnowflakeEventReceiver) *webRTCConn {
conn := &webRTCConn{pc: pc, dc: dc, pr: pr, eventLogger: eventLogger}
func newWebRTCConn(pc *webrtc.PeerConnection, dc *webrtc.DataChannel, pr *io.PipeReader, bytesLogger bytesLogger) *webRTCConn {
conn := &webRTCConn{pc: pc, dc: dc, pr: pr, bytesLogger: bytesLogger}
conn.isClosing = false
conn.bytesLogger = newBytesSyncLogger()
conn.activity = make(chan struct{}, 100)
conn.sendMoreCh = make(chan struct{}, 1)
conn.inactivityTimeout = 30 * time.Second