mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
chore: allow disabled system hosts by environment variable DISABLE_SYSTEM_HOSTS
This commit is contained in:
parent
dceb8ee535
commit
b3db113b1b
|
@ -3,6 +3,8 @@ package resolver
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
_ "unsafe"
|
_ "unsafe"
|
||||||
|
|
||||||
|
@ -11,6 +13,8 @@ import (
|
||||||
"github.com/zhangyunhao116/fastrand"
|
"github.com/zhangyunhao116/fastrand"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var DisableSystemHosts, _ = strconv.ParseBool(os.Getenv("DISABLE_SYSTEM_HOSTS"))
|
||||||
|
|
||||||
type Hosts struct {
|
type Hosts struct {
|
||||||
*trie.DomainTrie[HostValue]
|
*trie.DomainTrie[HostValue]
|
||||||
}
|
}
|
||||||
|
@ -47,7 +51,7 @@ func (h *Hosts) Search(domain string, isDomain bool) (*HostValue, bool) {
|
||||||
|
|
||||||
return &hostValue, false
|
return &hostValue, false
|
||||||
}
|
}
|
||||||
if !isDomain {
|
if !isDomain && !DisableSystemHosts {
|
||||||
addr, _ := lookupStaticHost(domain)
|
addr, _ := lookupStaticHost(domain)
|
||||||
if hostValue, err := NewHostValue(addr); err == nil {
|
if hostValue, err := NewHostValue(addr); err == nil {
|
||||||
return &hostValue, true
|
return &hostValue, true
|
||||||
|
|
Loading…
Reference in New Issue
Block a user