Merge remote-tracking branch 'upstream/main' into dns-hosts

This commit is contained in:
j2rong4cn 2025-05-09 15:28:47 +08:00
commit eafb352eaf
7 changed files with 146 additions and 39 deletions

View file

@ -2,7 +2,6 @@ package dns
import (
"context"
"sort"
"strconv"
"github.com/xtls/xray-core/common/errors"
@ -70,14 +69,16 @@ func filterIP(ips []net.Address, option dns.IPOption) []net.Address {
}
func (h *StaticHosts) lookupInternal(domain string) []net.Address {
MatchSlice := h.matchers.Match(domain)
sort.Slice(MatchSlice, func(i, j int) bool {
return MatchSlice[i] < MatchSlice[j]
})
if len(MatchSlice) == 0 {
ips := make([]net.Address, 0)
found := false
for _, id := range h.matchers.Match(domain) {
ips = append(ips, h.ips[id]...)
found = true
}
if !found {
return nil
}
return h.ips[MatchSlice[0]]
return ips
}
func (h *StaticHosts) lookup(domain string, option dns.IPOption, maxDepth int) ([]net.Address, error) {