Skip to content

Commit

Permalink
chore: allow disabled system hosts by environment variable `DISABLE_S…
Browse files Browse the repository at this point in the history
…YSTEM_HOSTS`
  • Loading branch information
wwqgtxx committed Mar 13, 2024
1 parent dceb8ee commit b3db113
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion component/resolver/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package resolver
import (
"errors"
"net/netip"
"os"
"strconv"
"strings"
_ "unsafe"

Expand All @@ -11,6 +13,8 @@ import (
"github.com/zhangyunhao116/fastrand"
)

var DisableSystemHosts, _ = strconv.ParseBool(os.Getenv("DISABLE_SYSTEM_HOSTS"))

type Hosts struct {
*trie.DomainTrie[HostValue]
}
Expand Down Expand Up @@ -47,7 +51,7 @@ func (h *Hosts) Search(domain string, isDomain bool) (*HostValue, bool) {

return &hostValue, false
}
if !isDomain {
if !isDomain && !DisableSystemHosts {
addr, _ := lookupStaticHost(domain)
if hostValue, err := NewHostValue(addr); err == nil {
return &hostValue, true
Expand Down

0 comments on commit b3db113

Please sign in to comment.