diff --git a/transport/internet/udp/hub.go b/transport/internet/udp/hub.go index 31b6f0cbf..7848c8ab8 100644 --- a/transport/internet/udp/hub.go +++ b/transport/internet/udp/hub.go @@ -78,6 +78,7 @@ func (this *UDPHub) start() { buffer := alloc.NewBuffer() nBytes, noob, _, addr, err := this.conn.ReadMsgUDP(buffer.Value, oobBytes) if err != nil { + log.Info("UDP|Hub: Failed to read UDP msg: ", err) buffer.Release() continue } diff --git a/transport/internet/udp/hub_linux.go b/transport/internet/udp/hub_linux.go index 1d9d5b6b8..d43ea2c3b 100644 --- a/transport/internet/udp/hub_linux.go +++ b/transport/internet/udp/hub_linux.go @@ -3,6 +3,7 @@ package udp import ( + "net" "syscall" v2net "github.com/v2ray/v2ray-core/common/net" @@ -32,3 +33,7 @@ func RetrieveOriginalDest(oob []byte) v2net.Destination { } return nil } + +func ReadUDPMsg(conn *net.UDPConn, payload []byte, oob []byte) (int, int, int, *net.UDPAddr, error) { + return conn.ReadMsgUDP(payload, oob) +} diff --git a/transport/internet/udp/hub_other.go b/transport/internet/udp/hub_other.go index 6b481f4b4..777c616dd 100644 --- a/transport/internet/udp/hub_other.go +++ b/transport/internet/udp/hub_other.go @@ -3,6 +3,8 @@ package udp import ( + "net" + v2net "github.com/v2ray/v2ray-core/common/net" ) @@ -13,3 +15,8 @@ func SetOriginalDestOptions(fd int) error { func RetrieveOriginalDest(oob []byte) v2net.Destination { return nil } + +func ReadUDPMsg(conn *net.UDPConn, payload []byte, oob []byte) (int, int, int, *net.UDPAddr, error) { + nBytes, addr, err := conn.ReadFromUDP(payload) + return nBytes, 0, 0, addr, err +}