Skip to content

Commit adf8a31

Browse files
authored
fix: don't calculate tunneltime for unauthenticated connections (#209)
1 parent e9b6b5e commit adf8a31

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cmd/outline-ss-server/metrics.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,13 @@ func (cm *tcpConnMetrics) AddClosed(status string, data metrics.ProxyMetrics, du
129129
cm.tcpServiceMetrics.proxyCollector.addClientTarget(data.ClientProxy, data.ProxyTarget, cm.accessKey, cm.clientInfo)
130130
cm.tcpServiceMetrics.proxyCollector.addTargetClient(data.TargetProxy, data.ProxyClient, cm.accessKey, cm.clientInfo)
131131
cm.tcpServiceMetrics.closeConnection(status, duration, cm.accessKey, cm.clientInfo)
132-
ipKey, err := toIPKey(cm.clientAddr, cm.accessKey)
133-
if err == nil {
134-
cm.tunnelTimeMetrics.stopConnection(*ipKey)
132+
// We only track authenticated TCP connections, so ignore unauthenticated closed connections
133+
// when calculating tunneltime. See https://github.com/Jigsaw-Code/outline-server/issues/1590.
134+
if cm.accessKey != "" {
135+
ipKey, err := toIPKey(cm.clientAddr, cm.accessKey)
136+
if err == nil {
137+
cm.tunnelTimeMetrics.stopConnection(*ipKey)
138+
}
135139
}
136140
}
137141

0 commit comments

Comments
 (0)