From 9f1d85ab6e602472ed73e7ae7166fb9c9e393de9 Mon Sep 17 00:00:00 2001 From: Kr328 Date: Sun, 14 Jun 2020 00:41:53 +0800 Subject: [PATCH] Fix: fake-ip-filter on fakeip mode should lookup ip-host mapping (#743) --- dns/resolver.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dns/resolver.go b/dns/resolver.go index 7f50a1a..52a08c0 100644 --- a/dns/resolver.go +++ b/dns/resolver.go @@ -121,7 +121,7 @@ func (r *Resolver) exchangeWithoutCache(m *D.Msg) (msg *D.Msg, err error) { } putMsgToCache(r.lruCache, q.String(), msg) - if r.mapping { + if r.mapping || r.fakeip { ips := r.msgToIP(msg) for _, ip := range ips { putMsgToCache(r.lruCache, ip.String(), msg) @@ -151,7 +151,10 @@ func (r *Resolver) exchangeWithoutCache(m *D.Msg) (msg *D.Msg, err error) { // IPToHost return fake-ip or redir-host mapping host func (r *Resolver) IPToHost(ip net.IP) (string, bool) { if r.fakeip { - return r.pool.LookBack(ip) + record, existed := r.pool.LookBack(ip) + if existed { + return record, true + } } cache, _ := r.lruCache.Get(ip.String())