mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-06-29 07:42:37 +08:00
Prevent unexpected system resolve
This commit is contained in:
parent
b44a5ab894
commit
5d070b3fa9
@ -381,8 +381,10 @@ func (w *PacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
|
||||
if w.UDPOverride.Port != 0 {
|
||||
b.UDP.Port = w.UDPOverride.Port
|
||||
}
|
||||
var ip net.Address
|
||||
if b.UDP.Address.Family().IsDomain() {
|
||||
if ip, ok := w.resolvedUDPAddr.Load(b.UDP.Address.Domain()); ok {
|
||||
var ok bool
|
||||
if ip, ok = w.resolvedUDPAddr.Load(b.UDP.Address.Domain()); ok {
|
||||
b.UDP.Address = ip
|
||||
} else {
|
||||
ShouldUseSystemResolver := true
|
||||
@ -408,11 +410,14 @@ func (w *PacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
destAddr, _ := net.ResolveUDPAddr("udp", b.UDP.NetAddr())
|
||||
if destAddr == nil {
|
||||
if ip == nil {
|
||||
b.Release()
|
||||
continue
|
||||
}
|
||||
destAddr := &net.UDPAddr{
|
||||
IP: ip.IP(),
|
||||
Port: int(b.UDP.Port),
|
||||
}
|
||||
n, err = w.PacketConnWrapper.WriteTo(b.Bytes(), destAddr)
|
||||
} else {
|
||||
n, err = w.PacketConnWrapper.Write(b.Bytes())
|
||||
|
Loading…
x
Reference in New Issue
Block a user