Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions app/dns/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down