mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-22 21:15:35 +03:00
dnsfilter -- Add parameter to New() to supply optional initial config.
This commit is contained in:
parent
3ecc0ee24b
commit
e26837d9e8
3 changed files with 7 additions and 4 deletions
|
@ -77,7 +77,7 @@ func setupPlugin(c *caddy.Controller) (*plug, error) {
|
|||
// create new Plugin and copy default values
|
||||
p := &plug{
|
||||
settings: defaultPluginSettings,
|
||||
d: dnsfilter.New(),
|
||||
d: dnsfilter.New(nil),
|
||||
}
|
||||
|
||||
log.Println("Initializing the CoreDNS plugin")
|
||||
|
|
|
@ -856,7 +856,7 @@ func (d *Dnsfilter) matchHost(host string) (Result, error) {
|
|||
//
|
||||
|
||||
// New creates properly initialized DNS Filter that is ready to be used
|
||||
func New() *Dnsfilter {
|
||||
func New(c *Config) *Dnsfilter {
|
||||
d := new(Dnsfilter)
|
||||
|
||||
d.storage = make(map[string]bool)
|
||||
|
@ -879,6 +879,9 @@ func New() *Dnsfilter {
|
|||
}
|
||||
d.safeBrowsingServer = defaultSafebrowsingServer
|
||||
d.parentalServer = defaultParentalServer
|
||||
if c != nil {
|
||||
d.Config = *c
|
||||
}
|
||||
|
||||
return d
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ func (s *Server) Start(config *ServerConfig) error {
|
|||
|
||||
if s.dnsFilter == nil {
|
||||
log.Printf("Creating dnsfilter")
|
||||
s.dnsFilter = dnsfilter.New()
|
||||
s.dnsFilter = dnsfilter.New(nil)
|
||||
}
|
||||
|
||||
go s.packetLoop()
|
||||
|
@ -322,7 +322,7 @@ func (s *Server) reconfigureFilters(new ServerConfig) {
|
|||
return
|
||||
}
|
||||
|
||||
dnsFilter := dnsfilter.New()
|
||||
dnsFilter := dnsfilter.New(&new.Config) // sets safebrowsing, safesearch and parental
|
||||
for _, f := range newFilters {
|
||||
for _, rule := range f.Rules {
|
||||
err := dnsFilter.AddRule(rule, f.ID)
|
||||
|
|
Loading…
Reference in a new issue