From 72c0af9739898c3ec1797c96b15adc9c7ba9aed4 Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Fri, 31 Jan 2020 19:26:33 +0800 Subject: [PATCH] Chore: udp resolve ip on local --- tunnel/tunnel.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go index 5b388353..061a82e5 100644 --- a/tunnel/tunnel.go +++ b/tunnel/tunnel.go @@ -175,6 +175,15 @@ func (t *Tunnel) handleUDPConn(packet *inbound.PacketAdapter) { return } + if metadata.DstIP == nil { + ip, err := t.resolveIP(metadata.Host) + if err != nil { + log.Warnln("[UDP] Resolve %s failed: %s, %#v", metadata.Host, err.Error(), metadata) + return + } + metadata.DstIP = ip + } + key := packet.LocalAddr().String() pc := t.natTable.Get(key)