Skip to content

Commit f53fdba

Browse files
committed
Add support for blocked replies with NOERROR code and empty answer
Closes #8024
1 parent 01dd10e commit f53fdba

7 files changed

Lines changed: 23 additions & 0 deletions

File tree

client/src/__locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"blocking_mode_null_ip": "Null IP: Respond with zero IP address (0.0.0.0 for A; :: for AAAA)",
6262
"blocking_mode_nxdomain": "NXDOMAIN: Respond with NXDOMAIN code",
6363
"blocking_mode_refused": "REFUSED: Respond with REFUSED code",
64+
"blocking_mode_noerror": "NOERROR: Respond with NOERROR code and an empty reply",
6465
"blocklist": "Blocklist",
6566
"bootstrap_dns": "Bootstrap DNS servers",
6667
"bootstrap_dns_desc": "IP addresses of DNS servers used to resolve IP addresses of the DoH/DoT resolvers you specify as upstreams. Comments are not permitted.",
@@ -527,6 +528,7 @@
527528
"no_servers_specified": "No servers specified",
528529
"no_upstreams_data_found": "No upstreams data found",
529530
"no_whitelist_added": "No allowlists added",
531+
"noerror": "NOERROR",
530532
"nothing_found": "Nothing found",
531533
"null_ip": "Null IP",
532534
"number_of_dns_query_blocked_24_hours": "The number of DNS requests blocked by adblock filters and hosts blocklists",

client/src/components/Settings/Dns/Config/Form.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ const blockingModeOptions = [
6262
value: BLOCKING_MODES.nxdomain,
6363
label: i18next.t('nxdomain'),
6464
},
65+
{
66+
value: BLOCKING_MODES.noerror,
67+
label: i18next.t('noerror'),
68+
},
6569
{
6670
value: BLOCKING_MODES.null_ip,
6771
label: i18next.t('null_ip'),
@@ -76,6 +80,7 @@ const blockingModeDescriptions = [
7680
i18next.t(`blocking_mode_default`),
7781
i18next.t(`blocking_mode_refused`),
7882
i18next.t(`blocking_mode_nxdomain`),
83+
i18next.t(`blocking_mode_noerror`),
7984
i18next.t(`blocking_mode_null_ip`),
8085
i18next.t(`blocking_mode_custom_ip`),
8186
];

client/src/helpers/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ export const BLOCKING_MODES = {
189189
default: 'default',
190190
refused: 'refused',
191191
nxdomain: 'nxdomain',
192+
noerror: 'noerror',
192193
null_ip: 'null_ip',
193194
custom_ip: 'custom_ip',
194195
};

internal/dnsforward/dnsforward.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,7 @@ func validateBlockingMode(
747747
filtering.BlockingModeDefault,
748748
filtering.BlockingModeNXDOMAIN,
749749
filtering.BlockingModeREFUSED,
750+
filtering.BlockingModeNOERROR,
750751
filtering.BlockingModeNullIP:
751752
return nil
752753
case filtering.BlockingModeCustomIP:

internal/dnsforward/msg.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ func (s *Server) genForBlockingMode(
139139
return s.NewMsgNXDOMAIN(req)
140140
case filtering.BlockingModeREFUSED:
141141
return s.makeResponseREFUSED(req)
142+
case filtering.BlockingModeNOERROR:
143+
return s.NewMsgNOERROR(req)
142144
default:
143145
s.logger.ErrorContext(ctx, "invalid blocking mode", "mode", mode)
144146

@@ -390,6 +392,14 @@ func (s *Server) NewMsgNXDOMAIN(req *dns.Msg) (resp *dns.Msg) {
390392
return resp
391393
}
392394

395+
// NewMsgNOERROR creates an empty response pretending there is no address associated with the requested name.
396+
func (s *Server) NewMsgNOERROR(req *dns.Msg) (resp *dns.Msg) {
397+
resp = s.replyCompressed(req)
398+
resp.Ns = s.genSOA(req)
399+
400+
return resp
401+
}
402+
393403
// NewMsgSERVFAIL implements the [proxy.MessageConstructor] interface for
394404
// *Server.
395405
func (s *Server) NewMsgSERVFAIL(req *dns.Msg) (resp *dns.Msg) {

internal/filtering/filtering.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ const (
208208
// BlockingModeNXDOMAIN means respond with the NXDOMAIN code.
209209
BlockingModeNXDOMAIN BlockingMode = "nxdomain"
210210

211+
// BlockingModeNOERROR means respond with the NOERROR code.
212+
BlockingModeNOERROR BlockingMode = "noerror"
213+
211214
// BlockingModeREFUSED means respond with the REFUSED code.
212215
BlockingModeREFUSED BlockingMode = "refused"
213216
)

scripts/translations/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ func findUnused(fileNames []string, loc locales) (err error) {
267267
knownUsed := []textLabel{
268268
"blocking_mode_refused",
269269
"blocking_mode_nxdomain",
270+
"blocking_mode_noerror",
270271
"blocking_mode_custom_ip",
271272
}
272273

0 commit comments

Comments
 (0)