Skip to content

Commit

Permalink
home: hostsfile enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
schzhn committed Feb 15, 2024
1 parent fede297 commit c195430
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions internal/home/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ type dnsConfig struct {

// ServePlainDNS defines if plain DNS is allowed for incoming requests.
ServePlainDNS bool `yaml:"serve_plain_dns"`

// HostsFileEnabled defines whether to use information from the hosts file.
HostsFileEnabled bool `yaml:"hostsfile_enabled"`
}

type tlsConfigSettings struct {
Expand Down Expand Up @@ -349,9 +352,10 @@ var config = &configuration{
// was later increased to 300 due to https://github.com/AdguardTeam/AdGuardHome/issues/2257
MaxGoroutines: 300,
},
UpstreamTimeout: timeutil.Duration{Duration: dnsforward.DefaultTimeout},
UsePrivateRDNS: true,
ServePlainDNS: true,
UpstreamTimeout: timeutil.Duration{Duration: dnsforward.DefaultTimeout},
UsePrivateRDNS: true,
ServePlainDNS: true,
HostsFileEnabled: true,
},
TLS: tlsConfigSettings{
PortHTTPS: defaultPortHTTPS,
Expand Down
2 changes: 1 addition & 1 deletion internal/home/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func setupDNSFilteringConf(conf *filtering.Config) (err error) {

conf.EtcHosts = Context.etcHosts
// TODO(s.chzhen): Use empty interface.
if Context.etcHosts == nil {
if Context.etcHosts == nil || !config.DNS.HostsFileEnabled {
conf.EtcHosts = nil
}

Expand Down
4 changes: 2 additions & 2 deletions internal/home/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,13 @@ var cmdLineOpts = []cmdLineOpt{{
log.Info(
"warning: --no-etc-hosts flag is deprecated " +
"and will be removed in the future versions; " +
"set clients.runtime_sources.hosts in the configuration file to false instead",
"set dns.hostsfile_enabled in the configuration file to false instead",
)

return nil, nil
},
serialize: func(o options) (val string, ok bool) { return "", o.noEtcHosts },
description: "Deprecated: use clients.runtime_sources.hosts instead. Do not use the OS-provided hosts.",
description: "Deprecated: use dns.hostsfile_enabled instead. Do not use the OS-provided hosts.",
longName: "no-etc-hosts",
shortName: "",
}, {
Expand Down

0 comments on commit c195430

Please sign in to comment.