From 7f23c6f9577f4e20a8a3b53d453d05fae1de6acc Mon Sep 17 00:00:00 2001 From: Vasyl Gello Date: Mon, 15 Jul 2024 16:18:53 +0300 Subject: [PATCH] Cast the cached UDPConn Signed-off-by: Vasyl Gello --- cmd/yggstack/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/yggstack/main.go b/cmd/yggstack/main.go index 0939dc7..1911c6b 100644 --- a/cmd/yggstack/main.go +++ b/cmd/yggstack/main.go @@ -369,7 +369,7 @@ func main() { var udpFwdConn *net.UDPConn = nil - udpFwdConn, ok := remoteUdpConnections.Load(remoteUdpAddr) + connVal, ok := remoteUdpConnections.Load(remoteUdpAddr) if !ok { udpFwdConn, err = net.DialUDP("udp", nil, mapping.Mapped) @@ -379,6 +379,8 @@ func main() { } remoteUdpConnections.Store(remoteUdpAddr, &udpFwdConn) go types.ReverseProxyUDP(mtu, udpListenConn, remoteUdpAddr, udpFwdConn) + } else { + udpFwdConn = connVal.(net.UDPConn) } _, err = udpFwdConn.Write(udpBuffer[:bytesRead])