Fix UDP port forward not working with Yggdrasil client

Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
This commit is contained in:
Vasyl Gello 2024-08-06 15:35:26 +03:00
parent 08f51fded2
commit bfc106637a

View file

@ -465,13 +465,16 @@ func main() {
for {
bytesRead, remoteUdpAddr, err := udpListenConn.ReadFrom(udpBuffer)
if err != nil {
logger.Debugf("udp readFrom error: %v", err)
}
if bytesRead == 0 {
continue
}
}
remoteUdpAddrStr := remoteUdpAddr.String()
var udpSession *UDPSession = nil
connVal, ok := remoteUdpConnections.Load(remoteUdpAddrStr)
if !ok {
@ -481,18 +484,19 @@ func main() {
logger.Errorf("Failed to connect to %s: %s", mapping.Mapped, err)
continue
}
udpSession := &UDPSession{
udpSession = &UDPSession{
conn: udpFwdConn,
remoteAddr: remoteUdpAddr,
}
remoteUdpConnections.Store(remoteUdpAddrStr, udpSession)
go types.ReverseProxyUDP(mtu, udpListenConn, remoteUdpAddr, udpFwdConn)
}
} else {
udpSession, ok = connVal.(*UDPSession)
udpSession, ok := connVal.(*UDPSession)
if !ok {
continue
}
}
udpFwdConnPtr := udpSession.conn.(*net.UDPConn)
udpFwdConn := *udpFwdConnPtr