Pull request: 2504 querylog interval
Merge in DNS/adguard-home from 2504-querylog-ivl to master
Updates #2504.
Squashed commit of the following:
commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21
Merge: 8cd5c30d 97073d0d
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Thu Jul 1 18:45:10 2021 +0300
Merge branch 'master' into 2504-querylog-ivl
commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Thu Jul 1 18:35:50 2021 +0300
client: fix fmt
commit e95d462c31d886bacec0735acc567fec7c962149
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Thu Jul 1 17:58:06 2021 +0300
home: imp code
commit 48737b249c52a997a4f34dac45fbaf699477b007
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Thu Jul 1 17:23:18 2021 +0300
home: imp duration
commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Thu Jul 1 16:55:31 2021 +0300
home: imp code, docs
commit bb2826521b7e5d248ce2ab686528219c312b8ba2
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Thu Jul 1 16:11:40 2021 +0300
all: imp code, docs
commit d688aed1f340807a8bac8807c263956b0fc16f5b
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Thu Jul 1 13:49:42 2021 +0300
all: change querylog interval setting format
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/aghnet"
|
||||
"github.com/AdguardTeam/golibs/errors"
|
||||
@@ -19,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
// currentSchemaVersion is the current schema version.
|
||||
const currentSchemaVersion = 11
|
||||
const currentSchemaVersion = 12
|
||||
|
||||
// These aliases are provided for convenience.
|
||||
type (
|
||||
@@ -82,6 +83,7 @@ func upgradeConfigSchema(oldVersion int, diskConf yobj) (err error) {
|
||||
upgradeSchema8to9,
|
||||
upgradeSchema9to10,
|
||||
upgradeSchema10to11,
|
||||
upgradeSchema11to12,
|
||||
}
|
||||
|
||||
n := 0
|
||||
@@ -647,6 +649,46 @@ func upgradeSchema10to11(diskConf yobj) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// upgradeSchema11to12 performs the following changes:
|
||||
//
|
||||
// # BEFORE:
|
||||
// 'querylog_interval': 90
|
||||
//
|
||||
// # AFTER:
|
||||
// 'querylog_interval': '2160h'
|
||||
//
|
||||
func upgradeSchema11to12(diskConf yobj) (err error) {
|
||||
log.Printf("Upgrade yaml: 11 to 12")
|
||||
diskConf["schema_version"] = 12
|
||||
|
||||
dnsVal, ok := diskConf["dns"]
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
var dns yobj
|
||||
dns, ok = dnsVal.(yobj)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type of dns: %T", dnsVal)
|
||||
}
|
||||
|
||||
const field = "querylog_interval"
|
||||
|
||||
// Set the initial value from home.initConfig function.
|
||||
qlogIvl := 90
|
||||
qlogIvlVal, ok := dns[field]
|
||||
if ok {
|
||||
qlogIvl, ok = qlogIvlVal.(int)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type of %s: %T", field, qlogIvlVal)
|
||||
}
|
||||
}
|
||||
|
||||
dns[field] = Duration{Duration: time.Duration(qlogIvl) * 24 * time.Hour}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO(a.garipov): Replace with log.Output when we port it to our logging
|
||||
// package.
|
||||
func funcName() string {
|
||||
|
||||
Reference in New Issue
Block a user