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)