Move filtering setting fields from main app to dnsforward.

This commit is contained in:
Eugene Bujak 2018-11-28 18:24:04 +03:00
parent 7120f551c8
commit 8316d39b42
2 changed files with 43 additions and 33 deletions

View File

@ -48,13 +48,9 @@ type coreDNSConfig struct {
coreFile string coreFile string
Filters []filter `yaml:"-"` Filters []filter `yaml:"-"`
Port int `yaml:"port"` Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"` dnsforward.FilteringConfig `yaml:",inline"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL uint32 `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"` QueryLogEnabled bool `yaml:"querylog_enabled"`
Ratelimit int `yaml:"ratelimit"` Ratelimit int `yaml:"ratelimit"`
RefuseAny bool `yaml:"refuse_any"` RefuseAny bool `yaml:"refuse_any"`
@ -87,10 +83,12 @@ var config = configuration{
Port: 53, Port: 53,
binaryFile: "coredns", // only filename, no path binaryFile: "coredns", // only filename, no path
coreFile: "Corefile", // only filename, no path coreFile: "Corefile", // only filename, no path
FilteringConfig: dnsforward.FilteringConfig{
ProtectionEnabled: true, ProtectionEnabled: true,
FilteringEnabled: true, FilteringEnabled: true,
SafeBrowsingEnabled: false, SafeBrowsingEnabled: false,
BlockedResponseTTL: 10, // in seconds BlockedResponseTTL: 10, // in seconds
},
QueryLogEnabled: true, QueryLogEnabled: true,
Ratelimit: 20, Ratelimit: 20,
RefuseAny: true, RefuseAny: true,

View File

@ -72,12 +72,24 @@ func (s *Server) RUnlock() {
} }
*/ */
type FilteringConfig struct {
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL uint32 `yaml:"blocked_response_ttl"`
}
// The zero ServerConfig is empty and ready for use. // The zero ServerConfig is empty and ready for use.
type ServerConfig struct { type ServerConfig struct {
UDPListenAddr *net.UDPAddr // if nil, then default is is used (port 53 on *) UDPListenAddr *net.UDPAddr // if nil, then default is is used (port 53 on *)
BlockedResponseTTL uint32 // if 0, then default is used (3600) BlockedResponseTTL uint32 // if 0, then default is used (3600)
Upstreams []Upstream Upstreams []Upstream
Filters []Filter Filters []Filter
FilteringConfig
} }
var defaultValues = ServerConfig{ var defaultValues = ServerConfig{