mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-07-02 09:48:43 +00:00
Fix panic in illegal request
This commit is contained in:
@@ -196,6 +196,9 @@ func (s *ServerSession) handshake5(nMethod byte, reader io.Reader, writer net.Co
|
|||||||
var tempUDPConn *TempUDPConn
|
var tempUDPConn *TempUDPConn
|
||||||
//nolint:gocritic // Use if else chain for clarity
|
//nolint:gocritic // Use if else chain for clarity
|
||||||
if request.Command == protocol.RequestCommandUDP {
|
if request.Command == protocol.RequestCommandUDP {
|
||||||
|
if request.Address.Family().IsDomain() {
|
||||||
|
return nil, nil, errors.New("domain name in UDP associate is illegal")
|
||||||
|
}
|
||||||
if s.config.Address != nil {
|
if s.config.Address != nil {
|
||||||
// Use configured IP as remote address in the response to UDP Associate
|
// Use configured IP as remote address in the response to UDP Associate
|
||||||
responseAddress = s.config.Address.AsAddress()
|
responseAddress = s.config.Address.AsAddress()
|
||||||
@@ -212,8 +215,8 @@ func (s *ServerSession) handshake5(nMethod byte, reader io.Reader, writer net.Co
|
|||||||
if request.Address.IP().IsUnspecified() {
|
if request.Address.IP().IsUnspecified() {
|
||||||
expectedRemote.IP = writer.RemoteAddr().(*net.TCPAddr).IP // unix?
|
expectedRemote.IP = writer.RemoteAddr().(*net.TCPAddr).IP // unix?
|
||||||
} else {
|
} else {
|
||||||
expectedRemote.IP = request.Address.IP() // panic?
|
expectedRemote.IP = request.Address.IP()
|
||||||
expectedRemote.Port = int(request.Port) // 0 is allowed
|
expectedRemote.Port = int(request.Port) // 0 is allowed
|
||||||
}
|
}
|
||||||
tempUDPConn = NewTempUDPConn(udpHub, writer, expectedRemote)
|
tempUDPConn = NewTempUDPConn(udpHub, writer, expectedRemote)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user