mirror of
https://github.com/yggdrasil-network/yggstack.git
synced 2025-04-27 21:55:07 +03:00
Fix UDP port forward not working with Yggdrasil client
Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
This commit is contained in:
parent
08f51fded2
commit
bfc106637a
1 changed files with 12 additions and 8 deletions
|
@ -465,13 +465,16 @@ func main() {
|
||||||
for {
|
for {
|
||||||
bytesRead, remoteUdpAddr, err := udpListenConn.ReadFrom(udpBuffer)
|
bytesRead, remoteUdpAddr, err := udpListenConn.ReadFrom(udpBuffer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if bytesRead == 0 {
|
logger.Debugf("udp readFrom error: %v", err)
|
||||||
continue
|
}
|
||||||
}
|
if bytesRead == 0 {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
remoteUdpAddrStr := remoteUdpAddr.String()
|
remoteUdpAddrStr := remoteUdpAddr.String()
|
||||||
|
|
||||||
|
var udpSession *UDPSession = nil
|
||||||
|
|
||||||
connVal, ok := remoteUdpConnections.Load(remoteUdpAddrStr)
|
connVal, ok := remoteUdpConnections.Load(remoteUdpAddrStr)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -481,17 +484,18 @@ func main() {
|
||||||
logger.Errorf("Failed to connect to %s: %s", mapping.Mapped, err)
|
logger.Errorf("Failed to connect to %s: %s", mapping.Mapped, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
udpSession := &UDPSession{
|
udpSession = &UDPSession{
|
||||||
conn: udpFwdConn,
|
conn: udpFwdConn,
|
||||||
remoteAddr: remoteUdpAddr,
|
remoteAddr: remoteUdpAddr,
|
||||||
}
|
}
|
||||||
remoteUdpConnections.Store(remoteUdpAddrStr, udpSession)
|
remoteUdpConnections.Store(remoteUdpAddrStr, udpSession)
|
||||||
go types.ReverseProxyUDP(mtu, udpListenConn, remoteUdpAddr, udpFwdConn)
|
go types.ReverseProxyUDP(mtu, udpListenConn, remoteUdpAddr, udpFwdConn)
|
||||||
}
|
} else {
|
||||||
|
udpSession, ok = connVal.(*UDPSession)
|
||||||
|
|
||||||
udpSession, ok := connVal.(*UDPSession)
|
if !ok {
|
||||||
if !ok {
|
continue
|
||||||
continue
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
udpFwdConnPtr := udpSession.conn.(*net.UDPConn)
|
udpFwdConnPtr := udpSession.conn.(*net.UDPConn)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue