mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
Fix: dns fallback logic
This commit is contained in:
parent
ad551c1e30
commit
eb3be06859
|
@ -14,7 +14,7 @@ type geoipFilter struct{}
|
|||
|
||||
func (gf *geoipFilter) Match(ip net.IP) bool {
|
||||
record, _ := mmdb.Instance().Country(ip)
|
||||
return record.Country.IsoCode == "CN" || record.Country.IsoCode == ""
|
||||
return record.Country.IsoCode != "CN" && record.Country.IsoCode != ""
|
||||
}
|
||||
|
||||
type ipnetFilter struct {
|
||||
|
|
|
@ -197,8 +197,7 @@ func (r *Resolver) fallbackExchange(m *D.Msg) (msg *D.Msg, err error) {
|
|||
res := <-msgCh
|
||||
if res.Error == nil {
|
||||
if ips := r.msgToIP(res.Msg); len(ips) != 0 {
|
||||
if r.shouldFallback(ips[0]) {
|
||||
go func() { <-fallbackMsg }()
|
||||
if !r.shouldFallback(ips[0]) {
|
||||
msg = res.Msg
|
||||
err = res.Error
|
||||
return msg, err
|
||||
|
@ -258,7 +257,7 @@ func (r *Resolver) msgToIP(msg *D.Msg) []net.IP {
|
|||
}
|
||||
|
||||
func (r *Resolver) asyncExchange(client []dnsClient, msg *D.Msg) <-chan *result {
|
||||
ch := make(chan *result)
|
||||
ch := make(chan *result, 1)
|
||||
go func() {
|
||||
res, err := r.batchExchange(client, msg)
|
||||
ch <- &result{Msg: res, Error: err}
|
||||
|
|
Loading…
Reference in New Issue
Block a user