From 14ffd1a3f52049931b21abe4ebce5bd22ece715b Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Mon, 27 Apr 2020 13:21:16 +0300 Subject: [PATCH] Merge: - blocked-services: settings were reset on restart Close #1624 Squashed commit of the following: commit eecc91ca1f9d062c27702a9c07da74da673bef05 Merge: ec53dbeb 26f78dcc Author: Simon Zolin Date: Mon Apr 27 13:15:58 2020 +0300 Merge remote-tracking branch 'origin/master' into fix-blocked-svcs commit ec53dbebdc2fbd2ff94f939d2bd8fb07b9dd1bc8 Author: Simon Zolin Date: Mon Apr 27 12:58:50 2020 +0300 minor commit 1e3c20ed02151965ebaca55ac4f25a951a772062 Author: Simon Zolin Date: Mon Apr 27 12:53:37 2020 +0300 - blocked-services: settings were reset on restart broken by: 0789e4b20dea132f5d66ee18f7d1fbd05c10b014 * refactor: move blocked-services functions to dnsfilter --- dnsfilter/dnsfilter.go | 7 +++++-- home/home.go | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/dnsfilter/dnsfilter.go b/dnsfilter/dnsfilter.go index 60a32d39..82b56187 100644 --- a/dnsfilter/dnsfilter.go +++ b/dnsfilter/dnsfilter.go @@ -628,6 +628,11 @@ func makeResult(rule rules.Rule, reason Reason) Result { return res } +// InitModule() - manually initialize blocked services map +func InitModule() { + initBlockedServices() +} + // New creates properly initialized DNS Filter that is ready to be used func New(c *Config, blockFilters []Filter) *Dnsfilter { @@ -677,8 +682,6 @@ func New(c *Config, blockFilters []Filter) *Dnsfilter { } d.BlockedServices = bsvcs - initBlockedServices() - if blockFilters != nil { err := d.initFiltering(nil, blockFilters) if err != nil { diff --git a/home/home.go b/home/home.go index 2340ca6c..ebc25af4 100644 --- a/home/home.go +++ b/home/home.go @@ -208,6 +208,11 @@ func run(args options) { } } + // 'clients' module uses 'dnsfilter' module's static data (dnsfilter.BlockedSvcKnown()), + // so we have to initialize dnsfilter's static data first, + // but also avoid relying on automatic Go init() function + dnsfilter.InitModule() + config.DHCP.WorkDir = Context.workDir config.DHCP.HTTPRegister = httpRegister config.DHCP.ConfigModified = onConfigModified