mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 15:36:41 -05:00
Merge pull request #148 from Vigilans/vigilans/dns-fix-array-panic
Fix: Bound check when accessing DNS server's ipIndexMap
This commit is contained in:
commit
e55fdda5b1
@ -256,7 +256,10 @@ func (s *Server) IsOwnLink(ctx context.Context) bool {
|
|||||||
|
|
||||||
// Match check dns ip match geoip
|
// Match check dns ip match geoip
|
||||||
func (s *Server) Match(idx int, client Client, domain string, ips []net.IP) ([]net.IP, error) {
|
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 {
|
if matcher == nil {
|
||||||
return ips, nil
|
return ips, nil
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ func (t Type) New(pattern string) (Matcher, error) {
|
|||||||
|
|
||||||
// IndexMatcher is the interface for matching with a group of matchers.
|
// IndexMatcher is the interface for matching with a group of matchers.
|
||||||
type IndexMatcher interface {
|
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
|
Match(input string) []uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user