Skip to content

Commit

Permalink
Remove ipinfo.IPInfo from RemoveUDPNatEntry, as it doesn't need it.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbruens committed Mar 20, 2024
1 parent 5c75727 commit 4d0a20a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/outline-ss-server/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func (m *outlineMetrics) AddUDPNatEntry(clientInfo ipinfo.IPInfo, clientAddr net
m.tunnelTimeTracker.startConnection(clientInfo, clientAddr, accessKey)
}

func (m *outlineMetrics) RemoveUDPNatEntry(clientInfo ipinfo.IPInfo, clientAddr net.Addr, accessKey string) {
func (m *outlineMetrics) RemoveUDPNatEntry(clientAddr net.Addr, accessKey string) {
m.udpRemovedNatEntries.Inc()

m.tunnelTimeTracker.stopConnection(clientAddr, accessKey)
Expand Down
4 changes: 2 additions & 2 deletions cmd/outline-ss-server/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestMethodsDontPanic(t *testing.T) {
ssMetrics.AddUDPPacketFromClient(ipInfo, "2", "OK", 10, 20)
ssMetrics.AddUDPPacketFromTarget(ipInfo, "3", "OK", 10, 20)
ssMetrics.AddUDPNatEntry(ipInfo, fakeAddr("127.0.0.1:9"), "key-1")
ssMetrics.RemoveUDPNatEntry(ipInfo, fakeAddr("127.0.0.1:9"), "key-1")
ssMetrics.RemoveUDPNatEntry(fakeAddr("127.0.0.1:9"), "key-1")
ssMetrics.AddTCPProbe("ERR_CIPHER", "eof", 443, proxyMetrics.ClientProxy)
ssMetrics.AddTCPCipherSearch(true, 10*time.Millisecond)
ssMetrics.AddUDPCipherSearch(true, 10*time.Millisecond)
Expand Down Expand Up @@ -231,6 +231,6 @@ func BenchmarkNAT(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
ssMetrics.AddUDPNatEntry(ipinfo, fakeAddr("127.0.0.1:9"), "key-0")
ssMetrics.RemoveUDPNatEntry(ipinfo, fakeAddr("127.0.0.1:9"), "key-0")
ssMetrics.RemoveUDPNatEntry(fakeAddr("127.0.0.1:9"), "key-0")
}
}
2 changes: 1 addition & 1 deletion internal/integration_test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (m *fakeUDPMetrics) AddUDPPacketFromTarget(clientInfo ipinfo.IPInfo, access
func (m *fakeUDPMetrics) AddUDPNatEntry(clientInfo ipinfo.IPInfo, clientAddr net.Addr, accessKey string) {
m.natAdded++
}
func (m *fakeUDPMetrics) RemoveUDPNatEntry(clientInfo ipinfo.IPInfo, clientAddr net.Addr, accessKey string) {
func (m *fakeUDPMetrics) RemoveUDPNatEntry(clientAddr net.Addr, accessKey string) {
// Not tested because it requires waiting for a long timeout.
}
func (m *fakeUDPMetrics) AddUDPCipherSearch(accessKeyFound bool, timeToCipher time.Duration) {}
Expand Down
6 changes: 3 additions & 3 deletions service/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type UDPMetrics interface {
AddUDPPacketFromClient(clientInfo ipinfo.IPInfo, accessKey, status string, clientProxyBytes, proxyTargetBytes int)
AddUDPPacketFromTarget(clientInfo ipinfo.IPInfo, accessKey, status string, targetProxyBytes, proxyClientBytes int)
AddUDPNatEntry(clientInfo ipinfo.IPInfo, clientAddr net.Addr, accessKey string)
RemoveUDPNatEntry(clientInfo ipinfo.IPInfo, clientAddr net.Addr, accessKey string)
RemoveUDPNatEntry(clientAddr net.Addr, accessKey string)

// Shadowsocks metrics
AddUDPCipherSearch(accessKeyFound bool, timeToCipher time.Duration)
Expand Down Expand Up @@ -361,7 +361,7 @@ func (m *natmap) Add(clientAddr net.Addr, clientConn net.PacketConn, cryptoKey *
m.running.Add(1)
go func() {
timedCopy(clientAddr, clientConn, entry, keyID, m.metrics)
m.metrics.RemoveUDPNatEntry(clientInfo, clientAddr, keyID)
m.metrics.RemoveUDPNatEntry(clientAddr, keyID)
if pc := m.del(clientAddr.String()); pc != nil {
pc.Close()
}
Expand Down Expand Up @@ -477,6 +477,6 @@ func (m *NoOpUDPMetrics) AddUDPPacketFromTarget(clientInfo ipinfo.IPInfo, access
}
func (m *NoOpUDPMetrics) AddUDPNatEntry(clientInfo ipinfo.IPInfo, clientAddr net.Addr, accessKey string) {
}
func (m *NoOpUDPMetrics) RemoveUDPNatEntry(clientInfo ipinfo.IPInfo, clientAddr net.Addr, accessKey string) {
func (m *NoOpUDPMetrics) RemoveUDPNatEntry(clientAddr net.Addr, accessKey string) {
}
func (m *NoOpUDPMetrics) AddUDPCipherSearch(accessKeyFound bool, timeToCipher time.Duration) {}
2 changes: 1 addition & 1 deletion service/udp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (m *natTestMetrics) AddUDPPacketFromTarget(clientInfo ipinfo.IPInfo, access
func (m *natTestMetrics) AddUDPNatEntry(clientInfo ipinfo.IPInfo, clientAddr net.Addr, accessKey string) {
m.natEntriesAdded++
}
func (m *natTestMetrics) RemoveUDPNatEntry(clientInfo ipinfo.IPInfo, clientAddr net.Addr, accessKey string) {
func (m *natTestMetrics) RemoveUDPNatEntry(clientAddr net.Addr, accessKey string) {
}
func (m *natTestMetrics) AddUDPCipherSearch(accessKeyFound bool, timeToCipher time.Duration) {}

Expand Down

0 comments on commit 4d0a20a

Please sign in to comment.