mirror of
https://git.vectorsigma.ru/public/AdGuardHome.git
synced 2026-07-28 21:39:11 +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:
29
CHANGELOG.md
29
CHANGELOG.md
@@ -18,6 +18,35 @@ See also the [v0.107.65 GitHub milestone][ms-v0.107.65].
|
|||||||
NOTE: Add new changes BELOW THIS COMMENT.
|
NOTE: Add new changes BELOW THIS COMMENT.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- A separate checkbox in the Web UI to enable or disable the global DNS response cache without losing the configured cache size.
|
||||||
|
|
||||||
|
- A new `"cache_enabled"` field to the HTTP API (`GET /control/dns_info` and `POST /control/dns_config`). See `openapi/openapi.yaml` for the full description.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
#### Configuration changes
|
||||||
|
|
||||||
|
In this release, the schema version has changed from 29 to 30.
|
||||||
|
|
||||||
|
- Added a new boolean field `dns.cache_enabled` to the configuration. This field explicitly controls whether DNS caching is enabled, replacing the previous implicit logic based on `dns.cache_size`.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# BEFORE:
|
||||||
|
'dns':
|
||||||
|
# …
|
||||||
|
'cache_size': 123456
|
||||||
|
|
||||||
|
# AFTER:
|
||||||
|
'dns':
|
||||||
|
# …
|
||||||
|
'cache_enabled': true
|
||||||
|
'cache_size': 123456
|
||||||
|
```
|
||||||
|
|
||||||
|
To roll back this change, set the schema_version back to `29`.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Disabled state of Top clients action button in web UI ([#7923]).
|
- Disabled state of Top clients action button in web UI ([#7923]).
|
||||||
|
|||||||
@@ -655,7 +655,10 @@
|
|||||||
"safe_search": "Safe Search",
|
"safe_search": "Safe Search",
|
||||||
"blocklist": "Blocklist",
|
"blocklist": "Blocklist",
|
||||||
"milliseconds_abbreviation": "ms",
|
"milliseconds_abbreviation": "ms",
|
||||||
|
"cache_enabled": "Enable cache",
|
||||||
|
"cache_enabled_desc": "Store DNS responses locally.",
|
||||||
"cache_size": "Cache size",
|
"cache_size": "Cache size",
|
||||||
|
"cache_size_validation": "The cache size must be greater than zero when enabled.",
|
||||||
"cache_size_desc": "DNS cache size (in bytes). To disable caching, set to 0.",
|
"cache_size_desc": "DNS cache size (in bytes). To disable caching, set to 0.",
|
||||||
"cache_ttl_min_override": "Override minimum TTL",
|
"cache_ttl_min_override": "Override minimum TTL",
|
||||||
"cache_ttl_max_override": "Override maximum TTL",
|
"cache_ttl_max_override": "Override maximum TTL",
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ const INPUTS_FIELDS = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
type FormData = {
|
type FormData = {
|
||||||
|
cache_enabled: boolean;
|
||||||
cache_size: number;
|
cache_size: number;
|
||||||
cache_ttl_min: number;
|
cache_ttl_min: number;
|
||||||
cache_ttl_max: number;
|
cache_ttl_max: number;
|
||||||
@@ -54,10 +55,11 @@ const Form = ({ initialValues, onSubmit }: CacheFormProps) => {
|
|||||||
handleSubmit,
|
handleSubmit,
|
||||||
watch,
|
watch,
|
||||||
control,
|
control,
|
||||||
formState: { isSubmitting, isDirty },
|
formState: { isSubmitting },
|
||||||
} = useForm<FormData>({
|
} = useForm<FormData>({
|
||||||
mode: 'onBlur',
|
mode: 'onBlur',
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
|
cache_enabled: initialValues?.cache_enabled || false,
|
||||||
cache_size: initialValues?.cache_size || 0,
|
cache_size: initialValues?.cache_size || 0,
|
||||||
cache_ttl_min: initialValues?.cache_ttl_min || 0,
|
cache_ttl_min: initialValues?.cache_ttl_min || 0,
|
||||||
cache_ttl_max: initialValues?.cache_ttl_max || 0,
|
cache_ttl_max: initialValues?.cache_ttl_max || 0,
|
||||||
@@ -65,10 +67,13 @@ const Form = ({ initialValues, onSubmit }: CacheFormProps) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const cache_enabled = watch('cache_enabled');
|
||||||
|
const cache_size = watch('cache_size');
|
||||||
const cache_ttl_min = watch('cache_ttl_min');
|
const cache_ttl_min = watch('cache_ttl_min');
|
||||||
const cache_ttl_max = watch('cache_ttl_max');
|
const cache_ttl_max = watch('cache_ttl_max');
|
||||||
|
|
||||||
const minExceedsMax = cache_ttl_min > 0 && cache_ttl_max > 0 && cache_ttl_min > cache_ttl_max;
|
const minExceedsMax = cache_ttl_min > 0 && cache_ttl_max > 0 && cache_ttl_min > cache_ttl_max;
|
||||||
|
const cacheSizeZeroWhenEnabled = cache_enabled && cache_size === 0;
|
||||||
|
|
||||||
const handleClearCache = () => {
|
const handleClearCache = () => {
|
||||||
if (window.confirm(t('confirm_dns_cache_clear'))) {
|
if (window.confirm(t('confirm_dns_cache_clear'))) {
|
||||||
@@ -79,6 +84,24 @@ const Form = ({ initialValues, onSubmit }: CacheFormProps) => {
|
|||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit(onSubmit)}>
|
<form onSubmit={handleSubmit(onSubmit)}>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
|
<div className="col-12 col-md-7">
|
||||||
|
<div className="form__group form__group--settings">
|
||||||
|
<Controller
|
||||||
|
name="cache_enabled"
|
||||||
|
control={control}
|
||||||
|
render={({ field }) => (
|
||||||
|
<Checkbox
|
||||||
|
{...field}
|
||||||
|
data-testid="dns_cache_enabled"
|
||||||
|
title={t('cache_enabled')}
|
||||||
|
subtitle={t('cache_enabled_desc')}
|
||||||
|
disabled={processingSetConfig}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{INPUTS_FIELDS.map(({ name, title, description, placeholder }) => (
|
{INPUTS_FIELDS.map(({ name, title, description, placeholder }) => (
|
||||||
<div className="col-12" key={name}>
|
<div className="col-12" key={name}>
|
||||||
<div className="col-12 col-md-7 p-0">
|
<div className="col-12 col-md-7 p-0">
|
||||||
@@ -102,6 +125,12 @@ const Form = ({ initialValues, onSubmit }: CacheFormProps) => {
|
|||||||
setValueAs: (value) => replaceZeroWithEmptyString(value),
|
setValueAs: (value) => replaceZeroWithEmptyString(value),
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{name === CACHE_CONFIG_FIELDS.cache_size && cacheSizeZeroWhenEnabled && (
|
||||||
|
<span className="form__message form__message--error">
|
||||||
|
{t('cache_size_validation')}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -133,7 +162,7 @@ const Form = ({ initialValues, onSubmit }: CacheFormProps) => {
|
|||||||
type="submit"
|
type="submit"
|
||||||
data-testid="dns_save"
|
data-testid="dns_save"
|
||||||
className="btn btn-success btn-standard btn-large"
|
className="btn btn-success btn-standard btn-large"
|
||||||
disabled={isSubmitting || !isDirty || processingSetConfig || minExceedsMax}>
|
disabled={isSubmitting || processingSetConfig || minExceedsMax || cacheSizeZeroWhenEnabled}>
|
||||||
{t('save_btn')}
|
{t('save_btn')}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { RootState } from '../../../../initialState';
|
|||||||
const CacheConfig = () => {
|
const CacheConfig = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { cache_size, cache_ttl_max, cache_ttl_min, cache_optimistic } = useSelector(
|
const { cache_enabled, cache_size, cache_ttl_max, cache_ttl_min, cache_optimistic } = useSelector(
|
||||||
(state: RootState) => state.dnsConfig,
|
(state: RootState) => state.dnsConfig,
|
||||||
shallowEqual,
|
shallowEqual,
|
||||||
);
|
);
|
||||||
@@ -32,6 +32,7 @@ const CacheConfig = () => {
|
|||||||
<div className="form">
|
<div className="form">
|
||||||
<Form
|
<Form
|
||||||
initialValues={{
|
initialValues={{
|
||||||
|
cache_enabled,
|
||||||
cache_size: replaceZeroWithEmptyString(cache_size),
|
cache_size: replaceZeroWithEmptyString(cache_size),
|
||||||
cache_ttl_max: replaceZeroWithEmptyString(cache_ttl_max),
|
cache_ttl_max: replaceZeroWithEmptyString(cache_ttl_max),
|
||||||
cache_ttl_min: replaceZeroWithEmptyString(cache_ttl_min),
|
cache_ttl_min: replaceZeroWithEmptyString(cache_ttl_min),
|
||||||
|
|||||||
@@ -322,6 +322,7 @@ export type DnsConfigData = {
|
|||||||
ratelimit_subnet_len_ipv6?: number;
|
ratelimit_subnet_len_ipv6?: number;
|
||||||
edns_cs_use_custom?: boolean;
|
edns_cs_use_custom?: boolean;
|
||||||
edns_cs_custom_ip?: string;
|
edns_cs_custom_ip?: string;
|
||||||
|
cache_enabled?: boolean;
|
||||||
cache_size?: number;
|
cache_size?: number;
|
||||||
cache_ttl_max?: number;
|
cache_ttl_max?: number;
|
||||||
cache_ttl_min?: number;
|
cache_ttl_min?: number;
|
||||||
|
|||||||
@@ -2,4 +2,4 @@
|
|||||||
package configmigrate
|
package configmigrate
|
||||||
|
|
||||||
// LastSchemaVersion is the most recent schema version.
|
// 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,
|
26: migrateTo27,
|
||||||
27: migrateTo28,
|
27: migrateTo28,
|
||||||
28: m.migrateTo29,
|
28: m.migrateTo29,
|
||||||
|
29: m.migrateTo30,
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, migrate := range upgrades[current:target] {
|
for i, migrate := range upgrades[current:target] {
|
||||||
|
|||||||
@@ -193,6 +193,10 @@ func TestMigrateConfig_Migrate(t *testing.T) {
|
|||||||
yamlEqFunc: require.YAMLEq,
|
yamlEqFunc: require.YAMLEq,
|
||||||
name: "v27",
|
name: "v27",
|
||||||
targetVersion: 27,
|
targetVersion: 27,
|
||||||
|
}, {
|
||||||
|
yamlEqFunc: require.YAMLEq,
|
||||||
|
name: "v30",
|
||||||
|
targetVersion: 30,
|
||||||
}}
|
}}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
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
|
||||||
|
}
|
||||||
@@ -27,6 +27,7 @@ import (
|
|||||||
"github.com/AdguardTeam/golibs/netutil"
|
"github.com/AdguardTeam/golibs/netutil"
|
||||||
"github.com/AdguardTeam/golibs/stringutil"
|
"github.com/AdguardTeam/golibs/stringutil"
|
||||||
"github.com/AdguardTeam/golibs/timeutil"
|
"github.com/AdguardTeam/golibs/timeutil"
|
||||||
|
"github.com/AdguardTeam/golibs/validate"
|
||||||
"github.com/ameshkov/dnscrypt/v2"
|
"github.com/ameshkov/dnscrypt/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -104,6 +105,9 @@ type Config struct {
|
|||||||
|
|
||||||
// DNS cache settings
|
// DNS cache settings
|
||||||
|
|
||||||
|
// CacheEnabled defines if the DNS cache should be used.
|
||||||
|
CacheEnabled bool `yaml:"cache_enabled"`
|
||||||
|
|
||||||
// CacheSize is the DNS cache size (in bytes).
|
// CacheSize is the DNS cache size (in bytes).
|
||||||
CacheSize uint32 `yaml:"cache_size"`
|
CacheSize uint32 `yaml:"cache_size"`
|
||||||
|
|
||||||
@@ -369,6 +373,7 @@ func (s *Server) newProxyConfig(ctx context.Context) (conf *proxy.Config, err er
|
|||||||
}
|
}
|
||||||
|
|
||||||
conf, err = prepareCacheConfig(conf,
|
conf, err = prepareCacheConfig(conf,
|
||||||
|
srvConf.CacheEnabled,
|
||||||
srvConf.CacheSize,
|
srvConf.CacheSize,
|
||||||
srvConf.CacheMinTTL,
|
srvConf.CacheMinTTL,
|
||||||
srvConf.CacheMaxTTL,
|
srvConf.CacheMaxTTL,
|
||||||
@@ -385,13 +390,20 @@ func (s *Server) newProxyConfig(ctx context.Context) (conf *proxy.Config, err er
|
|||||||
// there is one.
|
// there is one.
|
||||||
func prepareCacheConfig(
|
func prepareCacheConfig(
|
||||||
conf *proxy.Config,
|
conf *proxy.Config,
|
||||||
|
isEnabled bool,
|
||||||
size uint32,
|
size uint32,
|
||||||
minTTL uint32,
|
minTTL uint32,
|
||||||
maxTTL uint32,
|
maxTTL uint32,
|
||||||
) (prepared *proxy.Config, err error) {
|
) (prepared *proxy.Config, err error) {
|
||||||
if size != 0 {
|
if isEnabled {
|
||||||
|
cacheSize := int(size)
|
||||||
|
err = validate.Positive("cache_size", cacheSize)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cache_enabled is true: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
conf.CacheEnabled = true
|
conf.CacheEnabled = true
|
||||||
conf.CacheSizeBytes = int(size)
|
conf.CacheSizeBytes = cacheSize
|
||||||
}
|
}
|
||||||
|
|
||||||
err = validateCacheTTL(minTTL, maxTTL)
|
err = validateCacheTTL(minTTL, maxTTL)
|
||||||
|
|||||||
@@ -93,6 +93,9 @@ type jsonDNSConfig struct {
|
|||||||
// CacheMaxTTL is custom maximum TTL for cached DNS responses.
|
// CacheMaxTTL is custom maximum TTL for cached DNS responses.
|
||||||
CacheMaxTTL *uint32 `json:"cache_ttl_max"`
|
CacheMaxTTL *uint32 `json:"cache_ttl_max"`
|
||||||
|
|
||||||
|
// CacheEnabled defines if the DNS cache should be used.
|
||||||
|
CacheEnabled *bool `json:"cache_enabled"`
|
||||||
|
|
||||||
// CacheOptimistic defines if expired entries should be served.
|
// CacheOptimistic defines if expired entries should be served.
|
||||||
CacheOptimistic *bool `json:"cache_optimistic"`
|
CacheOptimistic *bool `json:"cache_optimistic"`
|
||||||
|
|
||||||
@@ -162,6 +165,7 @@ func (s *Server) getDNSConfig(ctx context.Context) (c *jsonDNSConfig) {
|
|||||||
|
|
||||||
enableDNSSEC := s.conf.EnableDNSSEC
|
enableDNSSEC := s.conf.EnableDNSSEC
|
||||||
aaaaDisabled := s.conf.AAAADisabled
|
aaaaDisabled := s.conf.AAAADisabled
|
||||||
|
cacheEnabled := s.conf.CacheEnabled
|
||||||
cacheSize := s.conf.CacheSize
|
cacheSize := s.conf.CacheSize
|
||||||
cacheMinTTL := s.conf.CacheMinTTL
|
cacheMinTTL := s.conf.CacheMinTTL
|
||||||
cacheMaxTTL := s.conf.CacheMaxTTL
|
cacheMaxTTL := s.conf.CacheMaxTTL
|
||||||
@@ -207,6 +211,7 @@ func (s *Server) getDNSConfig(ctx context.Context) (c *jsonDNSConfig) {
|
|||||||
DNSSECEnabled: &enableDNSSEC,
|
DNSSECEnabled: &enableDNSSEC,
|
||||||
DisableIPv6: &aaaaDisabled,
|
DisableIPv6: &aaaaDisabled,
|
||||||
BlockedResponseTTL: &blockedResponseTTL,
|
BlockedResponseTTL: &blockedResponseTTL,
|
||||||
|
CacheEnabled: &cacheEnabled,
|
||||||
CacheSize: &cacheSize,
|
CacheSize: &cacheSize,
|
||||||
CacheMinTTL: &cacheMinTTL,
|
CacheMinTTL: &cacheMinTTL,
|
||||||
CacheMaxTTL: &cacheMaxTTL,
|
CacheMaxTTL: &cacheMaxTTL,
|
||||||
@@ -278,6 +283,7 @@ func (req *jsonDNSConfig) validate(
|
|||||||
ownAddrs addrPortSet,
|
ownAddrs addrPortSet,
|
||||||
sysResolvers SystemResolvers,
|
sysResolvers SystemResolvers,
|
||||||
privateNets netutil.SubnetSet,
|
privateNets netutil.SubnetSet,
|
||||||
|
curCacheSize uint32,
|
||||||
) (err error) {
|
) (err error) {
|
||||||
defer func() { err = errors.Annotate(err, "validating dns config: %w") }()
|
defer func() { err = errors.Annotate(err, "validating dns config: %w") }()
|
||||||
|
|
||||||
@@ -305,7 +311,7 @@ func (req *jsonDNSConfig) validate(
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = req.checkCacheTTL()
|
err = req.validateCacheSettings(curCacheSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Don't wrap the error since it's informative enough as is.
|
// Don't wrap the error since it's informative enough as is.
|
||||||
return err
|
return err
|
||||||
@@ -421,9 +427,14 @@ func (req *jsonDNSConfig) validateUpstreamDNSServers(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkCacheTTL returns an error if the configuration of the cache TTL is
|
// validateCacheSettings returns an error if the cache configuration is invalid.
|
||||||
// invalid.
|
func (req *jsonDNSConfig) validateCacheSettings(curCacheSize uint32) (err error) {
|
||||||
func (req *jsonDNSConfig) checkCacheTTL() (err error) {
|
err = req.validateCacheSize(curCacheSize)
|
||||||
|
if err != nil {
|
||||||
|
// Don't wrap the error because it's informative enough as is.
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if req.CacheMinTTL == nil && req.CacheMaxTTL == nil {
|
if req.CacheMinTTL == nil && req.CacheMaxTTL == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -440,6 +451,28 @@ func (req *jsonDNSConfig) checkCacheTTL() (err error) {
|
|||||||
return validateCacheTTL(minTTL, maxTTL)
|
return validateCacheTTL(minTTL, maxTTL)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validateCacheSize returns an error if the cache size configuration is
|
||||||
|
// invalid. It also explicitly sets CacheEnabled to support legacy behavior.
|
||||||
|
func (req *jsonDNSConfig) validateCacheSize(curCacheSize uint32) (err error) {
|
||||||
|
if req.CacheEnabled != nil && *req.CacheEnabled {
|
||||||
|
size := curCacheSize
|
||||||
|
if req.CacheSize != nil {
|
||||||
|
size = *req.CacheSize
|
||||||
|
}
|
||||||
|
|
||||||
|
if size == 0 {
|
||||||
|
return errors.Error("cache_size must be greater than zero when cache_enabled is true")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.CacheEnabled == nil && req.CacheSize != nil {
|
||||||
|
isEnabled := *req.CacheSize > 0
|
||||||
|
req.CacheEnabled = &isEnabled
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// checkRatelimitSubnetMaskLen returns an error if the length of the subnet mask
|
// checkRatelimitSubnetMaskLen returns an error if the length of the subnet mask
|
||||||
// for IPv4 or IPv6 addresses is invalid.
|
// for IPv4 or IPv6 addresses is invalid.
|
||||||
func (req *jsonDNSConfig) checkRatelimitSubnetMaskLen() (err error) {
|
func (req *jsonDNSConfig) checkRatelimitSubnetMaskLen() (err error) {
|
||||||
@@ -505,7 +538,7 @@ func (s *Server) handleSetConfig(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = req.validate(ourAddrs, s.sysResolvers, s.privateNets)
|
err = req.validate(ourAddrs, s.sysResolvers, s.privateNets, s.conf.CacheSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
aghhttp.Error(r, w, http.StatusBadRequest, "%s", err)
|
aghhttp.Error(r, w, http.StatusBadRequest, "%s", err)
|
||||||
|
|
||||||
@@ -598,6 +631,7 @@ func (s *Server) setConfigRestartable(dc *jsonDNSConfig) (shouldRestart bool) {
|
|||||||
setIfNotNil(&s.conf.FallbackDNS, dc.Fallbacks),
|
setIfNotNil(&s.conf.FallbackDNS, dc.Fallbacks),
|
||||||
setIfNotNil(&s.conf.EDNSClientSubnet.Enabled, dc.EDNSCSEnabled),
|
setIfNotNil(&s.conf.EDNSClientSubnet.Enabled, dc.EDNSCSEnabled),
|
||||||
setIfNotNil(&s.conf.EDNSClientSubnet.UseCustom, dc.EDNSCSUseCustom),
|
setIfNotNil(&s.conf.EDNSClientSubnet.UseCustom, dc.EDNSCSUseCustom),
|
||||||
|
setIfNotNil(&s.conf.CacheEnabled, dc.CacheEnabled),
|
||||||
setIfNotNil(&s.conf.CacheSize, dc.CacheSize),
|
setIfNotNil(&s.conf.CacheSize, dc.CacheSize),
|
||||||
setIfNotNil(&s.conf.CacheMinTTL, dc.CacheMinTTL),
|
setIfNotNil(&s.conf.CacheMinTTL, dc.CacheMinTTL),
|
||||||
setIfNotNil(&s.conf.CacheMaxTTL, dc.CacheMaxTTL),
|
setIfNotNil(&s.conf.CacheMaxTTL, dc.CacheMaxTTL),
|
||||||
|
|||||||
@@ -229,6 +229,9 @@ func TestDNSForwardHTTP_handleSetConfig(t *testing.T) {
|
|||||||
}, {
|
}, {
|
||||||
name: "cache_size",
|
name: "cache_size",
|
||||||
wantSet: "",
|
wantSet: "",
|
||||||
|
}, {
|
||||||
|
name: "cache_enabled",
|
||||||
|
wantSet: "",
|
||||||
}, {
|
}, {
|
||||||
name: "upstream_mode_parallel",
|
name: "upstream_mode_parallel",
|
||||||
wantSet: "",
|
wantSet: "",
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -72,6 +73,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -112,6 +114,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -79,6 +80,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -122,6 +124,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -165,6 +168,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -208,6 +212,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -253,6 +258,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -299,6 +305,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -342,6 +349,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -387,6 +395,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -432,6 +441,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -475,6 +485,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -518,6 +529,52 @@
|
|||||||
"cache_size": 1024,
|
"cache_size": 1024,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": true,
|
||||||
|
"cache_optimistic": false,
|
||||||
|
"resolve_clients": false,
|
||||||
|
"use_private_ptr_resolvers": false,
|
||||||
|
"local_ptr_upstreams": [],
|
||||||
|
"edns_cs_use_custom": false,
|
||||||
|
"edns_cs_custom_ip": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"cache_enabled": {
|
||||||
|
"req": {
|
||||||
|
"cache_enabled": true,
|
||||||
|
"cache_size": 1024
|
||||||
|
},
|
||||||
|
"want": {
|
||||||
|
"upstream_dns": [
|
||||||
|
"8.8.8.8:53",
|
||||||
|
"8.8.4.4:53"
|
||||||
|
],
|
||||||
|
"upstream_dns_file": "",
|
||||||
|
"bootstrap_dns": [
|
||||||
|
"9.9.9.10",
|
||||||
|
"149.112.112.10",
|
||||||
|
"2620:fe::10",
|
||||||
|
"2620:fe::fe:10"
|
||||||
|
],
|
||||||
|
"fallback_dns": [],
|
||||||
|
"protection_enabled": true,
|
||||||
|
"protection_disabled_until": null,
|
||||||
|
"ratelimit": 0,
|
||||||
|
"ratelimit_subnet_len_ipv4": 24,
|
||||||
|
"ratelimit_subnet_len_ipv6": 56,
|
||||||
|
"ratelimit_whitelist": [],
|
||||||
|
"blocking_mode": "default",
|
||||||
|
"blocking_ipv4": "",
|
||||||
|
"blocking_ipv6": "",
|
||||||
|
"blocked_response_ttl": 10,
|
||||||
|
"upstream_timeout": 10,
|
||||||
|
"edns_cs_enabled": false,
|
||||||
|
"dnssec_enabled": false,
|
||||||
|
"disable_ipv6": false,
|
||||||
|
"upstream_mode": "",
|
||||||
|
"cache_size": 1024,
|
||||||
|
"cache_ttl_min": 0,
|
||||||
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": true,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -561,6 +618,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -604,6 +662,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -649,6 +708,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -694,6 +754,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -738,6 +799,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -781,6 +843,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -826,6 +889,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -874,6 +938,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -917,6 +982,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -964,6 +1030,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -1007,6 +1074,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -1053,6 +1121,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
@@ -1096,6 +1165,7 @@
|
|||||||
"cache_size": 0,
|
"cache_size": 0,
|
||||||
"cache_ttl_min": 0,
|
"cache_ttl_min": 0,
|
||||||
"cache_ttl_max": 0,
|
"cache_ttl_max": 0,
|
||||||
|
"cache_enabled": false,
|
||||||
"cache_optimistic": false,
|
"cache_optimistic": false,
|
||||||
"resolve_clients": false,
|
"resolve_clients": false,
|
||||||
"use_private_ptr_resolvers": false,
|
"use_private_ptr_resolvers": false,
|
||||||
|
|||||||
@@ -466,7 +466,8 @@ var config = &configuration{
|
|||||||
}, {
|
}, {
|
||||||
Prefix: netip.MustParsePrefix("::1/128"),
|
Prefix: netip.MustParsePrefix("::1/128"),
|
||||||
}},
|
}},
|
||||||
CacheSize: 4 * 1024 * 1024,
|
CacheEnabled: true,
|
||||||
|
CacheSize: 4 * 1024 * 1024,
|
||||||
|
|
||||||
EDNSClientSubnet: &dnsforward.EDNSClientSubnet{
|
EDNSClientSubnet: &dnsforward.EDNSClientSubnet{
|
||||||
CustomIP: netip.Addr{},
|
CustomIP: netip.Addr{},
|
||||||
|
|||||||
@@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
## v0.108.0: API changes
|
## v0.108.0: API changes
|
||||||
|
|
||||||
|
## v0.107.64: API changes
|
||||||
|
|
||||||
|
- The new field `"cache_enabled"` in `GET /control/dns_info` and `POST /control/dns_config`. Setting this flag to true turns the DNS-response cache on and requires a positive `cache_size` value (or a positive `dns.cache_size` in the configuration file).
|
||||||
|
|
||||||
## v0.107.58: API changes
|
## v0.107.58: API changes
|
||||||
|
|
||||||
### The ability to check rules for query types and/or clients: GET /control/check_host
|
### The ability to check rules for query types and/or clients: GET /control/check_host
|
||||||
|
|||||||
@@ -1559,6 +1559,14 @@
|
|||||||
'type': 'integer'
|
'type': 'integer'
|
||||||
'cache_ttl_max':
|
'cache_ttl_max':
|
||||||
'type': 'integer'
|
'type': 'integer'
|
||||||
|
'cache_enabled':
|
||||||
|
'type': 'boolean'
|
||||||
|
'description': |
|
||||||
|
Enables or disables the DNS response cache.
|
||||||
|
|
||||||
|
If `cache_enabled` is `true`, the companion field `cache_size` must
|
||||||
|
be present and greater than 0, or the `dns.cache_size` setting in
|
||||||
|
the configuration file must already be greater than 0.
|
||||||
'cache_optimistic':
|
'cache_optimistic':
|
||||||
'type': 'boolean'
|
'type': 'boolean'
|
||||||
'upstream_mode':
|
'upstream_mode':
|
||||||
|
|||||||
Reference in New Issue
Block a user