Skip to content

Commit

Permalink
Stop passing unused keyID.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbruens committed Nov 15, 2024
1 parent 1f2e289 commit 6ec3801
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions service/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,9 @@ func (m *natmap) get(key string) *natconn {
return m.keyConn[key]
}

func (m *natmap) set(key string, pc net.PacketConn, keyID string, connMetrics UDPConnMetrics) *natconn {
func (m *natmap) set(key string, pc net.PacketConn, connMetrics UDPConnMetrics) *natconn {
entry := &natconn{
PacketConn: pc,
keyID: keyID,
metrics: connMetrics,
defaultTimeout: m.timeout,
}
Expand All @@ -393,10 +392,10 @@ func (m *natmap) del(key string) net.PacketConn {

func (m *natmap) Add(clientAddr net.Addr, clientConn net.PacketConn, targetConn net.PacketConn, keyID string) *natconn {
connMetrics := m.metrics.AddUDPNatEntry(clientAddr, keyID)
entry := m.set(clientAddr.String(), targetConn, keyID, connMetrics)
entry := m.set(clientAddr.String(), targetConn, connMetrics)

go func() {
timedCopy(clientAddr, clientConn, entry, keyID, m.logger)
timedCopy(clientAddr, clientConn, entry, m.logger)
connMetrics.RemoveNatEntry()
if pc := m.del(clientAddr.String()); pc != nil {
pc.Close()
Expand Down Expand Up @@ -424,7 +423,7 @@ func (m *natmap) Close() error {
var maxAddrLen int = len(socks.ParseAddr("[2001:db8::1]:12345"))

// copy from target to client until read timeout
func timedCopy(clientAddr net.Addr, clientConn net.PacketConn, targetConn *natconn, keyID string, l *slog.Logger) {
func timedCopy(clientAddr net.Addr, clientConn net.PacketConn, targetConn *natconn, l *slog.Logger) {
// pkt is used for in-place encryption of downstream UDP packets, with the layout
// [padding?][salt][address][body][tag][extra]
// Padding is only used if the address is IPv4.
Expand Down

0 comments on commit 6ec3801

Please sign in to comment.