mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-02-26 16:57:08 +00:00
chore: stop using go:linkname for net.lookupStaticHost
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
_ "unsafe"
|
||||
|
||||
"github.com/metacubex/mihomo/common/utils"
|
||||
"github.com/metacubex/mihomo/component/resolver/hosts"
|
||||
"github.com/metacubex/mihomo/component/trie"
|
||||
"github.com/zhangyunhao116/fastrand"
|
||||
)
|
||||
@@ -28,11 +29,6 @@ func NewHosts(hosts *trie.DomainTrie[HostValue]) Hosts {
|
||||
}
|
||||
}
|
||||
|
||||
// lookupStaticHost looks up the addresses and the canonical name for the given host from /etc/hosts.
|
||||
//
|
||||
//go:linkname lookupStaticHost net.lookupStaticHost
|
||||
func lookupStaticHost(host string) ([]string, string)
|
||||
|
||||
// Return the search result and whether to match the parameter `isDomain`
|
||||
func (h *Hosts) Search(domain string, isDomain bool) (*HostValue, bool) {
|
||||
if value := h.DomainTrie.Search(domain); value != nil {
|
||||
@@ -56,7 +52,7 @@ func (h *Hosts) Search(domain string, isDomain bool) (*HostValue, bool) {
|
||||
}
|
||||
|
||||
if !isDomain && !DisableSystemHosts && UseSystemHosts {
|
||||
addr, _ := lookupStaticHost(domain)
|
||||
addr, _ := hosts.LookupStaticHost(domain)
|
||||
if hostValue, err := NewHostValue(addr); err == nil {
|
||||
return &hostValue, true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user