mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 17:46:58 -05:00
drop unsupported domain address type in packet addr (#3186)
This commit is contained in:
parent
05345cc4fd
commit
229b30d877
@ -79,6 +79,11 @@ func (c *packetConnectionAdaptor) ReadFrom(p []byte) (n int, addr gonet.Addr, er
|
||||
}
|
||||
|
||||
func (c *packetConnectionAdaptor) WriteTo(p []byte, addr gonet.Addr) (n int, err error) {
|
||||
_, ok := addr.(*gonet.UDPAddr)
|
||||
if !ok {
|
||||
// address other than UDPAddr is not supported, and will be dropped.
|
||||
return 0, nil
|
||||
}
|
||||
payloadLen := len(p)
|
||||
var buffer *buf.Buffer
|
||||
buffer, err = AttachAddressToPacket(buf.FromBytes(p), addr)
|
||||
|
@ -2,6 +2,7 @@ package packetaddr
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/v2fly/v2ray-core/v5/common/errors"
|
||||
gonet "net"
|
||||
|
||||
"github.com/v2fly/v2ray-core/v5/common/buf"
|
||||
@ -45,6 +46,9 @@ func ExtractAddressFromPacket(data *buf.Buffer) (*buf.Buffer, gonet.Addr, error)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if address.Family().IsDomain() {
|
||||
return nil, nil, errors.New("invalid address type")
|
||||
}
|
||||
addr := &gonet.UDPAddr{
|
||||
IP: address.IP(),
|
||||
Port: int(port.Value()),
|
||||
|
@ -27,6 +27,12 @@ func (p PacketAddrDispatcher) Dispatch(ctx context.Context, destination net.Dest
|
||||
if destination.Network != net.Network_UDP {
|
||||
return
|
||||
}
|
||||
|
||||
// Processing of domain address is unsupported as it adds unpredictable overhead, it will be dropped.
|
||||
if destination.Address.Family().IsDomain() {
|
||||
return
|
||||
}
|
||||
|
||||
p.conn.WriteTo(payload.Bytes(), &net.UDPAddr{IP: destination.Address.IP(), Port: int(destination.Port.Value())})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user