From 59aa5e1b88f1b42ffc7b26debc81fee38c09910d Mon Sep 17 00:00:00 2001 From: patterniha <71074308+patterniha@users.noreply.github.com> Date: Wed, 7 May 2025 01:41:08 +0330 Subject: [PATCH] DNS: temporary appending hosts results (#4702) --- app/dns/hosts.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/dns/hosts.go b/app/dns/hosts.go index d0485be2..f4e06dbb 100644 --- a/app/dns/hosts.go +++ b/app/dns/hosts.go @@ -2,8 +2,6 @@ package dns import ( "context" - "sort" - "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" "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 { - 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 {