mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-16 12:03:03 +00:00
fix(udp): check addr nil (close 1807)
This commit is contained in:
parent
b67314796f
commit
76638d793c
@ -8,6 +8,7 @@ import (
|
|||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
|
"github.com/xtls/xray-core/common/errors"
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
"github.com/xtls/xray-core/transport/internet"
|
"github.com/xtls/xray-core/transport/internet"
|
||||||
)
|
)
|
||||||
@ -30,7 +31,14 @@ func ReadUDPMsg(conn *net.UDPConn, payload []byte, oob []byte) (int, int, int, *
|
|||||||
nBytes, addr, err := conn.ReadFromUDP(payload)
|
nBytes, addr, err := conn.ReadFromUDP(payload)
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
enc := gob.NewEncoder(&buf)
|
enc := gob.NewEncoder(&buf)
|
||||||
enc.Encode(conn.LocalAddr().(*net.UDPAddr))
|
udpAddr, ok := conn.LocalAddr().(*net.UDPAddr)
|
||||||
|
if !ok {
|
||||||
|
return 0, 0, 0, nil, errors.New("invalid local address")
|
||||||
|
}
|
||||||
|
if addr == nil {
|
||||||
|
return 0, 0, 0, nil, errors.New("invalid remote address")
|
||||||
|
}
|
||||||
|
enc.Encode(udpAddr)
|
||||||
enc.Encode(addr)
|
enc.Encode(addr)
|
||||||
var reader io.Reader = &buf
|
var reader io.Reader = &buf
|
||||||
noob, _ := reader.Read(oob)
|
noob, _ := reader.Read(oob)
|
||||||
|
Loading…
Reference in New Issue
Block a user