mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2026-12-04 14:13:09 +09:00
Pull request 2549: AGDNS-3507-ignored-enabled
Squashed commit of the following:
commit 860c6a786d396bec692e8247bebf561a9b1281fc
Author: f.setrakov <f.setrakov@adguard.com>
Date: Fri Dec 26 12:23:39 2025 +0300
aghnet: imp doc
commit 7794c9ca2e5fc7127c29ac922e49115a5d53d1a1
Author: f.setrakov <f.setrakov@adguard.com>
Date: Thu Dec 25 15:18:18 2025 +0300
all: fix stats ignored enabled
commit 5dd81d1087a23a3ee4ba5a37d90e479db647c0da
Merge: e17c2b382 eb6f3324b
Author: f.setrakov <f.setrakov@adguard.com>
Date: Thu Dec 25 13:26:27 2025 +0300
Merge branch 'master' into AGDNS-3507-ignored-enabled
commit e17c2b382911e508124f694a1065e31353158148
Author: f.setrakov <f.setrakov@adguard.com>
Date: Wed Dec 24 18:15:14 2025 +0300
all: add ignored_enabled field to config modifier
commit 565666fb73281722d7f6a49051123170bb41411f
Author: Ildar Kamalov <ik@adguard.com>
Date: Tue Dec 23 14:40:50 2025 +0300
ADG-11272 add ignore enabled settings for logs and stats config
commit 6f426bc31fa5346568ba3d8dafdc866586759396
Author: f.setrakov <f.setrakov@adguard.com>
Date: Tue Dec 16 13:46:26 2025 +0300
openapi: imp changelog
commit 0210a1ea7732daed044894148d03fde4095b914f
Author: f.setrakov <f.setrakov@adguard.com>
Date: Tue Dec 16 13:41:55 2025 +0300
all: imp docs
commit 2f73d467c52738424891b93c80dac9d0aadf3e3c
Author: f.setrakov <f.setrakov@adguard.com>
Date: Mon Dec 15 17:54:06 2025 +0300
all: imp docs
commit b972b73058fe92c82288e8189242e4d1a4ff75d9
Author: f.setrakov <f.setrakov@adguard.com>
Date: Mon Dec 15 15:29:06 2025 +0300
all: add ignored_enabled to api and cfg
This commit is contained in:
1 parent
eb6f3324bc
commit
ff8ecd9872
27 files changed
+510
-50
No files matched your search
@@ -17,6 +17,44 @@ See also the [v0.107.72 GitHub milestone][ms-v0.107.72].
|
||||
|
||||
NOTE: Add new changes BELOW THIS COMMENT.
|
||||
-->
|
||||
|
||||
### Added
|
||||
|
||||
- New field `"ignored_enabled"` in `GetStatsConfigResponse` or `GetQueryLogConfigResponse`. See `openapi/openapi.yaml` for details.
|
||||
|
||||
#### Configuration changes
|
||||
|
||||
In this release, the schema version has changed from 32 to 33.
|
||||
|
||||
- Added a new boolean field `ignored_enabled` in querylog and statistics config.
|
||||
|
||||
```yaml
|
||||
# BEFORE:
|
||||
'querylog':
|
||||
# …
|
||||
'ignored':
|
||||
- '|.^'
|
||||
'statistics':
|
||||
# …
|
||||
'ignored':
|
||||
- '|.^'
|
||||
|
||||
# AFTER:
|
||||
'querylog':
|
||||
# …
|
||||
'ignored':
|
||||
- '|.^'
|
||||
'ignored_enabled': true
|
||||
'statistics':
|
||||
# …
|
||||
'ignored':
|
||||
- '|.^'
|
||||
'ignored_enabled': true
|
||||
```
|
||||
|
||||
To roll back this change, set the `schema_version` back to `32`.
|
||||
|
||||
|
||||
<!--
|
||||
NOTE: Add new changes ABOVE THIS COMMENT.
|
||||
-->
|
||||
|
||||
@@ -570,8 +570,8 @@
|
||||
"statistics_enable": "Enable statistics",
|
||||
"ignore_domains": "Ignored domains (separated by newline)",
|
||||
"ignore_domains_title": "Ignored domains",
|
||||
"ignore_domains_desc_stats": "Queries matching these rules are not written to the statistics",
|
||||
"ignore_domains_desc_query": "Queries matching these rules are not written to the query log",
|
||||
"ignore_domains_desc_stats": "If enabled, queries matching these rules are not written to the statistics",
|
||||
"ignore_domains_desc_query": "If enabled, queries matching these rules are not written to the query log",
|
||||
"interval_hours": "{{count}} hour",
|
||||
"interval_hours_plural": "{{count}} hours",
|
||||
"filters_configuration": "Filters configuration",
|
||||
|
||||
@@ -30,6 +30,7 @@ export type FormValues = {
|
||||
interval: number;
|
||||
customInterval?: number | null;
|
||||
ignored: string;
|
||||
ignored_enabled: boolean;
|
||||
};
|
||||
|
||||
type Props = {
|
||||
@@ -57,6 +58,7 @@ export const Form = ({ initialValues, processing, processingReset, onSubmit, onR
|
||||
interval: initialValues.interval || DAY,
|
||||
customInterval: initialValues.customInterval || null,
|
||||
ignored: initialValues.ignored || '',
|
||||
ignored_enabled: initialValues.ignored_enabled ?? true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -180,12 +182,20 @@ export const Form = ({ initialValues, processing, processingReset, onSubmit, onR
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label className="form__label form__label--with-desc">
|
||||
<Trans>ignore_domains_title</Trans>
|
||||
</label>
|
||||
|
||||
<div className="form__desc form__desc--top">
|
||||
<Trans>ignore_domains_desc_query</Trans>
|
||||
<div className="form__group form__group--settings">
|
||||
<Controller
|
||||
name="ignored_enabled"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Checkbox
|
||||
{...field}
|
||||
data-testid="logs_config_ignored_enabled"
|
||||
title={t('ignore_domains_title')}
|
||||
subtitle={t('ignore_domains_desc_query')}
|
||||
disabled={processing}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="form__group form__group--settings">
|
||||
|
||||
@@ -13,6 +13,7 @@ interface LogsConfigProps {
|
||||
anonymize_client_ip: boolean;
|
||||
processing: boolean;
|
||||
ignored: unknown[];
|
||||
ignoredEnabled: boolean;
|
||||
processingClear: boolean;
|
||||
setLogsConfig: (...args: unknown[]) => unknown;
|
||||
clearLogs: (...args: unknown[]) => unknown;
|
||||
@@ -59,6 +60,7 @@ class LogsConfig extends Component<LogsConfigProps> {
|
||||
processingClear,
|
||||
anonymize_client_ip,
|
||||
ignored,
|
||||
ignoredEnabled,
|
||||
customInterval,
|
||||
} = this.props;
|
||||
|
||||
@@ -72,6 +74,7 @@ class LogsConfig extends Component<LogsConfigProps> {
|
||||
customInterval,
|
||||
anonymize_client_ip,
|
||||
ignored: ignored?.join('\n'),
|
||||
ignored_enabled: ignoredEnabled,
|
||||
}}
|
||||
processing={processing}
|
||||
processingReset={processingClear}
|
||||
|
||||
@@ -27,6 +27,7 @@ export type FormValues = {
|
||||
interval: number;
|
||||
customInterval?: number | null;
|
||||
ignored: string;
|
||||
ignored_enabled: boolean;
|
||||
};
|
||||
|
||||
const defaultFormValues = {
|
||||
@@ -34,6 +35,7 @@ const defaultFormValues = {
|
||||
interval: DAY,
|
||||
customInterval: null,
|
||||
ignored: '',
|
||||
ignored_enabled: true,
|
||||
};
|
||||
|
||||
type Props = {
|
||||
@@ -162,12 +164,20 @@ export const Form = ({ initialValues, processing, processingReset, onSubmit, onR
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="form__label form__label--with-desc">
|
||||
<Trans>ignore_domains_title</Trans>
|
||||
</div>
|
||||
|
||||
<div className="form__desc form__desc--top">
|
||||
<Trans>ignore_domains_desc_stats</Trans>
|
||||
<div className="form__group form__group--settings">
|
||||
<Controller
|
||||
name="ignored_enabled"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Checkbox
|
||||
{...field}
|
||||
data-testid="stats_config_ignored_enabled"
|
||||
title={t('ignore_domains_title')}
|
||||
subtitle={t('ignore_domains_desc_stats')}
|
||||
disabled={processing}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="form__group form__group--settings">
|
||||
|
||||
@@ -10,6 +10,7 @@ interface StatsConfigProps {
|
||||
interval: number;
|
||||
customInterval?: number;
|
||||
ignored: unknown[];
|
||||
ignoredEnabled: boolean;
|
||||
enabled: boolean;
|
||||
processing: boolean;
|
||||
processingReset: boolean;
|
||||
@@ -19,7 +20,7 @@ interface StatsConfigProps {
|
||||
}
|
||||
|
||||
class StatsConfig extends Component<StatsConfigProps> {
|
||||
handleFormSubmit = ({ enabled, interval, ignored, customInterval }: FormValues) => {
|
||||
handleFormSubmit = ({ enabled, interval, ignored, ignored_enabled, customInterval }: FormValues) => {
|
||||
const { t, interval: prevInterval } = this.props;
|
||||
const newInterval = customInterval ? customInterval * HOUR : interval;
|
||||
|
||||
@@ -27,6 +28,7 @@ class StatsConfig extends Component<StatsConfigProps> {
|
||||
enabled,
|
||||
interval: newInterval,
|
||||
ignored: ignored ? ignored.split('\n') : [],
|
||||
ignored_enabled,
|
||||
};
|
||||
|
||||
if (config.interval < prevInterval) {
|
||||
@@ -54,6 +56,7 @@ class StatsConfig extends Component<StatsConfigProps> {
|
||||
processing,
|
||||
processingReset,
|
||||
ignored,
|
||||
ignoredEnabled,
|
||||
enabled,
|
||||
} = this.props;
|
||||
|
||||
@@ -66,6 +69,7 @@ class StatsConfig extends Component<StatsConfigProps> {
|
||||
customInterval,
|
||||
enabled,
|
||||
ignored: ignored.join('\n'),
|
||||
ignored_enabled: ignoredEnabled,
|
||||
}}
|
||||
processing={processing}
|
||||
processingReset={processingReset}
|
||||
|
||||
@@ -58,6 +58,7 @@ interface SettingsProps {
|
||||
customInterval?: number;
|
||||
enabled?: boolean;
|
||||
ignored?: unknown[];
|
||||
ignored_enabled?: boolean;
|
||||
processingSetConfig?: boolean;
|
||||
processingReset?: boolean;
|
||||
};
|
||||
@@ -70,6 +71,7 @@ interface SettingsProps {
|
||||
processingClear?: boolean;
|
||||
processingGetConfig?: boolean;
|
||||
ignored?: unknown[];
|
||||
ignored_enabled?: boolean;
|
||||
};
|
||||
filtering?: {
|
||||
interval?: number;
|
||||
@@ -195,6 +197,7 @@ class Settings extends Component<SettingsProps> {
|
||||
<LogsConfig
|
||||
enabled={queryLogs.enabled}
|
||||
ignored={queryLogs.ignored}
|
||||
ignoredEnabled={queryLogs.ignored_enabled}
|
||||
interval={queryLogs.interval}
|
||||
customInterval={queryLogs.customInterval}
|
||||
anonymize_client_ip={queryLogs.anonymize_client_ip}
|
||||
@@ -210,6 +213,7 @@ class Settings extends Component<SettingsProps> {
|
||||
interval={stats.interval}
|
||||
customInterval={stats.customInterval}
|
||||
ignored={stats.ignored}
|
||||
ignoredEnabled={stats.ignored_enabled}
|
||||
enabled={stats.enabled}
|
||||
processing={stats.processingSetConfig}
|
||||
processingReset={stats.processingReset}
|
||||
|
||||
@@ -197,6 +197,7 @@ export type StatsData = {
|
||||
processingReset: boolean;
|
||||
interval: number;
|
||||
customInterval?: number;
|
||||
ignored_enabled: boolean;
|
||||
dnsQueries: number[];
|
||||
blockedFiltering: number[];
|
||||
replacedParental: number[];
|
||||
@@ -372,6 +373,7 @@ export type QueryLogsData = {
|
||||
isDetailed: boolean;
|
||||
isEntireLog: boolean;
|
||||
customInterval: any;
|
||||
ignored_enabled: boolean;
|
||||
};
|
||||
|
||||
export type ServicesData = {
|
||||
@@ -576,6 +578,7 @@ export const initialState: RootState = {
|
||||
isDetailed: true,
|
||||
isEntireLog: false,
|
||||
customInterval: null,
|
||||
ignored_enabled: true,
|
||||
},
|
||||
rewrites: {
|
||||
processing: true,
|
||||
@@ -607,6 +610,7 @@ export const initialState: RootState = {
|
||||
processingReset: false,
|
||||
interval: DAY,
|
||||
customInterval: null,
|
||||
ignored_enabled: true,
|
||||
dnsQueries: [],
|
||||
blockedFiltering: [],
|
||||
replacedParental: [],
|
||||
|
||||
@@ -137,6 +137,7 @@ const queryLogs = handleActions(
|
||||
isDetailed: true,
|
||||
isEntireLog: false,
|
||||
customInterval: null,
|
||||
ignored_enabled: true,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -129,6 +129,7 @@ const stats = handleActions(
|
||||
processingReset: false,
|
||||
interval: DAY,
|
||||
customInterval: null,
|
||||
ignored_enabled: true,
|
||||
...defaultStats,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -19,11 +19,15 @@ type IgnoreEngine struct {
|
||||
|
||||
// ignored is the list of rules for ignoring hostnames.
|
||||
ignored []string
|
||||
|
||||
// enabled determines whether ignoring is enabled.
|
||||
enabled bool
|
||||
}
|
||||
|
||||
// NewIgnoreEngine creates a new instance of the IgnoreEngine and stores the
|
||||
// list of rules for ignoring hostnames.
|
||||
func NewIgnoreEngine(ignored []string) (e *IgnoreEngine, err error) {
|
||||
// list of rules for ignoring hostnames. If enabled is set to false, hostnames
|
||||
// will never be ignored.
|
||||
func NewIgnoreEngine(ignored []string, enabled bool) (e *IgnoreEngine, err error) {
|
||||
ruleLists := []filterlist.Interface{
|
||||
filterlist.NewString(&filterlist.StringConfig{
|
||||
RulesText: strings.ToLower(strings.Join(ignored, "\n")),
|
||||
@@ -38,12 +42,13 @@ func NewIgnoreEngine(ignored []string) (e *IgnoreEngine, err error) {
|
||||
return &IgnoreEngine{
|
||||
engine: urlfilter.NewDNSEngine(ruleStorage),
|
||||
ignored: ignored,
|
||||
enabled: enabled,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Has returns true if IgnoreEngine matches the host.
|
||||
func (e *IgnoreEngine) Has(host string) (ignore bool) {
|
||||
if e == nil {
|
||||
if e == nil || !e.enabled {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -56,3 +61,8 @@ func (e *IgnoreEngine) Has(host string) (ignore bool) {
|
||||
func (e *IgnoreEngine) Values() (ignored []string) {
|
||||
return slices.Clone(e.ignored)
|
||||
}
|
||||
|
||||
// IsEnabled returns true if hostnames ignoring is enabled.
|
||||
func (e *IgnoreEngine) IsEnabled() (enabled bool) {
|
||||
return e.enabled
|
||||
}
|
||||
@@ -14,7 +14,7 @@ func TestIgnoreEngine_Has(t *testing.T) {
|
||||
"|.^",
|
||||
}
|
||||
|
||||
engine, err := aghnet.NewIgnoreEngine(hostnames)
|
||||
engine, err := aghnet.NewIgnoreEngine(hostnames, true)
|
||||
require.NotNil(t, engine)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
package configmigrate
|
||||
|
||||
// LastSchemaVersion is the most recent schema version.
|
||||
const LastSchemaVersion uint = 32
|
||||
const LastSchemaVersion uint = 33
|
||||
@@ -143,6 +143,7 @@ func (m *Migrator) upgradeConfigSchema(
|
||||
29: m.migrateTo30,
|
||||
30: m.migrateTo31,
|
||||
31: m.migrateTo32,
|
||||
32: m.migrateTo33,
|
||||
}
|
||||
|
||||
for i, migrate := range upgrades[current:target] {
|
||||
|
||||
@@ -207,6 +207,10 @@ func TestMigrateConfig_Migrate(t *testing.T) {
|
||||
yamlEqFunc: require.YAMLEq,
|
||||
name: "v32",
|
||||
targetVersion: 32,
|
||||
}, {
|
||||
yamlEqFunc: require.YAMLEq,
|
||||
name: "v33",
|
||||
targetVersion: 33,
|
||||
}}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
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
|
||||
cache_optimistic_answer_ttl: 30s
|
||||
cache_optimistic_max_age: 12h
|
||||
edns_client_subnet:
|
||||
enabled: true
|
||||
use_custom: false
|
||||
custom_ip: ""
|
||||
filtering:
|
||||
filtering_enabled: true
|
||||
parental_enabled: false
|
||||
safebrowsing_enabled: false
|
||||
rewrites:
|
||||
- domain: test.example
|
||||
answer: 192.0.2.0
|
||||
enabled: true
|
||||
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: 32
|
||||
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
|
||||
@@ -0,0 +1,128 @@
|
||||
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
|
||||
cache_optimistic_answer_ttl: 30s
|
||||
cache_optimistic_max_age: 12h
|
||||
edns_client_subnet:
|
||||
enabled: true
|
||||
use_custom: false
|
||||
custom_ip: ""
|
||||
filtering:
|
||||
filtering_enabled: true
|
||||
parental_enabled: false
|
||||
safebrowsing_enabled: false
|
||||
rewrites:
|
||||
- domain: test.example
|
||||
answer: 192.0.2.0
|
||||
enabled: true
|
||||
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: 33
|
||||
user_rules: []
|
||||
querylog:
|
||||
enabled: true
|
||||
file_enabled: true
|
||||
interval: 720h
|
||||
size_memory: 1000
|
||||
ignored:
|
||||
- '|.^'
|
||||
ignored_enabled: true
|
||||
statistics:
|
||||
enabled: true
|
||||
interval: 240h
|
||||
ignored:
|
||||
- '|.^'
|
||||
ignored_enabled: true
|
||||
os:
|
||||
group: ''
|
||||
rlimit_nofile: 123
|
||||
user: ''
|
||||
log:
|
||||
file: ""
|
||||
max_backups: 0
|
||||
max_size: 100
|
||||
max_age: 3
|
||||
compress: true
|
||||
local_time: false
|
||||
verbose: true
|
||||
@@ -0,0 +1,58 @@
|
||||
package configmigrate
|
||||
|
||||
import "context"
|
||||
|
||||
// migrateTo33 performs the following changes:
|
||||
//
|
||||
// # BEFORE:
|
||||
// 'querylog':
|
||||
// # …
|
||||
// 'ignored':
|
||||
// - '|.^'
|
||||
// 'statistics':
|
||||
// # …
|
||||
// 'ignored':
|
||||
// - '|.^'
|
||||
//
|
||||
// # AFTER:
|
||||
// 'querylog':
|
||||
// # …
|
||||
// 'ignored':
|
||||
// - '|.^'
|
||||
// 'ignored_enabled': true
|
||||
// 'statistics':
|
||||
// # …
|
||||
// 'ignored':
|
||||
// - '|.^'
|
||||
// 'ignored_enabled': true
|
||||
//
|
||||
// If ignored is empty, then ignored_enabled should be false.
|
||||
func (m Migrator) migrateTo33(_ context.Context, diskConf yobj) (err error) {
|
||||
diskConf["schema_version"] = 33
|
||||
|
||||
queryLogConf, ok, err := fieldVal[yobj](diskConf, "querylog")
|
||||
if !ok {
|
||||
return err
|
||||
}
|
||||
|
||||
ignored, ok, err := fieldVal[yarr](queryLogConf, "ignored")
|
||||
if !ok {
|
||||
return err
|
||||
}
|
||||
|
||||
queryLogConf["ignored_enabled"] = len(ignored) > 0
|
||||
|
||||
statisticsConf, ok, err := fieldVal[yobj](diskConf, "statistics")
|
||||
if !ok {
|
||||
return err
|
||||
}
|
||||
|
||||
ignored, ok, err = fieldVal[yarr](statisticsConf, "ignored")
|
||||
if !ok {
|
||||
return err
|
||||
}
|
||||
|
||||
statisticsConf["ignored_enabled"] = len(ignored) > 0
|
||||
|
||||
return nil
|
||||
}
|
||||
+20
-8
@@ -410,6 +410,10 @@ type queryLogConfig struct {
|
||||
// Enabled defines if the query log is enabled.
|
||||
Enabled bool `yaml:"enabled"`
|
||||
|
||||
// IgnoredEnabled defines whether hosts from the ignored list should be
|
||||
// ignored.
|
||||
IgnoredEnabled bool `yaml:"ignored_enabled"`
|
||||
|
||||
// FileEnabled defines, if the query log is written to the file.
|
||||
FileEnabled bool `yaml:"file_enabled"`
|
||||
}
|
||||
@@ -427,6 +431,10 @@ type statsConfig struct {
|
||||
|
||||
// Enabled defines if the statistics are enabled.
|
||||
Enabled bool `yaml:"enabled"`
|
||||
|
||||
// IgnoredEnabled defines whether hosts from the ignored list should be
|
||||
// ignored.
|
||||
IgnoredEnabled bool `yaml:"ignored_enabled"`
|
||||
}
|
||||
|
||||
// Default block host constants.
|
||||
@@ -497,16 +505,18 @@ var config = &configuration{
|
||||
PortDNSOverQUIC: defaultPortQUIC,
|
||||
},
|
||||
QueryLog: queryLogConfig{
|
||||
Enabled: true,
|
||||
FileEnabled: true,
|
||||
Interval: timeutil.Duration(90 * timeutil.Day),
|
||||
MemSize: 1000,
|
||||
Ignored: []string{},
|
||||
Enabled: true,
|
||||
FileEnabled: true,
|
||||
Interval: timeutil.Duration(90 * timeutil.Day),
|
||||
MemSize: 1000,
|
||||
Ignored: []string{},
|
||||
IgnoredEnabled: false,
|
||||
},
|
||||
Stats: statsConfig{
|
||||
Enabled: true,
|
||||
Interval: timeutil.Duration(1 * timeutil.Day),
|
||||
Ignored: []string{},
|
||||
Enabled: true,
|
||||
Interval: timeutil.Duration(1 * timeutil.Day),
|
||||
Ignored: []string{},
|
||||
IgnoredEnabled: false,
|
||||
},
|
||||
// NOTE: Keep these parameters in sync with the one put into
|
||||
// client/src/helpers/filters/filters.ts by scripts/vetted-filters.
|
||||
@@ -867,6 +877,7 @@ func (c *configuration) write(
|
||||
config.Stats.Interval = timeutil.Duration(statsConf.Limit)
|
||||
config.Stats.Enabled = statsConf.Enabled
|
||||
config.Stats.Ignored = statsConf.Ignored.Values()
|
||||
config.Stats.IgnoredEnabled = statsConf.Ignored.IsEnabled()
|
||||
}
|
||||
|
||||
if globalContext.queryLog != nil {
|
||||
@@ -878,6 +889,7 @@ func (c *configuration) write(
|
||||
config.QueryLog.Interval = timeutil.Duration(dc.RotationIvl)
|
||||
config.QueryLog.MemSize = dc.MemSize
|
||||
config.QueryLog.Ignored = dc.Ignored.Values()
|
||||
config.QueryLog.IgnoredEnabled = dc.Ignored.IsEnabled()
|
||||
}
|
||||
|
||||
if globalContext.filters != nil {
|
||||
|
||||
@@ -64,7 +64,7 @@ func initDNS(
|
||||
ShouldCountClient: globalContext.clients.shouldCountClient,
|
||||
}
|
||||
|
||||
engine, err := aghnet.NewIgnoreEngine(config.Stats.Ignored)
|
||||
engine, err := aghnet.NewIgnoreEngine(config.Stats.Ignored, config.Stats.IgnoredEnabled)
|
||||
if err != nil {
|
||||
return fmt.Errorf("statistics: ignored list: %w", err)
|
||||
}
|
||||
@@ -89,7 +89,7 @@ func initDNS(
|
||||
FileEnabled: config.QueryLog.FileEnabled,
|
||||
}
|
||||
|
||||
engine, err = aghnet.NewIgnoreEngine(config.QueryLog.Ignored)
|
||||
engine, err = aghnet.NewIgnoreEngine(config.QueryLog.Ignored, config.QueryLog.IgnoredEnabled)
|
||||
if err != nil {
|
||||
return fmt.Errorf("querylog: ignored list: %w", err)
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ type getConfigResp struct {
|
||||
// be able to tell when it's set without using pointers.
|
||||
Enabled aghalg.NullBool `json:"enabled"`
|
||||
|
||||
IgnoredEnabled aghalg.NullBool `json:"ignored_enabled"`
|
||||
|
||||
// AnonymizeClientIP shows if the clients' IP addresses must be anonymized.
|
||||
// It is an aghalg.NullBool to be able to tell when it's set without using
|
||||
// pointers.
|
||||
@@ -140,6 +142,7 @@ func (l *queryLog) handleGetQueryLogConfig(w http.ResponseWriter, r *http.Reques
|
||||
Enabled: aghalg.BoolToNullBool(l.conf.Enabled),
|
||||
AnonymizeClientIP: aghalg.BoolToNullBool(l.conf.AnonymizeClientIP),
|
||||
Ignored: l.conf.Ignored.Values(),
|
||||
IgnoredEnabled: aghalg.BoolToNullBool(l.conf.Ignored.IsEnabled()),
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -232,7 +235,14 @@ func (l *queryLog) handlePutQueryLogConfig(w http.ResponseWriter, r *http.Reques
|
||||
return
|
||||
}
|
||||
|
||||
engine, err := aghnet.NewIgnoreEngine(newConf.Ignored)
|
||||
var ignoredEnabled bool
|
||||
if newConf.IgnoredEnabled == aghalg.NBNull {
|
||||
ignoredEnabled = len(newConf.Ignored) > 0
|
||||
} else {
|
||||
ignoredEnabled = newConf.IgnoredEnabled == aghalg.NBTrue
|
||||
}
|
||||
|
||||
engine, err := aghnet.NewIgnoreEngine(newConf.Ignored, ignoredEnabled)
|
||||
if err != nil {
|
||||
aghhttp.ErrorAndLog(
|
||||
ctx,
|
||||
@@ -315,8 +325,8 @@ func (l *queryLog) applyQueryLogConfig(
|
||||
conf.Ignored = engine
|
||||
conf.RotationIvl = ivl
|
||||
conf.Enabled = newConf.Enabled == aghalg.NBTrue
|
||||
|
||||
conf.AnonymizeClientIP = newConf.AnonymizeClientIP == aghalg.NBTrue
|
||||
|
||||
if conf.AnonymizeClientIP {
|
||||
l.anonymizer.Store(AnonymizeIP)
|
||||
} else {
|
||||
|
||||
@@ -272,7 +272,7 @@ func TestQueryLogShouldLog(t *testing.T) {
|
||||
ignoredRoot,
|
||||
}
|
||||
|
||||
engine, err := aghnet.NewIgnoreEngine(ignored)
|
||||
engine, err := aghnet.NewIgnoreEngine(ignored, true)
|
||||
require.NoError(t, err)
|
||||
|
||||
findClient := func(ids []string) (c *Client, err error) {
|
||||
|
||||
+15
-4
@@ -94,6 +94,9 @@ type getConfigResp struct {
|
||||
// Enabled shows if statistics are enabled. It is an aghalg.NullBool to be
|
||||
// able to tell when it's set without using pointers.
|
||||
Enabled aghalg.NullBool `json:"enabled"`
|
||||
|
||||
// IgnoredEnabled defines if ignored list is enabled.
|
||||
IgnoredEnabled aghalg.NullBool `json:"ignored_enabled"`
|
||||
}
|
||||
|
||||
// handleStatsInfo is the handler for the GET /control/stats_info HTTP API.
|
||||
@@ -136,9 +139,10 @@ func (s *StatsCtx) handleGetStatsConfig(w http.ResponseWriter, r *http.Request)
|
||||
defer s.confMu.RUnlock()
|
||||
|
||||
resp = &getConfigResp{
|
||||
Ignored: s.ignored.Values(),
|
||||
Interval: float64(s.limit.Milliseconds()),
|
||||
Enabled: aghalg.BoolToNullBool(s.enabled),
|
||||
Ignored: s.ignored.Values(),
|
||||
IgnoredEnabled: aghalg.BoolToNullBool(s.ignored.IsEnabled()),
|
||||
Interval: float64(s.limit.Milliseconds()),
|
||||
Enabled: aghalg.BoolToNullBool(s.enabled),
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -188,7 +192,14 @@ func (s *StatsCtx) handlePutStatsConfig(w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
engine, err := aghnet.NewIgnoreEngine(reqData.Ignored)
|
||||
var ignoredEnabled bool
|
||||
if reqData.IgnoredEnabled == aghalg.NBNull {
|
||||
ignoredEnabled = len(reqData.Ignored) > 0
|
||||
} else {
|
||||
ignoredEnabled = reqData.IgnoredEnabled == aghalg.NBTrue
|
||||
}
|
||||
|
||||
engine, err := aghnet.NewIgnoreEngine(reqData.Ignored, ignoredEnabled)
|
||||
if err != nil {
|
||||
aghhttp.ErrorAndLog(ctx, s.logger, r, w, http.StatusUnprocessableEntity, "ignored: %s", err)
|
||||
|
||||
|
||||
@@ -45,27 +45,30 @@ func TestHandleStatsConfig(t *testing.T) {
|
||||
}{{
|
||||
name: "set_ivl_1_minIvl",
|
||||
body: getConfigResp{
|
||||
Enabled: aghalg.NBTrue,
|
||||
Interval: float64(minIvl.Milliseconds()),
|
||||
Ignored: []string{},
|
||||
Enabled: aghalg.NBTrue,
|
||||
Interval: float64(minIvl.Milliseconds()),
|
||||
Ignored: []string{},
|
||||
IgnoredEnabled: aghalg.NBFalse,
|
||||
},
|
||||
wantCode: http.StatusOK,
|
||||
wantErr: "",
|
||||
}, {
|
||||
name: "small_interval",
|
||||
body: getConfigResp{
|
||||
Enabled: aghalg.NBTrue,
|
||||
Interval: float64(smallIvl.Milliseconds()),
|
||||
Ignored: []string{},
|
||||
Enabled: aghalg.NBTrue,
|
||||
Interval: float64(smallIvl.Milliseconds()),
|
||||
Ignored: []string{},
|
||||
IgnoredEnabled: aghalg.NBFalse,
|
||||
},
|
||||
wantCode: http.StatusUnprocessableEntity,
|
||||
wantErr: "unsupported interval: less than an hour\n",
|
||||
}, {
|
||||
name: "big_interval",
|
||||
body: getConfigResp{
|
||||
Enabled: aghalg.NBTrue,
|
||||
Interval: float64(maxIvl.Milliseconds() + minIvl.Milliseconds()),
|
||||
Ignored: []string{},
|
||||
Enabled: aghalg.NBTrue,
|
||||
Interval: float64(maxIvl.Milliseconds() + minIvl.Milliseconds()),
|
||||
Ignored: []string{},
|
||||
IgnoredEnabled: aghalg.NBFalse,
|
||||
},
|
||||
wantCode: http.StatusUnprocessableEntity,
|
||||
wantErr: "unsupported interval: more than a year\n",
|
||||
@@ -77,15 +80,17 @@ func TestHandleStatsConfig(t *testing.T) {
|
||||
Ignored: []string{
|
||||
"ignor.ed",
|
||||
},
|
||||
IgnoredEnabled: aghalg.NBTrue,
|
||||
},
|
||||
wantCode: http.StatusOK,
|
||||
wantErr: "",
|
||||
}, {
|
||||
name: "enabled_is_null",
|
||||
body: getConfigResp{
|
||||
Enabled: aghalg.NBNull,
|
||||
Interval: float64(minIvl.Milliseconds()),
|
||||
Ignored: []string{},
|
||||
Enabled: aghalg.NBNull,
|
||||
Interval: float64(minIvl.Milliseconds()),
|
||||
Ignored: []string{},
|
||||
IgnoredEnabled: aghalg.NBFalse,
|
||||
},
|
||||
wantCode: http.StatusUnprocessableEntity,
|
||||
wantErr: "enabled is null\n",
|
||||
|
||||
@@ -230,7 +230,7 @@ func TestShouldCount(t *testing.T) {
|
||||
ignored2 = "ignored.to"
|
||||
)
|
||||
ignored := []string{ignored1, ignored2}
|
||||
engine, err := aghnet.NewIgnoreEngine(ignored)
|
||||
engine, err := aghnet.NewIgnoreEngine(ignored, true)
|
||||
require.NoError(t, err)
|
||||
|
||||
s, err := stats.New(stats.Config{
|
||||
|
||||
@@ -2,6 +2,16 @@
|
||||
|
||||
<!-- TODO(a.garipov): Reformat in accordance with the KeepAChangelog spec. -->
|
||||
|
||||
## v0.107.72: API changes
|
||||
|
||||
### New `ignored_enabled` field in `GetStatsConfigResponse` and `GetQueryLogConfigResponse`
|
||||
|
||||
- The new field `ignored_enabled` indicates whether the host names in the ignored array should be ignored. This field has been added for the following endpoints:
|
||||
- `GET /control/querylog/config`
|
||||
- `PUT /control/querylog/config/update`
|
||||
- `GET /control/stats/config`
|
||||
- `PUT /control/stats/config/update`
|
||||
|
||||
## v0.107.70: API changes
|
||||
|
||||
### New `"start_time"` field in 'GET /control/status'
|
||||
|
||||
@@ -2000,6 +2000,11 @@
|
||||
'type': 'array'
|
||||
'items':
|
||||
'type': 'string'
|
||||
'ignored_enabled':
|
||||
'type': 'boolean'
|
||||
'description': >
|
||||
If true, the host names in the `ignored` array are excluded from the
|
||||
statistics.
|
||||
'PutStatsConfigUpdateRequest':
|
||||
'$ref': '#/components/schemas/GetStatsConfigResponse'
|
||||
'DhcpConfig':
|
||||
@@ -2429,6 +2434,11 @@
|
||||
'type': 'array'
|
||||
'items':
|
||||
'type': 'string'
|
||||
'ignored_enabled':
|
||||
'type': 'boolean'
|
||||
'description': >
|
||||
If true, the host names in the `ignored` array are excluded from the
|
||||
query log.
|
||||
'PutQueryLogConfigUpdateRequest':
|
||||
'$ref': '#/components/schemas/GetQueryLogConfigResponse'
|
||||
'ResultRule':
|
||||
|
||||
Reference in new issue
Block a user