From 2b93c9d4c90854641a40d2ccc7beb2c0da46b2d6 Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Thu, 6 Dec 2018 10:51:37 +0800 Subject: [PATCH] Fix: resolve ip crash --- dns/client.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dns/client.go b/dns/client.go index b443c5c0c..7559ea37d 100644 --- a/dns/client.go +++ b/dns/client.go @@ -131,12 +131,14 @@ func (r *Resolver) resolveIP(m *D.Msg) (msg *D.Msg, err error) { return nil, errors.New("GeoIP can't use") } - ips, _ := r.msgToIP(res.Msg) - if record, _ := mmdb.Country(ips[0]); record.Country.IsoCode == "CN" || record.Country.IsoCode == "" { - // release channel - go func() { <-fallbackMsg }() - msg = res.Msg - return + ips, err := r.msgToIP(res.Msg) + if err == nil { + if record, _ := mmdb.Country(ips[0]); record.Country.IsoCode == "CN" || record.Country.IsoCode == "" { + // release channel + go func() { <-fallbackMsg }() + msg = res.Msg + return msg, err + } } }