mirror of
https://git.vectorsigma.ru/public/AdGuardHome.git
synced 2026-07-28 21:49:08 +00:00
Pull request 2438: AGDNS-3021-cache-enabled
Merge in DNS/adguard-home from AGDNS-3021-cache-enabled to master
Squashed commit of the following:
commit b92dd03cd07e3fec55b70f29e3db57823c40c419
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Tue Aug 5 19:18:59 2025 +0300
all: imp chlog
commit 26338b6a484555b8a995fc523d861b496925c535
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Tue Aug 5 18:20:06 2025 +0300
all: fix chlog
commit 8b9a40080e335a715bbc6ff70984433d5349fb32
Merge: 9e915b0b2 86de4e75f
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Tue Aug 5 18:17:20 2025 +0300
Merge branch 'master' into AGDNS-3021-cache-enabled
commit 9e915b0b203bf746d5eb940552a41897aba3683e
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Mon Aug 4 17:45:47 2025 +0300
client: imp docs
commit 8391be798a18bc04809dbcfbebdba3999e95401a
Author: Ildar Kamalov <ik@adguard.com>
Date: Mon Aug 4 16:26:32 2025 +0300
ADG-10416 fix cache size error styles
commit 02c33fed2c3e2b09f42062c3531b40152d45b0b6
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Thu Jul 24 17:59:00 2025 +0300
bamboo-specs: fix ci
commit 7fbe7a5ec051a01d820b0973eb4bba12ee618ba5
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Wed Jul 23 20:32:25 2025 +0300
all: imp docs
commit e681868d93785484465fe3744634081615d36be7
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Tue Jul 22 14:36:32 2025 +0300
all: imp docs
commit a5e7cc5223f6aad095a72647fe68463232ef7736
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Thu Jul 17 20:49:55 2025 +0300
all: add tests
commit 1ec3ec24ae2cf33a1aa95f168ebdc13aa06e7fa4
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Wed Jul 16 22:16:37 2025 +0300
all: http api
commit fe49206905c46fe49c57a0d66368fce57405477b
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Tue Jul 15 20:26:23 2025 +0300
all: cache enabled
This commit is contained in:
@@ -2,4 +2,4 @@
|
||||
package configmigrate
|
||||
|
||||
// LastSchemaVersion is the most recent schema version.
|
||||
const LastSchemaVersion uint = 29
|
||||
const LastSchemaVersion uint = 30
|
||||
|
||||
@@ -125,6 +125,7 @@ func (m *Migrator) upgradeConfigSchema(current, target uint, diskConf yobj) (err
|
||||
26: migrateTo27,
|
||||
27: migrateTo28,
|
||||
28: m.migrateTo29,
|
||||
29: m.migrateTo30,
|
||||
}
|
||||
|
||||
for i, migrate := range upgrades[current:target] {
|
||||
|
||||
@@ -193,6 +193,10 @@ func TestMigrateConfig_Migrate(t *testing.T) {
|
||||
yamlEqFunc: require.YAMLEq,
|
||||
name: "v27",
|
||||
targetVersion: 27,
|
||||
}, {
|
||||
yamlEqFunc: require.YAMLEq,
|
||||
name: "v30",
|
||||
targetVersion: 30,
|
||||
}}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
||||
119
internal/configmigrate/testdata/TestMigrateConfig_Migrate/v30/input.yml
vendored
Normal file
119
internal/configmigrate/testdata/TestMigrateConfig_Migrate/v30/input.yml
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
http:
|
||||
address: 127.0.0.1:3000
|
||||
session_ttl: 3h
|
||||
pprof:
|
||||
enabled: true
|
||||
port: 6060
|
||||
users:
|
||||
- name: testuser
|
||||
password: testpassword
|
||||
dns:
|
||||
bind_hosts:
|
||||
- 127.0.0.1
|
||||
port: 53
|
||||
parental_sensitivity: 0
|
||||
upstream_dns:
|
||||
- tls://1.1.1.1
|
||||
- tls://1.0.0.1
|
||||
- quic://8.8.8.8:784
|
||||
bootstrap_dns:
|
||||
- 8.8.8.8:53
|
||||
cache_size: 4194304
|
||||
edns_client_subnet:
|
||||
enabled: true
|
||||
use_custom: false
|
||||
custom_ip: ""
|
||||
filtering:
|
||||
filtering_enabled: true
|
||||
parental_enabled: false
|
||||
safebrowsing_enabled: false
|
||||
safe_fs_patterns: []
|
||||
safe_search:
|
||||
enabled: false
|
||||
bing: true
|
||||
duckduckgo: true
|
||||
google: true
|
||||
pixabay: true
|
||||
yandex: true
|
||||
youtube: true
|
||||
protection_enabled: true
|
||||
blocked_services:
|
||||
schedule:
|
||||
time_zone: Local
|
||||
ids:
|
||||
- 500px
|
||||
blocked_response_ttl: 10
|
||||
filters:
|
||||
- url: https://adaway.org/hosts.txt
|
||||
name: AdAway
|
||||
enabled: false
|
||||
- url: FILEPATH
|
||||
name: Local Filter
|
||||
enabled: false
|
||||
clients:
|
||||
persistent:
|
||||
- name: localhost
|
||||
ids:
|
||||
- 127.0.0.1
|
||||
- aa:aa:aa:aa:aa:aa
|
||||
use_global_settings: true
|
||||
use_global_blocked_services: true
|
||||
filtering_enabled: false
|
||||
parental_enabled: false
|
||||
safebrowsing_enabled: false
|
||||
safe_search:
|
||||
enabled: true
|
||||
bing: true
|
||||
duckduckgo: true
|
||||
google: true
|
||||
pixabay: true
|
||||
yandex: true
|
||||
youtube: true
|
||||
blocked_services:
|
||||
schedule:
|
||||
time_zone: Local
|
||||
ids:
|
||||
- 500px
|
||||
runtime_sources:
|
||||
whois: true
|
||||
arp: true
|
||||
rdns: true
|
||||
dhcp: true
|
||||
hosts: true
|
||||
dhcp:
|
||||
enabled: false
|
||||
interface_name: vboxnet0
|
||||
local_domain_name: local
|
||||
dhcpv4:
|
||||
gateway_ip: 192.168.0.1
|
||||
subnet_mask: 255.255.255.0
|
||||
range_start: 192.168.0.10
|
||||
range_end: 192.168.0.250
|
||||
lease_duration: 1234
|
||||
icmp_timeout_msec: 10
|
||||
schema_version: 29
|
||||
user_rules: []
|
||||
querylog:
|
||||
enabled: true
|
||||
file_enabled: true
|
||||
interval: 720h
|
||||
size_memory: 1000
|
||||
ignored:
|
||||
- '|.^'
|
||||
statistics:
|
||||
enabled: true
|
||||
interval: 240h
|
||||
ignored:
|
||||
- '|.^'
|
||||
os:
|
||||
group: ''
|
||||
rlimit_nofile: 123
|
||||
user: ''
|
||||
log:
|
||||
file: ""
|
||||
max_backups: 0
|
||||
max_size: 100
|
||||
max_age: 3
|
||||
compress: true
|
||||
local_time: false
|
||||
verbose: true
|
||||
120
internal/configmigrate/testdata/TestMigrateConfig_Migrate/v30/output.yml
vendored
Normal file
120
internal/configmigrate/testdata/TestMigrateConfig_Migrate/v30/output.yml
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
http:
|
||||
address: 127.0.0.1:3000
|
||||
session_ttl: 3h
|
||||
pprof:
|
||||
enabled: true
|
||||
port: 6060
|
||||
users:
|
||||
- name: testuser
|
||||
password: testpassword
|
||||
dns:
|
||||
bind_hosts:
|
||||
- 127.0.0.1
|
||||
port: 53
|
||||
parental_sensitivity: 0
|
||||
upstream_dns:
|
||||
- tls://1.1.1.1
|
||||
- tls://1.0.0.1
|
||||
- quic://8.8.8.8:784
|
||||
bootstrap_dns:
|
||||
- 8.8.8.8:53
|
||||
cache_enabled: true
|
||||
cache_size: 4194304
|
||||
edns_client_subnet:
|
||||
enabled: true
|
||||
use_custom: false
|
||||
custom_ip: ""
|
||||
filtering:
|
||||
filtering_enabled: true
|
||||
parental_enabled: false
|
||||
safebrowsing_enabled: false
|
||||
safe_fs_patterns: []
|
||||
safe_search:
|
||||
enabled: false
|
||||
bing: true
|
||||
duckduckgo: true
|
||||
google: true
|
||||
pixabay: true
|
||||
yandex: true
|
||||
youtube: true
|
||||
protection_enabled: true
|
||||
blocked_services:
|
||||
schedule:
|
||||
time_zone: Local
|
||||
ids:
|
||||
- 500px
|
||||
blocked_response_ttl: 10
|
||||
filters:
|
||||
- url: https://adaway.org/hosts.txt
|
||||
name: AdAway
|
||||
enabled: false
|
||||
- url: FILEPATH
|
||||
name: Local Filter
|
||||
enabled: false
|
||||
clients:
|
||||
persistent:
|
||||
- name: localhost
|
||||
ids:
|
||||
- 127.0.0.1
|
||||
- aa:aa:aa:aa:aa:aa
|
||||
use_global_settings: true
|
||||
use_global_blocked_services: true
|
||||
filtering_enabled: false
|
||||
parental_enabled: false
|
||||
safebrowsing_enabled: false
|
||||
safe_search:
|
||||
enabled: true
|
||||
bing: true
|
||||
duckduckgo: true
|
||||
google: true
|
||||
pixabay: true
|
||||
yandex: true
|
||||
youtube: true
|
||||
blocked_services:
|
||||
schedule:
|
||||
time_zone: Local
|
||||
ids:
|
||||
- 500px
|
||||
runtime_sources:
|
||||
whois: true
|
||||
arp: true
|
||||
rdns: true
|
||||
dhcp: true
|
||||
hosts: true
|
||||
dhcp:
|
||||
enabled: false
|
||||
interface_name: vboxnet0
|
||||
local_domain_name: local
|
||||
dhcpv4:
|
||||
gateway_ip: 192.168.0.1
|
||||
subnet_mask: 255.255.255.0
|
||||
range_start: 192.168.0.10
|
||||
range_end: 192.168.0.250
|
||||
lease_duration: 1234
|
||||
icmp_timeout_msec: 10
|
||||
schema_version: 30
|
||||
user_rules: []
|
||||
querylog:
|
||||
enabled: true
|
||||
file_enabled: true
|
||||
interval: 720h
|
||||
size_memory: 1000
|
||||
ignored:
|
||||
- '|.^'
|
||||
statistics:
|
||||
enabled: true
|
||||
interval: 240h
|
||||
ignored:
|
||||
- '|.^'
|
||||
os:
|
||||
group: ''
|
||||
rlimit_nofile: 123
|
||||
user: ''
|
||||
log:
|
||||
file: ""
|
||||
max_backups: 0
|
||||
max_size: 100
|
||||
max_age: 3
|
||||
compress: true
|
||||
local_time: false
|
||||
verbose: true
|
||||
33
internal/configmigrate/v30.go
Normal file
33
internal/configmigrate/v30.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package configmigrate
|
||||
|
||||
// migrateTo30 performs the following changes:
|
||||
//
|
||||
// # BEFORE:
|
||||
// 'dns':
|
||||
// 'cache_size': 123456
|
||||
// # …
|
||||
//
|
||||
// # AFTER:
|
||||
// 'dns':
|
||||
// 'cache_size': 123456
|
||||
// 'cache_enabled': true
|
||||
// # …
|
||||
//
|
||||
// If cache_size is zero, then cache_enabled should be false.
|
||||
func (m Migrator) migrateTo30(diskConf yobj) (err error) {
|
||||
diskConf["schema_version"] = 30
|
||||
|
||||
dnsConf, ok, err := fieldVal[yobj](diskConf, "dns")
|
||||
if !ok {
|
||||
return err
|
||||
}
|
||||
|
||||
cacheSize, ok, err := fieldVal[int](dnsConf, "cache_size")
|
||||
if !ok {
|
||||
return err
|
||||
}
|
||||
|
||||
dnsConf["cache_enabled"] = cacheSize > 0
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user