From adf8a317dbd00f1231637359a8676cdacd03b6a8 Mon Sep 17 00:00:00 2001 From: Sander Bruens Date: Wed, 11 Sep 2024 19:08:22 -0400 Subject: [PATCH] fix: don't calculate tunneltime for unauthenticated connections (#209) --- cmd/outline-ss-server/metrics.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/outline-ss-server/metrics.go b/cmd/outline-ss-server/metrics.go index 5766163a..302f1036 100644 --- a/cmd/outline-ss-server/metrics.go +++ b/cmd/outline-ss-server/metrics.go @@ -129,9 +129,13 @@ func (cm *tcpConnMetrics) AddClosed(status string, data metrics.ProxyMetrics, du cm.tcpServiceMetrics.proxyCollector.addClientTarget(data.ClientProxy, data.ProxyTarget, cm.accessKey, cm.clientInfo) cm.tcpServiceMetrics.proxyCollector.addTargetClient(data.TargetProxy, data.ProxyClient, cm.accessKey, cm.clientInfo) cm.tcpServiceMetrics.closeConnection(status, duration, cm.accessKey, cm.clientInfo) - ipKey, err := toIPKey(cm.clientAddr, cm.accessKey) - if err == nil { - cm.tunnelTimeMetrics.stopConnection(*ipKey) + // We only track authenticated TCP connections, so ignore unauthenticated closed connections + // when calculating tunneltime. See https://github.com/Jigsaw-Code/outline-server/issues/1590. + if cm.accessKey != "" { + ipKey, err := toIPKey(cm.clientAddr, cm.accessKey) + if err == nil { + cm.tunnelTimeMetrics.stopConnection(*ipKey) + } } }