1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 01:57:12 -05:00

Fix UDP reading on Windows

This commit is contained in:
v2ray 2016-08-19 12:58:26 +02:00
parent ad1353ac2f
commit 55e5268ce8
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
3 changed files with 13 additions and 0 deletions

View File

@ -78,6 +78,7 @@ func (this *UDPHub) start() {
buffer := alloc.NewBuffer() buffer := alloc.NewBuffer()
nBytes, noob, _, addr, err := this.conn.ReadMsgUDP(buffer.Value, oobBytes) nBytes, noob, _, addr, err := this.conn.ReadMsgUDP(buffer.Value, oobBytes)
if err != nil { if err != nil {
log.Info("UDP|Hub: Failed to read UDP msg: ", err)
buffer.Release() buffer.Release()
continue continue
} }

View File

@ -3,6 +3,7 @@
package udp package udp
import ( import (
"net"
"syscall" "syscall"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
@ -32,3 +33,7 @@ func RetrieveOriginalDest(oob []byte) v2net.Destination {
} }
return nil return nil
} }
func ReadUDPMsg(conn *net.UDPConn, payload []byte, oob []byte) (int, int, int, *net.UDPAddr, error) {
return conn.ReadMsgUDP(payload, oob)
}

View File

@ -3,6 +3,8 @@
package udp package udp
import ( import (
"net"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
) )
@ -13,3 +15,8 @@ func SetOriginalDestOptions(fd int) error {
func RetrieveOriginalDest(oob []byte) v2net.Destination { func RetrieveOriginalDest(oob []byte) v2net.Destination {
return nil 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
}