From 70c5afd6a5065ad827b038954dba1ade503a5246 Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Tue, 27 Nov 2018 21:30:11 +0300 Subject: [PATCH] Restore Engrish function names to normal English. --- app.go | 4 ++-- control.go | 16 +++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app.go b/app.go index ca5c2487..96d73c2c 100644 --- a/app.go +++ b/app.go @@ -156,7 +156,7 @@ func main() { // Update filters we've just loaded right away, don't wait for periodic update timer go func() { - checkFiltersUpdates(false) + refreshFiltersIfNeccessary(false) // Save the updated config err := writeConfig() if err != nil { @@ -177,7 +177,7 @@ func main() { address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) - runFiltersUpdatesTimer() + go periodicallyRefreshFilters() http.Handle("/", optionalAuthHandler(http.FileServer(box))) registerControlHandlers() diff --git a/control.go b/control.go index 5c17ee0e..e5dc5b00 100644 --- a/control.go +++ b/control.go @@ -471,7 +471,7 @@ func handleFilteringEnableURL(w http.ResponseWriter, r *http.Request) { } // kick off refresh of rules from new URLs - checkFiltersUpdates(false) + refreshFiltersIfNeccessary(false) httpUpdateConfigReloadDNSReturnOK(w, r) } @@ -527,22 +527,20 @@ func handleFilteringSetRules(w http.ResponseWriter, r *http.Request) { func handleFilteringRefresh(w http.ResponseWriter, r *http.Request) { force := r.URL.Query().Get("force") - updated := checkFiltersUpdates(force != "") + updated := refreshFiltersIfNeccessary(force != "") fmt.Fprintf(w, "OK %d filters updated\n", updated) } // Sets up a timer that will be checking for filters updates periodically -func runFiltersUpdatesTimer() { - go func() { - for range time.Tick(time.Minute) { - checkFiltersUpdates(false) - } - }() +func periodicallyRefreshFilters() { + for range time.Tick(time.Minute) { + refreshFiltersIfNeccessary(false) + } } // Checks filters updates if necessary // If force is true, it ignores the filter.LastUpdated field value -func checkFiltersUpdates(force bool) int { +func refreshFiltersIfNeccessary(force bool) int { config.Lock() // fetch URLs