From 26a87f9d34d05bc16d7f1c2026d8957768d67c78 Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Mon, 11 Feb 2019 17:20:42 +0800 Subject: [PATCH] Fix: `redir-host` mode crash --- tunnel/tunnel.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go index 2663ca31..77e81058 100644 --- a/tunnel/tunnel.go +++ b/tunnel/tunnel.go @@ -107,15 +107,15 @@ func (t *Tunnel) resolveIP(host string) (net.IP, error) { return t.resolver.ResolveIP(host) } -func (t *Tunnel) needLookupIP() bool { - return t.hasResolver() && t.resolver.IsMapping() +func (t *Tunnel) needLookupIP(metadata *C.Metadata) bool { + return t.hasResolver() && t.resolver.IsMapping() && metadata.Host == "" && metadata.IP != nil } func (t *Tunnel) handleConn(localConn C.ServerAdapter) { defer localConn.Close() metadata := localConn.Metadata() - if t.needLookupIP() { + if t.needLookupIP(metadata) { host, exist := t.resolver.IPToHost(*metadata.IP) if exist { metadata.Host = host