* /control/querylog_config: support optional parameters

This commit is contained in:
Simon Zolin
2019-11-12 15:36:17 +03:00
parent 0b7ac93076
commit 81e8bbe63c
4 changed files with 22 additions and 18 deletions

View File

@@ -26,7 +26,8 @@ const (
// queryLog is a structure that writes and reads the DNS query log
type queryLog struct {
conf Config
conf *Config
lock sync.Mutex
logFile string // path to the log file
bufferLock sync.RWMutex
@@ -40,7 +41,8 @@ type queryLog struct {
func newQueryLog(conf Config) *queryLog {
l := queryLog{}
l.logFile = filepath.Join(conf.BaseDir, queryLogFileName)
l.conf = conf
l.conf = &Config{}
*l.conf = conf
if !checkInterval(l.conf.Interval) {
l.conf.Interval = 1
}
@@ -59,12 +61,6 @@ func checkInterval(days uint32) bool {
return days == 1 || days == 7 || days == 30 || days == 90
}
// Set new configuration at runtime
func (l *queryLog) configure(conf Config) {
l.conf.Enabled = conf.Enabled
l.conf.Interval = conf.Interval
}
func (l *queryLog) WriteDiskConfig(dc *DiskConfig) {
dc.Enabled = l.conf.Enabled
dc.Interval = l.conf.Interval