chore: reslove udp host after rule matching

This commit is contained in:
PuerNya 2023-12-18 14:51:36 +08:00 committed by 汐殇
parent 2bba8aa14a
commit 8cf14bb67e

View File

@ -328,16 +328,6 @@ func handleUDPConn(packet C.PacketAdapter) {
sniffer.Dispatcher.UDPSniff(packet)
}
// local resolve UDP dns
if !metadata.Resolved() {
ip, err := resolver.ResolveIP(context.Background(), metadata.Host)
if err != nil {
packet.Drop()
return
}
metadata.DstIP = ip
}
key := packet.LocalAddr().String()
handle := func() bool {
@ -381,6 +371,16 @@ func handleUDPConn(packet C.PacketAdapter) {
return
}
// local resolve UDP dns
if !metadata.Resolved() && proxy.Type() != C.Reject && proxy.Type() != C.RejectDrop {
ip, err := resolver.ResolveIP(context.Background(), metadata.Host)
if err != nil {
packet.Drop()
return
}
metadata.DstIP = ip
}
ctx, cancel := context.WithTimeout(context.Background(), C.DefaultUDPTimeout)
defer cancel()
rawPc, err := retry(ctx, func(ctx context.Context) (C.PacketConn, error) {