diff --git a/CHANGELOG.md b/CHANGELOG.md
index e5e6b70b1..0f236021d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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`.
+
+
diff --git a/client/src/__locales/en.json b/client/src/__locales/en.json
index 4fcb8b4f8..0a77813fc 100644
--- a/client/src/__locales/en.json
+++ b/client/src/__locales/en.json
@@ -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",
diff --git a/client/src/components/Settings/LogsConfig/Form.tsx b/client/src/components/Settings/LogsConfig/Form.tsx
index cdb1255d1..3f3487def 100644
--- a/client/src/components/Settings/LogsConfig/Form.tsx
+++ b/client/src/components/Settings/LogsConfig/Form.tsx
@@ -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
-
-
-
-
ignore_domains_desc_stats
+
+ (
+
+ )}
+ />
diff --git a/client/src/components/Settings/StatsConfig/index.tsx b/client/src/components/Settings/StatsConfig/index.tsx
index 1240dbb61..64b976b7c 100644
--- a/client/src/components/Settings/StatsConfig/index.tsx
+++ b/client/src/components/Settings/StatsConfig/index.tsx
@@ -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 {
- 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 {
enabled,
interval: newInterval,
ignored: ignored ? ignored.split('\n') : [],
+ ignored_enabled,
};
if (config.interval < prevInterval) {
@@ -54,6 +56,7 @@ class StatsConfig extends Component {
processing,
processingReset,
ignored,
+ ignoredEnabled,
enabled,
} = this.props;
@@ -66,6 +69,7 @@ class StatsConfig extends Component {
customInterval,
enabled,
ignored: ignored.join('\n'),
+ ignored_enabled: ignoredEnabled,
}}
processing={processing}
processingReset={processingReset}
diff --git a/client/src/components/Settings/index.tsx b/client/src/components/Settings/index.tsx
index 750f02654..8f3320782 100644
--- a/client/src/components/Settings/index.tsx
+++ b/client/src/components/Settings/index.tsx
@@ -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 {
{
interval={stats.interval}
customInterval={stats.customInterval}
ignored={stats.ignored}
+ ignoredEnabled={stats.ignored_enabled}
enabled={stats.enabled}
processing={stats.processingSetConfig}
processingReset={stats.processingReset}
diff --git a/client/src/initialState.ts b/client/src/initialState.ts
index 979f33ca8..7cc2855fe 100644
--- a/client/src/initialState.ts
+++ b/client/src/initialState.ts
@@ -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: [],
diff --git a/client/src/reducers/queryLogs.ts b/client/src/reducers/queryLogs.ts
index 623d90b50..7a05928b0 100644
--- a/client/src/reducers/queryLogs.ts
+++ b/client/src/reducers/queryLogs.ts
@@ -137,6 +137,7 @@ const queryLogs = handleActions(
isDetailed: true,
isEntireLog: false,
customInterval: null,
+ ignored_enabled: true,
},
);
diff --git a/client/src/reducers/stats.ts b/client/src/reducers/stats.ts
index e2c7022fb..3433afddf 100644
--- a/client/src/reducers/stats.ts
+++ b/client/src/reducers/stats.ts
@@ -129,6 +129,7 @@ const stats = handleActions(
processingReset: false,
interval: DAY,
customInterval: null,
+ ignored_enabled: true,
...defaultStats,
},
);
diff --git a/internal/aghnet/ignore.go b/internal/aghnet/ignore.go
index ed3784e0a..0b9cee173 100644
--- a/internal/aghnet/ignore.go
+++ b/internal/aghnet/ignore.go
@@ -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
+}
diff --git a/internal/aghnet/ignore_test.go b/internal/aghnet/ignore_test.go
index 0cf936d30..1b80dc057 100644
--- a/internal/aghnet/ignore_test.go
+++ b/internal/aghnet/ignore_test.go
@@ -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)
diff --git a/internal/configmigrate/configmigrate.go b/internal/configmigrate/configmigrate.go
index efa75a37f..9cda02894 100644
--- a/internal/configmigrate/configmigrate.go
+++ b/internal/configmigrate/configmigrate.go
@@ -2,4 +2,4 @@
package configmigrate
// LastSchemaVersion is the most recent schema version.
-const LastSchemaVersion uint = 32
+const LastSchemaVersion uint = 33
diff --git a/internal/configmigrate/migrator.go b/internal/configmigrate/migrator.go
index 4482e1e51..4ae0f218e 100644
--- a/internal/configmigrate/migrator.go
+++ b/internal/configmigrate/migrator.go
@@ -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] {
diff --git a/internal/configmigrate/migrator_test.go b/internal/configmigrate/migrator_test.go
index 92ce257e3..9261faf5e 100644
--- a/internal/configmigrate/migrator_test.go
+++ b/internal/configmigrate/migrator_test.go
@@ -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 {
diff --git a/internal/configmigrate/testdata/TestMigrateConfig_Migrate/v33/input.yml b/internal/configmigrate/testdata/TestMigrateConfig_Migrate/v33/input.yml
new file mode 100644
index 000000000..2394164e4
--- /dev/null
+++ b/internal/configmigrate/testdata/TestMigrateConfig_Migrate/v33/input.yml
@@ -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
diff --git a/internal/configmigrate/testdata/TestMigrateConfig_Migrate/v33/output.yml b/internal/configmigrate/testdata/TestMigrateConfig_Migrate/v33/output.yml
new file mode 100644
index 000000000..5eb2d4904
--- /dev/null
+++ b/internal/configmigrate/testdata/TestMigrateConfig_Migrate/v33/output.yml
@@ -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
diff --git a/internal/configmigrate/v33.go b/internal/configmigrate/v33.go
new file mode 100644
index 000000000..c0c8f08ec
--- /dev/null
+++ b/internal/configmigrate/v33.go
@@ -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
+}
diff --git a/internal/home/config.go b/internal/home/config.go
index 24e912a0b..082f0e66a 100644
--- a/internal/home/config.go
+++ b/internal/home/config.go
@@ -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 {
diff --git a/internal/home/dns.go b/internal/home/dns.go
index 4545fe720..f24da33e0 100644
--- a/internal/home/dns.go
+++ b/internal/home/dns.go
@@ -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)
}
diff --git a/internal/querylog/http.go b/internal/querylog/http.go
index 57dec1447..5d6eb4e52 100644
--- a/internal/querylog/http.go
+++ b/internal/querylog/http.go
@@ -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 {
diff --git a/internal/querylog/qlog_internal_test.go b/internal/querylog/qlog_internal_test.go
index 77ec0c7a4..ad7009919 100644
--- a/internal/querylog/qlog_internal_test.go
+++ b/internal/querylog/qlog_internal_test.go
@@ -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) {
diff --git a/internal/stats/http.go b/internal/stats/http.go
index 12424bbf2..bb142d12a 100644
--- a/internal/stats/http.go
+++ b/internal/stats/http.go
@@ -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)
diff --git a/internal/stats/http_internal_test.go b/internal/stats/http_internal_test.go
index 1af423496..3fb4ced0b 100644
--- a/internal/stats/http_internal_test.go
+++ b/internal/stats/http_internal_test.go
@@ -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",
diff --git a/internal/stats/stats_test.go b/internal/stats/stats_test.go
index c94cf7346..d9763784b 100644
--- a/internal/stats/stats_test.go
+++ b/internal/stats/stats_test.go
@@ -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{
diff --git a/openapi/CHANGELOG.md b/openapi/CHANGELOG.md
index 75cefc9dc..db42436c5 100644
--- a/openapi/CHANGELOG.md
+++ b/openapi/CHANGELOG.md
@@ -2,6 +2,16 @@
+## 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'
diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml
index bef4c97bb..65ef2c5ef 100644
--- a/openapi/openapi.yaml
+++ b/openapi/openapi.yaml
@@ -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':