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.
|
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.
|
NOTE: Add new changes ABOVE THIS COMMENT.
|
||||||
-->
|
-->
|
||||||
|
|||||||
@@ -570,8 +570,8 @@
|
|||||||
"statistics_enable": "Enable statistics",
|
"statistics_enable": "Enable statistics",
|
||||||
"ignore_domains": "Ignored domains (separated by newline)",
|
"ignore_domains": "Ignored domains (separated by newline)",
|
||||||
"ignore_domains_title": "Ignored domains",
|
"ignore_domains_title": "Ignored domains",
|
||||||
"ignore_domains_desc_stats": "Queries matching these rules are not written to the statistics",
|
"ignore_domains_desc_stats": "If enabled, 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_query": "If enabled, queries matching these rules are not written to the query log",
|
||||||
"interval_hours": "{{count}} hour",
|
"interval_hours": "{{count}} hour",
|
||||||
"interval_hours_plural": "{{count}} hours",
|
"interval_hours_plural": "{{count}} hours",
|
||||||
"filters_configuration": "Filters configuration",
|
"filters_configuration": "Filters configuration",
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export type FormValues = {
|
|||||||
interval: number;
|
interval: number;
|
||||||
customInterval?: number | null;
|
customInterval?: number | null;
|
||||||
ignored: string;
|
ignored: string;
|
||||||
|
ignored_enabled: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -57,6 +58,7 @@ export const Form = ({ initialValues, processing, processingReset, onSubmit, onR
|
|||||||
interval: initialValues.interval || DAY,
|
interval: initialValues.interval || DAY,
|
||||||
customInterval: initialValues.customInterval || null,
|
customInterval: initialValues.customInterval || null,
|
||||||
ignored: initialValues.ignored || '',
|
ignored: initialValues.ignored || '',
|
||||||
|
ignored_enabled: initialValues.ignored_enabled ?? true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -180,12 +182,20 @@ export const Form = ({ initialValues, processing, processingReset, onSubmit, onR
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label className="form__label form__label--with-desc">
|
<div className="form__group form__group--settings">
|
||||||
<Trans>ignore_domains_title</Trans>
|
<Controller
|
||||||
</label>
|
name="ignored_enabled"
|
||||||
|
control={control}
|
||||||
<div className="form__desc form__desc--top">
|
render={({ field }) => (
|
||||||
<Trans>ignore_domains_desc_query</Trans>
|
<Checkbox
|
||||||
|
{...field}
|
||||||
|
data-testid="logs_config_ignored_enabled"
|
||||||
|
title={t('ignore_domains_title')}
|
||||||
|
subtitle={t('ignore_domains_desc_query')}
|
||||||
|
disabled={processing}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="form__group form__group--settings">
|
<div className="form__group form__group--settings">
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ interface LogsConfigProps {
|
|||||||
anonymize_client_ip: boolean;
|
anonymize_client_ip: boolean;
|
||||||
processing: boolean;
|
processing: boolean;
|
||||||
ignored: unknown[];
|
ignored: unknown[];
|
||||||
|
ignoredEnabled: boolean;
|
||||||
processingClear: boolean;
|
processingClear: boolean;
|
||||||
setLogsConfig: (...args: unknown[]) => unknown;
|
setLogsConfig: (...args: unknown[]) => unknown;
|
||||||
clearLogs: (...args: unknown[]) => unknown;
|
clearLogs: (...args: unknown[]) => unknown;
|
||||||
@@ -59,6 +60,7 @@ class LogsConfig extends Component<LogsConfigProps> {
|
|||||||
processingClear,
|
processingClear,
|
||||||
anonymize_client_ip,
|
anonymize_client_ip,
|
||||||
ignored,
|
ignored,
|
||||||
|
ignoredEnabled,
|
||||||
customInterval,
|
customInterval,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
@@ -72,6 +74,7 @@ class LogsConfig extends Component<LogsConfigProps> {
|
|||||||
customInterval,
|
customInterval,
|
||||||
anonymize_client_ip,
|
anonymize_client_ip,
|
||||||
ignored: ignored?.join('\n'),
|
ignored: ignored?.join('\n'),
|
||||||
|
ignored_enabled: ignoredEnabled,
|
||||||
}}
|
}}
|
||||||
processing={processing}
|
processing={processing}
|
||||||
processingReset={processingClear}
|
processingReset={processingClear}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export type FormValues = {
|
|||||||
interval: number;
|
interval: number;
|
||||||
customInterval?: number | null;
|
customInterval?: number | null;
|
||||||
ignored: string;
|
ignored: string;
|
||||||
|
ignored_enabled: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultFormValues = {
|
const defaultFormValues = {
|
||||||
@@ -34,6 +35,7 @@ const defaultFormValues = {
|
|||||||
interval: DAY,
|
interval: DAY,
|
||||||
customInterval: null,
|
customInterval: null,
|
||||||
ignored: '',
|
ignored: '',
|
||||||
|
ignored_enabled: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -162,12 +164,20 @@ export const Form = ({ initialValues, processing, processingReset, onSubmit, onR
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="form__label form__label--with-desc">
|
<div className="form__group form__group--settings">
|
||||||
<Trans>ignore_domains_title</Trans>
|
<Controller
|
||||||
</div>
|
name="ignored_enabled"
|
||||||
|
control={control}
|
||||||
<div className="form__desc form__desc--top">
|
render={({ field }) => (
|
||||||
<Trans>ignore_domains_desc_stats</Trans>
|
<Checkbox
|
||||||
|
{...field}
|
||||||
|
data-testid="stats_config_ignored_enabled"
|
||||||
|
title={t('ignore_domains_title')}
|
||||||
|
subtitle={t('ignore_domains_desc_stats')}
|
||||||
|
disabled={processing}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="form__group form__group--settings">
|
<div className="form__group form__group--settings">
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ interface StatsConfigProps {
|
|||||||
interval: number;
|
interval: number;
|
||||||
customInterval?: number;
|
customInterval?: number;
|
||||||
ignored: unknown[];
|
ignored: unknown[];
|
||||||
|
ignoredEnabled: boolean;
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
processing: boolean;
|
processing: boolean;
|
||||||
processingReset: boolean;
|
processingReset: boolean;
|
||||||
@@ -19,7 +20,7 @@ interface StatsConfigProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class StatsConfig extends Component<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 { t, interval: prevInterval } = this.props;
|
||||||
const newInterval = customInterval ? customInterval * HOUR : interval;
|
const newInterval = customInterval ? customInterval * HOUR : interval;
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ class StatsConfig extends Component<StatsConfigProps> {
|
|||||||
enabled,
|
enabled,
|
||||||
interval: newInterval,
|
interval: newInterval,
|
||||||
ignored: ignored ? ignored.split('\n') : [],
|
ignored: ignored ? ignored.split('\n') : [],
|
||||||
|
ignored_enabled,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (config.interval < prevInterval) {
|
if (config.interval < prevInterval) {
|
||||||
@@ -54,6 +56,7 @@ class StatsConfig extends Component<StatsConfigProps> {
|
|||||||
processing,
|
processing,
|
||||||
processingReset,
|
processingReset,
|
||||||
ignored,
|
ignored,
|
||||||
|
ignoredEnabled,
|
||||||
enabled,
|
enabled,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
@@ -66,6 +69,7 @@ class StatsConfig extends Component<StatsConfigProps> {
|
|||||||
customInterval,
|
customInterval,
|
||||||
enabled,
|
enabled,
|
||||||
ignored: ignored.join('\n'),
|
ignored: ignored.join('\n'),
|
||||||
|
ignored_enabled: ignoredEnabled,
|
||||||
}}
|
}}
|
||||||
processing={processing}
|
processing={processing}
|
||||||
processingReset={processingReset}
|
processingReset={processingReset}
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ interface SettingsProps {
|
|||||||
customInterval?: number;
|
customInterval?: number;
|
||||||
enabled?: boolean;
|
enabled?: boolean;
|
||||||
ignored?: unknown[];
|
ignored?: unknown[];
|
||||||
|
ignored_enabled?: boolean;
|
||||||
processingSetConfig?: boolean;
|
processingSetConfig?: boolean;
|
||||||
processingReset?: boolean;
|
processingReset?: boolean;
|
||||||
};
|
};
|
||||||
@@ -70,6 +71,7 @@ interface SettingsProps {
|
|||||||
processingClear?: boolean;
|
processingClear?: boolean;
|
||||||
processingGetConfig?: boolean;
|
processingGetConfig?: boolean;
|
||||||
ignored?: unknown[];
|
ignored?: unknown[];
|
||||||
|
ignored_enabled?: boolean;
|
||||||
};
|
};
|
||||||
filtering?: {
|
filtering?: {
|
||||||
interval?: number;
|
interval?: number;
|
||||||
@@ -195,6 +197,7 @@ class Settings extends Component<SettingsProps> {
|
|||||||
<LogsConfig
|
<LogsConfig
|
||||||
enabled={queryLogs.enabled}
|
enabled={queryLogs.enabled}
|
||||||
ignored={queryLogs.ignored}
|
ignored={queryLogs.ignored}
|
||||||
|
ignoredEnabled={queryLogs.ignored_enabled}
|
||||||
interval={queryLogs.interval}
|
interval={queryLogs.interval}
|
||||||
customInterval={queryLogs.customInterval}
|
customInterval={queryLogs.customInterval}
|
||||||
anonymize_client_ip={queryLogs.anonymize_client_ip}
|
anonymize_client_ip={queryLogs.anonymize_client_ip}
|
||||||
@@ -210,6 +213,7 @@ class Settings extends Component<SettingsProps> {
|
|||||||
interval={stats.interval}
|
interval={stats.interval}
|
||||||
customInterval={stats.customInterval}
|
customInterval={stats.customInterval}
|
||||||
ignored={stats.ignored}
|
ignored={stats.ignored}
|
||||||
|
ignoredEnabled={stats.ignored_enabled}
|
||||||
enabled={stats.enabled}
|
enabled={stats.enabled}
|
||||||
processing={stats.processingSetConfig}
|
processing={stats.processingSetConfig}
|
||||||
processingReset={stats.processingReset}
|
processingReset={stats.processingReset}
|
||||||
|
|||||||
@@ -197,6 +197,7 @@ export type StatsData = {
|
|||||||
processingReset: boolean;
|
processingReset: boolean;
|
||||||
interval: number;
|
interval: number;
|
||||||
customInterval?: number;
|
customInterval?: number;
|
||||||
|
ignored_enabled: boolean;
|
||||||
dnsQueries: number[];
|
dnsQueries: number[];
|
||||||
blockedFiltering: number[];
|
blockedFiltering: number[];
|
||||||
replacedParental: number[];
|
replacedParental: number[];
|
||||||
@@ -372,6 +373,7 @@ export type QueryLogsData = {
|
|||||||
isDetailed: boolean;
|
isDetailed: boolean;
|
||||||
isEntireLog: boolean;
|
isEntireLog: boolean;
|
||||||
customInterval: any;
|
customInterval: any;
|
||||||
|
ignored_enabled: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ServicesData = {
|
export type ServicesData = {
|
||||||
@@ -576,6 +578,7 @@ export const initialState: RootState = {
|
|||||||
isDetailed: true,
|
isDetailed: true,
|
||||||
isEntireLog: false,
|
isEntireLog: false,
|
||||||
customInterval: null,
|
customInterval: null,
|
||||||
|
ignored_enabled: true,
|
||||||
},
|
},
|
||||||
rewrites: {
|
rewrites: {
|
||||||
processing: true,
|
processing: true,
|
||||||
@@ -607,6 +610,7 @@ export const initialState: RootState = {
|
|||||||
processingReset: false,
|
processingReset: false,
|
||||||
interval: DAY,
|
interval: DAY,
|
||||||
customInterval: null,
|
customInterval: null,
|
||||||
|
ignored_enabled: true,
|
||||||
dnsQueries: [],
|
dnsQueries: [],
|
||||||
blockedFiltering: [],
|
blockedFiltering: [],
|
||||||
replacedParental: [],
|
replacedParental: [],
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ const queryLogs = handleActions(
|
|||||||
isDetailed: true,
|
isDetailed: true,
|
||||||
isEntireLog: false,
|
isEntireLog: false,
|
||||||
customInterval: null,
|
customInterval: null,
|
||||||
|
ignored_enabled: true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ const stats = handleActions(
|
|||||||
processingReset: false,
|
processingReset: false,
|
||||||
interval: DAY,
|
interval: DAY,
|
||||||
customInterval: null,
|
customInterval: null,
|
||||||
|
ignored_enabled: true,
|
||||||
...defaultStats,
|
...defaultStats,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -19,11 +19,15 @@ type IgnoreEngine struct {
|
|||||||
|
|
||||||
// ignored is the list of rules for ignoring hostnames.
|
// ignored is the list of rules for ignoring hostnames.
|
||||||
ignored []string
|
ignored []string
|
||||||
|
|
||||||
|
// enabled determines whether ignoring is enabled.
|
||||||
|
enabled bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewIgnoreEngine creates a new instance of the IgnoreEngine and stores the
|
// NewIgnoreEngine creates a new instance of the IgnoreEngine and stores the
|
||||||
// list of rules for ignoring hostnames.
|
// list of rules for ignoring hostnames. If enabled is set to false, hostnames
|
||||||
func NewIgnoreEngine(ignored []string) (e *IgnoreEngine, err error) {
|
// will never be ignored.
|
||||||
|
func NewIgnoreEngine(ignored []string, enabled bool) (e *IgnoreEngine, err error) {
|
||||||
ruleLists := []filterlist.Interface{
|
ruleLists := []filterlist.Interface{
|
||||||
filterlist.NewString(&filterlist.StringConfig{
|
filterlist.NewString(&filterlist.StringConfig{
|
||||||
RulesText: strings.ToLower(strings.Join(ignored, "\n")),
|
RulesText: strings.ToLower(strings.Join(ignored, "\n")),
|
||||||
@@ -38,12 +42,13 @@ func NewIgnoreEngine(ignored []string) (e *IgnoreEngine, err error) {
|
|||||||
return &IgnoreEngine{
|
return &IgnoreEngine{
|
||||||
engine: urlfilter.NewDNSEngine(ruleStorage),
|
engine: urlfilter.NewDNSEngine(ruleStorage),
|
||||||
ignored: ignored,
|
ignored: ignored,
|
||||||
|
enabled: enabled,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Has returns true if IgnoreEngine matches the host.
|
// Has returns true if IgnoreEngine matches the host.
|
||||||
func (e *IgnoreEngine) Has(host string) (ignore bool) {
|
func (e *IgnoreEngine) Has(host string) (ignore bool) {
|
||||||
if e == nil {
|
if e == nil || !e.enabled {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,3 +61,8 @@ func (e *IgnoreEngine) Has(host string) (ignore bool) {
|
|||||||
func (e *IgnoreEngine) Values() (ignored []string) {
|
func (e *IgnoreEngine) Values() (ignored []string) {
|
||||||
return slices.Clone(e.ignored)
|
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.NotNil(t, engine)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
|||||||
@@ -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 = 32
|
const LastSchemaVersion uint = 33
|
||||||
@@ -143,6 +143,7 @@ func (m *Migrator) upgradeConfigSchema(
|
|||||||
29: m.migrateTo30,
|
29: m.migrateTo30,
|
||||||
30: m.migrateTo31,
|
30: m.migrateTo31,
|
||||||
31: m.migrateTo32,
|
31: m.migrateTo32,
|
||||||
|
32: m.migrateTo33,
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, migrate := range upgrades[current:target] {
|
for i, migrate := range upgrades[current:target] {
|
||||||
|
|||||||
@@ -207,6 +207,10 @@ func TestMigrateConfig_Migrate(t *testing.T) {
|
|||||||
yamlEqFunc: require.YAMLEq,
|
yamlEqFunc: require.YAMLEq,
|
||||||
name: "v32",
|
name: "v32",
|
||||||
targetVersion: 32,
|
targetVersion: 32,
|
||||||
|
}, {
|
||||||
|
yamlEqFunc: require.YAMLEq,
|
||||||
|
name: "v33",
|
||||||
|
targetVersion: 33,
|
||||||
}}
|
}}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
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 defines if the query log is enabled.
|
||||||
Enabled bool `yaml:"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 defines, if the query log is written to the file.
|
||||||
FileEnabled bool `yaml:"file_enabled"`
|
FileEnabled bool `yaml:"file_enabled"`
|
||||||
}
|
}
|
||||||
@@ -427,6 +431,10 @@ type statsConfig struct {
|
|||||||
|
|
||||||
// Enabled defines if the statistics are enabled.
|
// Enabled defines if the statistics are enabled.
|
||||||
Enabled bool `yaml:"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.
|
// Default block host constants.
|
||||||
@@ -497,16 +505,18 @@ var config = &configuration{
|
|||||||
PortDNSOverQUIC: defaultPortQUIC,
|
PortDNSOverQUIC: defaultPortQUIC,
|
||||||
},
|
},
|
||||||
QueryLog: queryLogConfig{
|
QueryLog: queryLogConfig{
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
FileEnabled: true,
|
FileEnabled: true,
|
||||||
Interval: timeutil.Duration(90 * timeutil.Day),
|
Interval: timeutil.Duration(90 * timeutil.Day),
|
||||||
MemSize: 1000,
|
MemSize: 1000,
|
||||||
Ignored: []string{},
|
Ignored: []string{},
|
||||||
|
IgnoredEnabled: false,
|
||||||
},
|
},
|
||||||
Stats: statsConfig{
|
Stats: statsConfig{
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
Interval: timeutil.Duration(1 * timeutil.Day),
|
Interval: timeutil.Duration(1 * timeutil.Day),
|
||||||
Ignored: []string{},
|
Ignored: []string{},
|
||||||
|
IgnoredEnabled: false,
|
||||||
},
|
},
|
||||||
// NOTE: Keep these parameters in sync with the one put into
|
// NOTE: Keep these parameters in sync with the one put into
|
||||||
// client/src/helpers/filters/filters.ts by scripts/vetted-filters.
|
// 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.Interval = timeutil.Duration(statsConf.Limit)
|
||||||
config.Stats.Enabled = statsConf.Enabled
|
config.Stats.Enabled = statsConf.Enabled
|
||||||
config.Stats.Ignored = statsConf.Ignored.Values()
|
config.Stats.Ignored = statsConf.Ignored.Values()
|
||||||
|
config.Stats.IgnoredEnabled = statsConf.Ignored.IsEnabled()
|
||||||
}
|
}
|
||||||
|
|
||||||
if globalContext.queryLog != nil {
|
if globalContext.queryLog != nil {
|
||||||
@@ -878,6 +889,7 @@ func (c *configuration) write(
|
|||||||
config.QueryLog.Interval = timeutil.Duration(dc.RotationIvl)
|
config.QueryLog.Interval = timeutil.Duration(dc.RotationIvl)
|
||||||
config.QueryLog.MemSize = dc.MemSize
|
config.QueryLog.MemSize = dc.MemSize
|
||||||
config.QueryLog.Ignored = dc.Ignored.Values()
|
config.QueryLog.Ignored = dc.Ignored.Values()
|
||||||
|
config.QueryLog.IgnoredEnabled = dc.Ignored.IsEnabled()
|
||||||
}
|
}
|
||||||
|
|
||||||
if globalContext.filters != nil {
|
if globalContext.filters != nil {
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ func initDNS(
|
|||||||
ShouldCountClient: globalContext.clients.shouldCountClient,
|
ShouldCountClient: globalContext.clients.shouldCountClient,
|
||||||
}
|
}
|
||||||
|
|
||||||
engine, err := aghnet.NewIgnoreEngine(config.Stats.Ignored)
|
engine, err := aghnet.NewIgnoreEngine(config.Stats.Ignored, config.Stats.IgnoredEnabled)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("statistics: ignored list: %w", err)
|
return fmt.Errorf("statistics: ignored list: %w", err)
|
||||||
}
|
}
|
||||||
@@ -89,7 +89,7 @@ func initDNS(
|
|||||||
FileEnabled: config.QueryLog.FileEnabled,
|
FileEnabled: config.QueryLog.FileEnabled,
|
||||||
}
|
}
|
||||||
|
|
||||||
engine, err = aghnet.NewIgnoreEngine(config.QueryLog.Ignored)
|
engine, err = aghnet.NewIgnoreEngine(config.QueryLog.Ignored, config.QueryLog.IgnoredEnabled)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("querylog: ignored list: %w", err)
|
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.
|
// be able to tell when it's set without using pointers.
|
||||||
Enabled aghalg.NullBool `json:"enabled"`
|
Enabled aghalg.NullBool `json:"enabled"`
|
||||||
|
|
||||||
|
IgnoredEnabled aghalg.NullBool `json:"ignored_enabled"`
|
||||||
|
|
||||||
// AnonymizeClientIP shows if the clients' IP addresses must be anonymized.
|
// 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
|
// It is an aghalg.NullBool to be able to tell when it's set without using
|
||||||
// pointers.
|
// pointers.
|
||||||
@@ -140,6 +142,7 @@ func (l *queryLog) handleGetQueryLogConfig(w http.ResponseWriter, r *http.Reques
|
|||||||
Enabled: aghalg.BoolToNullBool(l.conf.Enabled),
|
Enabled: aghalg.BoolToNullBool(l.conf.Enabled),
|
||||||
AnonymizeClientIP: aghalg.BoolToNullBool(l.conf.AnonymizeClientIP),
|
AnonymizeClientIP: aghalg.BoolToNullBool(l.conf.AnonymizeClientIP),
|
||||||
Ignored: l.conf.Ignored.Values(),
|
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
|
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 {
|
if err != nil {
|
||||||
aghhttp.ErrorAndLog(
|
aghhttp.ErrorAndLog(
|
||||||
ctx,
|
ctx,
|
||||||
@@ -315,8 +325,8 @@ func (l *queryLog) applyQueryLogConfig(
|
|||||||
conf.Ignored = engine
|
conf.Ignored = engine
|
||||||
conf.RotationIvl = ivl
|
conf.RotationIvl = ivl
|
||||||
conf.Enabled = newConf.Enabled == aghalg.NBTrue
|
conf.Enabled = newConf.Enabled == aghalg.NBTrue
|
||||||
|
|
||||||
conf.AnonymizeClientIP = newConf.AnonymizeClientIP == aghalg.NBTrue
|
conf.AnonymizeClientIP = newConf.AnonymizeClientIP == aghalg.NBTrue
|
||||||
|
|
||||||
if conf.AnonymizeClientIP {
|
if conf.AnonymizeClientIP {
|
||||||
l.anonymizer.Store(AnonymizeIP)
|
l.anonymizer.Store(AnonymizeIP)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ func TestQueryLogShouldLog(t *testing.T) {
|
|||||||
ignoredRoot,
|
ignoredRoot,
|
||||||
}
|
}
|
||||||
|
|
||||||
engine, err := aghnet.NewIgnoreEngine(ignored)
|
engine, err := aghnet.NewIgnoreEngine(ignored, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
findClient := func(ids []string) (c *Client, err error) {
|
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
|
// Enabled shows if statistics are enabled. It is an aghalg.NullBool to be
|
||||||
// able to tell when it's set without using pointers.
|
// able to tell when it's set without using pointers.
|
||||||
Enabled aghalg.NullBool `json:"enabled"`
|
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.
|
// 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()
|
defer s.confMu.RUnlock()
|
||||||
|
|
||||||
resp = &getConfigResp{
|
resp = &getConfigResp{
|
||||||
Ignored: s.ignored.Values(),
|
Ignored: s.ignored.Values(),
|
||||||
Interval: float64(s.limit.Milliseconds()),
|
IgnoredEnabled: aghalg.BoolToNullBool(s.ignored.IsEnabled()),
|
||||||
Enabled: aghalg.BoolToNullBool(s.enabled),
|
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
|
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 {
|
if err != nil {
|
||||||
aghhttp.ErrorAndLog(ctx, s.logger, r, w, http.StatusUnprocessableEntity, "ignored: %s", err)
|
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",
|
name: "set_ivl_1_minIvl",
|
||||||
body: getConfigResp{
|
body: getConfigResp{
|
||||||
Enabled: aghalg.NBTrue,
|
Enabled: aghalg.NBTrue,
|
||||||
Interval: float64(minIvl.Milliseconds()),
|
Interval: float64(minIvl.Milliseconds()),
|
||||||
Ignored: []string{},
|
Ignored: []string{},
|
||||||
|
IgnoredEnabled: aghalg.NBFalse,
|
||||||
},
|
},
|
||||||
wantCode: http.StatusOK,
|
wantCode: http.StatusOK,
|
||||||
wantErr: "",
|
wantErr: "",
|
||||||
}, {
|
}, {
|
||||||
name: "small_interval",
|
name: "small_interval",
|
||||||
body: getConfigResp{
|
body: getConfigResp{
|
||||||
Enabled: aghalg.NBTrue,
|
Enabled: aghalg.NBTrue,
|
||||||
Interval: float64(smallIvl.Milliseconds()),
|
Interval: float64(smallIvl.Milliseconds()),
|
||||||
Ignored: []string{},
|
Ignored: []string{},
|
||||||
|
IgnoredEnabled: aghalg.NBFalse,
|
||||||
},
|
},
|
||||||
wantCode: http.StatusUnprocessableEntity,
|
wantCode: http.StatusUnprocessableEntity,
|
||||||
wantErr: "unsupported interval: less than an hour\n",
|
wantErr: "unsupported interval: less than an hour\n",
|
||||||
}, {
|
}, {
|
||||||
name: "big_interval",
|
name: "big_interval",
|
||||||
body: getConfigResp{
|
body: getConfigResp{
|
||||||
Enabled: aghalg.NBTrue,
|
Enabled: aghalg.NBTrue,
|
||||||
Interval: float64(maxIvl.Milliseconds() + minIvl.Milliseconds()),
|
Interval: float64(maxIvl.Milliseconds() + minIvl.Milliseconds()),
|
||||||
Ignored: []string{},
|
Ignored: []string{},
|
||||||
|
IgnoredEnabled: aghalg.NBFalse,
|
||||||
},
|
},
|
||||||
wantCode: http.StatusUnprocessableEntity,
|
wantCode: http.StatusUnprocessableEntity,
|
||||||
wantErr: "unsupported interval: more than a year\n",
|
wantErr: "unsupported interval: more than a year\n",
|
||||||
@@ -77,15 +80,17 @@ func TestHandleStatsConfig(t *testing.T) {
|
|||||||
Ignored: []string{
|
Ignored: []string{
|
||||||
"ignor.ed",
|
"ignor.ed",
|
||||||
},
|
},
|
||||||
|
IgnoredEnabled: aghalg.NBTrue,
|
||||||
},
|
},
|
||||||
wantCode: http.StatusOK,
|
wantCode: http.StatusOK,
|
||||||
wantErr: "",
|
wantErr: "",
|
||||||
}, {
|
}, {
|
||||||
name: "enabled_is_null",
|
name: "enabled_is_null",
|
||||||
body: getConfigResp{
|
body: getConfigResp{
|
||||||
Enabled: aghalg.NBNull,
|
Enabled: aghalg.NBNull,
|
||||||
Interval: float64(minIvl.Milliseconds()),
|
Interval: float64(minIvl.Milliseconds()),
|
||||||
Ignored: []string{},
|
Ignored: []string{},
|
||||||
|
IgnoredEnabled: aghalg.NBFalse,
|
||||||
},
|
},
|
||||||
wantCode: http.StatusUnprocessableEntity,
|
wantCode: http.StatusUnprocessableEntity,
|
||||||
wantErr: "enabled is null\n",
|
wantErr: "enabled is null\n",
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ func TestShouldCount(t *testing.T) {
|
|||||||
ignored2 = "ignored.to"
|
ignored2 = "ignored.to"
|
||||||
)
|
)
|
||||||
ignored := []string{ignored1, ignored2}
|
ignored := []string{ignored1, ignored2}
|
||||||
engine, err := aghnet.NewIgnoreEngine(ignored)
|
engine, err := aghnet.NewIgnoreEngine(ignored, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
s, err := stats.New(stats.Config{
|
s, err := stats.New(stats.Config{
|
||||||
|
|||||||
@@ -2,6 +2,16 @@
|
|||||||
|
|
||||||
<!-- TODO(a.garipov): Reformat in accordance with the KeepAChangelog spec. -->
|
<!-- 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
|
## v0.107.70: API changes
|
||||||
|
|
||||||
### New `"start_time"` field in 'GET /control/status'
|
### New `"start_time"` field in 'GET /control/status'
|
||||||
|
|||||||
@@ -2000,6 +2000,11 @@
|
|||||||
'type': 'array'
|
'type': 'array'
|
||||||
'items':
|
'items':
|
||||||
'type': 'string'
|
'type': 'string'
|
||||||
|
'ignored_enabled':
|
||||||
|
'type': 'boolean'
|
||||||
|
'description': >
|
||||||
|
If true, the host names in the `ignored` array are excluded from the
|
||||||
|
statistics.
|
||||||
'PutStatsConfigUpdateRequest':
|
'PutStatsConfigUpdateRequest':
|
||||||
'$ref': '#/components/schemas/GetStatsConfigResponse'
|
'$ref': '#/components/schemas/GetStatsConfigResponse'
|
||||||
'DhcpConfig':
|
'DhcpConfig':
|
||||||
@@ -2429,6 +2434,11 @@
|
|||||||
'type': 'array'
|
'type': 'array'
|
||||||
'items':
|
'items':
|
||||||
'type': 'string'
|
'type': 'string'
|
||||||
|
'ignored_enabled':
|
||||||
|
'type': 'boolean'
|
||||||
|
'description': >
|
||||||
|
If true, the host names in the `ignored` array are excluded from the
|
||||||
|
query log.
|
||||||
'PutQueryLogConfigUpdateRequest':
|
'PutQueryLogConfigUpdateRequest':
|
||||||
'$ref': '#/components/schemas/GetQueryLogConfigResponse'
|
'$ref': '#/components/schemas/GetQueryLogConfigResponse'
|
||||||
'ResultRule':
|
'ResultRule':
|
||||||
|
|||||||
Reference in new issue
Block a user