From 47c997d75ef1866798c77c81e402ebd02ed7bf8f Mon Sep 17 00:00:00 2001 From: Vigilans Date: Mon, 31 Aug 2020 12:21:56 +0800 Subject: [PATCH] Fix github.com/v2fly/v2ray-core/issues/146 --- app/dns/server.go | 5 ++++- common/strmatcher/strmatcher.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/dns/server.go b/app/dns/server.go index 22920e5b..2c9f11a5 100644 --- a/app/dns/server.go +++ b/app/dns/server.go @@ -256,7 +256,10 @@ func (s *Server) IsOwnLink(ctx context.Context) bool { // Match check dns ip match geoip func (s *Server) Match(idx int, client Client, domain string, ips []net.IP) ([]net.IP, error) { - matcher := s.ipIndexMap[idx] + var matcher *MultiGeoIPMatcher + if idx < len(s.ipIndexMap) { + matcher = s.ipIndexMap[idx] + } if matcher == nil { return ips, nil } diff --git a/common/strmatcher/strmatcher.go b/common/strmatcher/strmatcher.go index 7c2e366a..cc889b73 100644 --- a/common/strmatcher/strmatcher.go +++ b/common/strmatcher/strmatcher.go @@ -49,7 +49,7 @@ func (t Type) New(pattern string) (Matcher, error) { // IndexMatcher is the interface for matching with a group of matchers. type IndexMatcher interface { - // Match returns the the index of a matcher that matches the input. It returns 0 if no such matcher exists. + // Match returns the the index of a matcher that matches the input. It returns empty array if no such matcher exists. Match(input string) []uint32 }