filtering: refactor; change API; add "filters_update_interval" setting

+ config: "filters_update_interval"
* add /control/filtering_info
* remove /control/filtering/enable
* remove /control/filtering/disable

* add /control/filtering_config
* remove /control/filtering/status

* add /control/filtering/set_url
* remove /control/filtering/enable_url
* remove /control/filtering/disable_url
This commit is contained in:
Simon Zolin
2019-09-04 14:12:00 +03:00
parent 8c89973365
commit adb422fedf
14 changed files with 324 additions and 157 deletions

View File

@@ -35,7 +35,7 @@ type queryLog struct {
lock sync.RWMutex
}
// newQueryLog creates a new instance of the query log
// create a new instance of the query log
func newQueryLog(conf Config) *queryLog {
l := queryLog{}
l.logFile = filepath.Join(conf.BaseDir, queryLogFileName)
@@ -53,7 +53,6 @@ func (l *queryLog) Configure(conf Config) {
l.conf = conf
}
// Clear memory buffer and remove the file
func (l *queryLog) Clear() {
l.fileFlushLock.Lock()
defer l.fileFlushLock.Unlock()
@@ -164,7 +163,6 @@ func (l *queryLog) Add(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Res
}
}
// getQueryLogJson returns a map with the current query log ready to be converted to a JSON
func (l *queryLog) GetData() []map[string]interface{} {
l.lock.RLock()
values := make([]*logEntry, len(l.cache))