0
mirror of https://github.com/XTLS/Xray-core.git synced 2025-05-09 19:51:24 +03:00

DNS: temporary appending hosts results (#4702)

This commit is contained in:
patterniha 2025-05-07 01:41:08 +03:30 committed by GitHub
parent 3e52f73e3c
commit 59aa5e1b88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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