Merge: - filters: auto-update didn't work

Close #1077

* commit 'e2ff8628ada0b9c2aac5dd6c1d9a6bb70de25854':
  - filters: auto-update didn't work
This commit is contained in:
Simon Zolin 2019-10-17 15:13:00 +03:00
commit e72ae3ac6f
2 changed files with 9 additions and 1 deletions

View File

@ -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 {

View File

@ -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)