From e2ff8628ada0b9c2aac5dd6c1d9a6bb70de25854 Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Thu, 17 Oct 2019 14:33:38 +0300 Subject: [PATCH] - filters: auto-update didn't work --- home/dns.go | 2 ++ home/filter.go | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/home/dns.go b/home/dns.go index 8db03f49..6cd4895a 100644 --- a/home/dns.go +++ b/home/dns.go @@ -230,6 +230,8 @@ func startDNSServer() error { return errorx.Decorate(err, "Couldn't start forwarding DNS server") } + startFiltering() + const topClientsNumber = 100 // the number of clients to get topClients := config.stats.GetTopClientsIP(topClientsNumber) for _, ip := range topClients { diff --git a/home/filter.go b/home/filter.go index 07a75e61..415ba783 100644 --- a/home/filter.go +++ b/home/filter.go @@ -28,6 +28,12 @@ func initFiltering() { loadFilters() deduplicateFilters() updateUniqueFilterID(config.Filters) +} + +func startFiltering() { + // Here we should start updating filters, + // but currently we can't wake up the periodic task to do so. + // So for now we just start this periodic task from here. go periodicallyRefreshFilters() } @@ -178,7 +184,7 @@ func assignUniqueFilterID() int64 { // Sets up a timer that will be checking for filters updates periodically func periodicallyRefreshFilters() { for { - if config.DNS.FiltersUpdateIntervalHours != 0 && refreshStatus != 0 { + if config.DNS.FiltersUpdateIntervalHours != 0 && refreshStatus == 0 { refreshStatus = 1 refreshLock.Lock() _ = refreshFiltersIfNecessary(false)