Skip to content

Commit cfa0982

Browse files
committed
Add support for blocked replies with NOERROR code and empty answer
Closes #8024
1 parent 3eb42df commit cfa0982

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
@@ -96,6 +96,10 @@ const Form = ({ processing, initialValues, onSubmit }: Props) => {
9696
value: BLOCKING_MODES.nxdomain,
9797
label: t('nxdomain'),
9898
},
99+
{
100+
value: BLOCKING_MODES.noerror,
101+
label: t('noerror'),
102+
},
99103
{
100104
value: BLOCKING_MODES.null_ip,
101105
label: t('null_ip'),
@@ -110,6 +114,7 @@ const Form = ({ processing, initialValues, onSubmit }: Props) => {
110114
t(`blocking_mode_default`),
111115
t(`blocking_mode_refused`),
112116
t(`blocking_mode_nxdomain`),
117+
t(`blocking_mode_noerror`),
113118
t(`blocking_mode_null_ip`),
114119
t(`blocking_mode_custom_ip`),
115120
];

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
@@ -733,6 +733,7 @@ func validateBlockingMode(
733733
filtering.BlockingModeDefault,
734734
filtering.BlockingModeNXDOMAIN,
735735
filtering.BlockingModeREFUSED,
736+
filtering.BlockingModeNOERROR,
736737
filtering.BlockingModeNullIP:
737738
return nil
738739
case filtering.BlockingModeCustomIP:

internal/dnsforward/msg.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ func (s *Server) genForBlockingMode(
141141
return s.NewMsgNXDOMAIN(req)
142142
case filtering.BlockingModeREFUSED:
143143
return s.makeResponseREFUSED(req)
144+
case filtering.BlockingModeNOERROR:
145+
return s.NewMsgNOERROR(req)
144146
default:
145147
s.logger.ErrorContext(ctx, "invalid blocking mode", "mode", mode)
146148

@@ -395,6 +397,14 @@ func (s *Server) NewMsgNXDOMAIN(req *dns.Msg) (resp *dns.Msg) {
395397
return resp
396398
}
397399

400+
// NewMsgNOERROR creates an empty response pretending there is no address associated with the requested name.
401+
func (s *Server) NewMsgNOERROR(req *dns.Msg) (resp *dns.Msg) {
402+
resp = s.replyCompressed(req)
403+
resp.Ns = s.genSOA(req)
404+
405+
return resp
406+
}
407+
398408
// NewMsgSERVFAIL implements the [proxy.MessageConstructor] interface for
399409
// *Server.
400410
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)