Skip to content

Commit 9e07956

Browse files
authored
Merge pull request #2740 from Manakuremati/master
Add dns.cache.rrtype
2 parents b3b9e3c + 3613c37 commit 9e07956

5 files changed

Lines changed: 23 additions & 3 deletions

File tree

src/api/docs/content/specs/config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ components:
252252
type: integer
253253
upstreamBlockedTTL:
254254
type: integer
255+
rrtype:
256+
type: string
255257
revServers:
256258
type: array
257259
items:
@@ -706,6 +708,7 @@ components:
706708
size: 10000
707709
optimizer: 3600
708710
upstreamBlockedTTL: 86400
711+
rrtype: "ANY"
709712
revServers:
710713
- "true,192.168.0.0/24,192.168.0.1,lan"
711714
blocking:

src/config/config.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,14 @@ void initConfig(struct config *conf)
635635
conf->dns.cache.upstreamBlockedTTL.d.ui = 86400;
636636
conf->dns.cache.upstreamBlockedTTL.c = validate_stub; // Only type-based checking
637637

638+
conf->dns.cache.rrtype.k = "dns.cache.rrtype";
639+
conf->dns.cache.rrtype.h = "This is dnsmasq's --cache-rr option, which allows you to define which DNS record types should be cached by PiHole. This option can take a comma-separated list of RR-types as input. The default value ANY caches all record types.";
640+
conf->dns.cache.rrtype.a = cJSON_CreateStringReference("Valid DNS record types in the following form: <rrtype>[,<rrtype>...]");
641+
conf->dns.cache.rrtype.t = CONF_STRING;
642+
conf->dns.cache.rrtype.f = FLAG_RESTART_FTL;
643+
conf->dns.cache.rrtype.d.s = (char*)"ANY";
644+
conf->dns.cache.rrtype.c = validate_stub; // Only type-based checking
645+
638646
// sub-struct dns.blocking
639647
conf->dns.blocking.active.k = "dns.blocking.active";
640648
conf->dns.blocking.active.h = "Should FTL block queries?";

src/config/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ struct config {
160160
struct conf_item size;
161161
struct conf_item optimizer;
162162
struct conf_item upstreamBlockedTTL;
163+
struct conf_item rrtype;
163164
} cache;
164165
struct {
165166
struct conf_item active;

src/config/dnsmasq_config.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,9 +775,9 @@ bool __attribute__((nonnull(1,3))) write_dnsmasq_config(struct config *conf, boo
775775
fputs("\n", pihole_conf);
776776
}
777777

778-
// Add option for caching all DNS records
778+
// Add option for which DNS records types to cache
779779
fputs("# Cache all DNS records\n", pihole_conf);
780-
fputs("cache-rr=ANY\n", pihole_conf);
780+
fprintf(pihole_conf, "cache-rr=%s\n\n", conf->dns.cache.rrtype.v.s);
781781
fputs("\n", pihole_conf);
782782

783783
// Add option for PCAP file recording

test/pihole.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,14 @@
355355
# blocked queries
356356
upstreamBlockedTTL = 86400
357357

358+
# This is dnsmasq's --cache-rr option, which allows you to define which DNS record
359+
# types should be cached by PiHole. This option can take a comma-separated list of
360+
# RR-types as input. The default value ANY caches all record types.
361+
#
362+
# Allowed values are:
363+
# Valid DNS record types in the following form: <rrtype>[,<rrtype>...]
364+
rrtype = "ANY"
365+
358366
[dns.blocking]
359367
# Should FTL block queries?
360368
#
@@ -1679,7 +1687,7 @@
16791687
all = true ### CHANGED, default = false
16801688

16811689
# Configuration statistics:
1682-
# 162 total entries out of which 108 entries are default
1690+
# 163 total entries out of which 109 entries are default
16831691
# --> 54 entries are modified
16841692
# 3 entries are forced through environment:
16851693
# - misc.nice

0 commit comments

Comments
 (0)