diff --git a/src/api/docs/content/specs/config.yaml b/src/api/docs/content/specs/config.yaml index ceddd424..20ac14e8 100644 --- a/src/api/docs/content/specs/config.yaml +++ b/src/api/docs/content/specs/config.yaml @@ -239,9 +239,9 @@ components: host: type: object properties: - overwrite_v4: + force4: type: boolean - overwrite_v6: + force6: type: boolean IPv4: type: string @@ -250,9 +250,9 @@ components: blocking: type: object properties: - overwrite_v4: + force4: type: boolean - overwrite_v6: + force6: type: boolean IPv4: type: string @@ -551,13 +551,13 @@ components: iCloudPrivateRelay: true reply: host: - overwrite_v4: false - overwrite_v6: false + force4: false + force6: false IPv4: 0.0.0.0 IPv6: "::" blocking: - overwrite_v4: false - overwrite_v6: false + force4: false + force6: false IPv4: 0.0.0.0 IPv6: "::" rateLimit: diff --git a/src/config/config.c b/src/config/config.c index 579dbb81..fdceb000 100644 --- a/src/config/config.c +++ b/src/config/config.c @@ -537,11 +537,11 @@ void initConfig(struct config *conf) conf->dns.specialDomains.iCloudPrivateRelay.d.b = true; // sub-struct dns.reply_addr - conf->dns.reply.host.overwrite_v4.k = "dns.reply.host.overwrite_v4"; - conf->dns.reply.host.overwrite_v4.h = "Use a specific IPv4 address for the Pi-hole host? By default, FTL determines the address of the interface a query arrived on and uses this address for replying to A queries with the most suitable address for the requesting client. This setting can be used to use a fixed, rather than the dynamically obtained, address when Pi-hole responds to the following names: [ \"pi.hole\", \"\", \"pi.hole.\", \".\" ]"; - conf->dns.reply.host.overwrite_v4.t = CONF_BOOL; - conf->dns.reply.host.overwrite_v4.f = FLAG_ADVANCED_SETTING; - conf->dns.reply.host.overwrite_v4.d.b = false; + conf->dns.reply.host.force4.k = "dns.reply.host.force4"; + conf->dns.reply.host.force4.h = "Use a specific IPv4 address for the Pi-hole host? By default, FTL determines the address of the interface a query arrived on and uses this address for replying to A queries with the most suitable address for the requesting client. This setting can be used to use a fixed, rather than the dynamically obtained, address when Pi-hole responds to the following names: [ \"pi.hole\", \"\", \"pi.hole.\", \".\" ]"; + conf->dns.reply.host.force4.t = CONF_BOOL; + conf->dns.reply.host.force4.f = FLAG_ADVANCED_SETTING; + conf->dns.reply.host.force4.d.b = false; conf->dns.reply.host.v4.k = "dns.reply.host.IPv4"; conf->dns.reply.host.v4.h = "Custom IPv4 address for the Pi-hole host"; @@ -550,11 +550,11 @@ void initConfig(struct config *conf) conf->dns.reply.host.v4.f = FLAG_ADVANCED_SETTING; memset(&conf->dns.reply.host.v4.d.in_addr, 0, sizeof(struct in_addr)); - conf->dns.reply.host.overwrite_v6.k = "dns.reply.host.overwrite_v6"; - conf->dns.reply.host.overwrite_v6.h = "Use a specific IPv6 address for the Pi-hole host? See description for the IPv4 variant above for further details."; - conf->dns.reply.host.overwrite_v6.t = CONF_BOOL; - conf->dns.reply.host.overwrite_v6.f = FLAG_ADVANCED_SETTING; - conf->dns.reply.host.overwrite_v6.d.b = false; + conf->dns.reply.host.force6.k = "dns.reply.host.force6"; + conf->dns.reply.host.force6.h = "Use a specific IPv6 address for the Pi-hole host? See description for the IPv4 variant above for further details."; + conf->dns.reply.host.force6.t = CONF_BOOL; + conf->dns.reply.host.force6.f = FLAG_ADVANCED_SETTING; + conf->dns.reply.host.force6.d.b = false; conf->dns.reply.host.v6.k = "dns.reply.host.IPv6"; conf->dns.reply.host.v6.h = "Custom IPv6 address for the Pi-hole host"; @@ -563,11 +563,11 @@ void initConfig(struct config *conf) conf->dns.reply.host.v6.f = FLAG_ADVANCED_SETTING; memset(&conf->dns.reply.host.v6.d.in6_addr, 0, sizeof(struct in6_addr)); - conf->dns.reply.blocking.overwrite_v4.k = "dns.reply.blocking.overwrite_v4"; - conf->dns.reply.blocking.overwrite_v4.h = "Use a specific IPv4 address in IP blocking mode? By default, FTL determines the address of the interface a query arrived on and uses this address for replying to A queries with the most suitable address for the requesting client. This setting can be used to use a fixed, rather than the dynamically obtained, address when Pi-hole responds in the following cases: IP blocking mode is used and this query is to be blocked, regular expressions with the ;reply=IP regex extension."; - conf->dns.reply.blocking.overwrite_v4.t = CONF_BOOL; - conf->dns.reply.blocking.overwrite_v4.f = FLAG_ADVANCED_SETTING; - conf->dns.reply.blocking.overwrite_v4.d.b = false; + conf->dns.reply.blocking.force4.k = "dns.reply.blocking.force4"; + conf->dns.reply.blocking.force4.h = "Use a specific IPv4 address in IP blocking mode? By default, FTL determines the address of the interface a query arrived on and uses this address for replying to A queries with the most suitable address for the requesting client. This setting can be used to use a fixed, rather than the dynamically obtained, address when Pi-hole responds in the following cases: IP blocking mode is used and this query is to be blocked, regular expressions with the ;reply=IP regex extension."; + conf->dns.reply.blocking.force4.t = CONF_BOOL; + conf->dns.reply.blocking.force4.f = FLAG_ADVANCED_SETTING; + conf->dns.reply.blocking.force4.d.b = false; conf->dns.reply.blocking.v4.k = "dns.reply.blocking.IPv4"; conf->dns.reply.blocking.v4.h = "Custom IPv4 address for IP blocking mode"; @@ -576,11 +576,11 @@ void initConfig(struct config *conf) conf->dns.reply.blocking.v4.f = FLAG_ADVANCED_SETTING; memset(&conf->dns.reply.blocking.v4.d.in_addr, 0, sizeof(struct in_addr)); - conf->dns.reply.blocking.overwrite_v6.k = "dns.reply.blocking.overwrite_v6"; - conf->dns.reply.blocking.overwrite_v6.h = "Use a specific IPv6 address in IP blocking mode? See description for the IPv4 variant above for further details."; - conf->dns.reply.blocking.overwrite_v6.t = CONF_BOOL; - conf->dns.reply.blocking.overwrite_v6.f = FLAG_ADVANCED_SETTING; - conf->dns.reply.blocking.overwrite_v6.d.b = false; + conf->dns.reply.blocking.force6.k = "dns.reply.blocking.force6"; + conf->dns.reply.blocking.force6.h = "Use a specific IPv6 address in IP blocking mode? See description for the IPv4 variant above for further details."; + conf->dns.reply.blocking.force6.t = CONF_BOOL; + conf->dns.reply.blocking.force6.f = FLAG_ADVANCED_SETTING; + conf->dns.reply.blocking.force6.d.b = false; conf->dns.reply.blocking.v6.k = "dns.reply.blocking.IPv6"; conf->dns.reply.blocking.v6.h = "Custom IPv6 address for IP blocking mode"; diff --git a/src/config/config.h b/src/config/config.h index 3058b1c4..9db14310 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -139,15 +139,15 @@ struct config { } specialDomains; struct { struct { - struct conf_item overwrite_v4; - struct conf_item overwrite_v6; + struct conf_item force4; struct conf_item v4; + struct conf_item force6; struct conf_item v6; } host; struct { - struct conf_item overwrite_v4; - struct conf_item overwrite_v6; + struct conf_item force4; struct conf_item v4; + struct conf_item force6; struct conf_item v6; } blocking; } reply; diff --git a/src/config/legacy_reader.c b/src/config/legacy_reader.c index 17ed72bd..4ca5dfc3 100644 --- a/src/config/legacy_reader.c +++ b/src/config/legacy_reader.c @@ -401,39 +401,39 @@ const char *readFTLlegacy(struct config *conf) // Use a specific IP address instead of automatically detecting the // IPv4 interface address a query arrived on for A hostname queries // defaults to: not set - conf->dns.reply.host.overwrite_v4.v.b = false; + conf->dns.reply.host.force4.v.b = false; conf->dns.reply.host.v4.v.in_addr.s_addr = 0; buffer = parseFTLconf(fp, "LOCAL_IPV4"); if(buffer != NULL && inet_pton(AF_INET, buffer, &conf->dns.reply.host.v4.v.in_addr)) - conf->dns.reply.host.overwrite_v4.v.b = true; + conf->dns.reply.host.force4.v.b = true; // LOCAL_IPV6 // Use a specific IP address instead of automatically detecting the // IPv6 interface address a query arrived on for AAAA hostname queries // defaults to: not set - conf->dns.reply.host.overwrite_v6.v.b = false; + conf->dns.reply.host.force6.v.b = false; memset(&conf->dns.reply.host.v6.v.in6_addr, 0, sizeof(conf->dns.reply.host.v6.v.in6_addr)); buffer = parseFTLconf(fp, "LOCAL_IPV6"); if(buffer != NULL && inet_pton(AF_INET6, buffer, &conf->dns.reply.host.v6.v.in6_addr)) - conf->dns.reply.host.overwrite_v6.v.b = true; + conf->dns.reply.host.force6.v.b = true; // BLOCK_IPV4 // Use a specific IPv4 address for IP blocking mode replies // defaults to: REPLY_ADDR4 setting - conf->dns.reply.blocking.overwrite_v4.v.b = false; + conf->dns.reply.blocking.force4.v.b = false; conf->dns.reply.blocking.v4.v.in_addr.s_addr = 0; buffer = parseFTLconf(fp, "BLOCK_IPV4"); if(buffer != NULL && inet_pton(AF_INET, buffer, &conf->dns.reply.blocking.v4.v.in_addr)) - conf->dns.reply.blocking.overwrite_v4.v.b = true; + conf->dns.reply.blocking.force4.v.b = true; // BLOCK_IPV6 // Use a specific IPv6 address for IP blocking mode replies // defaults to: REPLY_ADDR6 setting - conf->dns.reply.blocking.overwrite_v6.v.b = false; + conf->dns.reply.blocking.force6.v.b = false; memset(&conf->dns.reply.blocking.v6.v.in6_addr, 0, sizeof(conf->dns.reply.host.v6.v.in6_addr)); buffer = parseFTLconf(fp, "BLOCK_IPV6"); if(buffer != NULL && inet_pton(AF_INET6, buffer, &conf->dns.reply.blocking.v6.v.in6_addr)) - conf->dns.reply.blocking.overwrite_v6.v.b = true; + conf->dns.reply.blocking.force6.v.b = true; // REPLY_ADDR4 (deprecated setting) // Use a specific IP address instead of automatically detecting the @@ -443,15 +443,15 @@ const char *readFTLlegacy(struct config *conf) buffer = parseFTLconf(fp, "REPLY_ADDR4"); if(buffer != NULL && inet_pton(AF_INET, buffer, &reply_addr4)) { - if(conf->dns.reply.host.overwrite_v4.v.b || conf->dns.reply.blocking.overwrite_v4.v.b) + if(conf->dns.reply.host.force4.v.b || conf->dns.reply.blocking.force4.v.b) { log_warn("Ignoring REPLY_ADDR4 as LOCAL_IPV4 or BLOCK_IPV4 has been specified."); } else { - conf->dns.reply.host.overwrite_v4.v.b = true; + conf->dns.reply.host.force4.v.b = true; memcpy(&conf->dns.reply.host.v4.v.in_addr, &reply_addr4, sizeof(reply_addr4)); - conf->dns.reply.blocking.overwrite_v4.v.b = true; + conf->dns.reply.blocking.force4.v.b = true; memcpy(&conf->dns.reply.blocking.v4.v.in_addr, &reply_addr4, sizeof(reply_addr4)); } } @@ -464,15 +464,15 @@ const char *readFTLlegacy(struct config *conf) buffer = parseFTLconf(fp, "REPLY_ADDR6"); if(buffer != NULL && inet_pton(AF_INET, buffer, &reply_addr6)) { - if(conf->dns.reply.host.overwrite_v6.v.b || conf->dns.reply.blocking.overwrite_v6.v.b) + if(conf->dns.reply.host.force6.v.b || conf->dns.reply.blocking.force6.v.b) { log_warn("Ignoring REPLY_ADDR6 as LOCAL_IPV6 or BLOCK_IPV6 has been specified."); } else { - conf->dns.reply.host.overwrite_v6.v.b = true; + conf->dns.reply.host.force6.v.b = true; memcpy(&conf->dns.reply.host.v6.v.in6_addr, &reply_addr6, sizeof(reply_addr6)); - conf->dns.reply.blocking.overwrite_v6.v.b = true; + conf->dns.reply.blocking.force6.v.b = true; memcpy(&conf->dns.reply.blocking.v6.v.in6_addr, &reply_addr6, sizeof(reply_addr6)); } } diff --git a/src/dnsmasq_interface.c b/src/dnsmasq_interface.c index 46ffeee9..24ca0f42 100644 --- a/src/dnsmasq_interface.c +++ b/src/dnsmasq_interface.c @@ -341,9 +341,9 @@ size_t _FTL_make_answer(struct dns_header *header, char *limit, const size_t len config.dns.blocking.mode.v.blocking_mode == MODE_IP_NODATA_AAAA || forced_ip) { - if(hostname && config.dns.reply.host.overwrite_v4.v.b) + if(hostname && config.dns.reply.host.force4.v.b) memcpy(&addr, &config.dns.reply.host.v4.v.in_addr, sizeof(config.dns.reply.host.v4.v.in_addr)); - else if(!hostname && config.dns.reply.blocking.overwrite_v4.v.b) + else if(!hostname && config.dns.reply.blocking.force4.v.b) memcpy(&addr, &config.dns.reply.blocking.v4.v.in_addr, sizeof(config.dns.reply.blocking.v4.v.in_addr)); else memcpy(&addr, &next_iface.addr4, sizeof(addr)); @@ -376,9 +376,9 @@ size_t _FTL_make_answer(struct dns_header *header, char *limit, const size_t len else if(config.dns.blocking.mode.v.blocking_mode == MODE_IP || forced_ip) { - if(hostname && config.dns.reply.host.overwrite_v6.v.b) + if(hostname && config.dns.reply.host.force6.v.b) memcpy(&addr, &config.dns.reply.host.v6.v.in6_addr, sizeof(config.dns.reply.host.v6.v.in6_addr)); - else if(!hostname && config.dns.reply.blocking.overwrite_v6.v.b) + else if(!hostname && config.dns.reply.blocking.force6.v.b) memcpy(&addr, &config.dns.reply.blocking.v6.v.in6_addr, sizeof(config.dns.reply.blocking.v6.v.in6_addr)); else memcpy(&addr, &next_iface.addr6, sizeof(addr)); @@ -533,10 +533,10 @@ bool _FTL_new_query(const unsigned int flags, const char *name, // virtual interface that has only an IPv4 address if((querytype == TYPE_A && !next_iface.haveIPv4 && - !config.dns.reply.host.overwrite_v4.v.b) || + !config.dns.reply.host.force4.v.b) || (querytype == TYPE_AAAA && !next_iface.haveIPv6 && - !config.dns.reply.host.overwrite_v6.v.b)) + !config.dns.reply.host.force6.v.b)) force_next_DNS_reply = REPLY_NODATA; else force_next_DNS_reply = REPLY_IP; diff --git a/test/pihole.toml b/test/pihole.toml index db38864b..e381f3b2 100644 --- a/test/pihole.toml +++ b/test/pihole.toml @@ -239,11 +239,11 @@ # be used to use a fixed, rather than the dynamically obtained, address when Pi-hole # responds to the following names: [ "pi.hole", "", # "pi.hole.", "." ] - overwrite_v4 = true ### CHANGED, default = false + force4 = true ### CHANGED, default = false # Use a specific IPv6 address for the Pi-hole host? See description for the IPv4 # variant above for further details. - overwrite_v6 = true ### CHANGED, default = false + force6 = true ### CHANGED, default = false # Custom IPv4 address for the Pi-hole host # @@ -264,11 +264,11 @@ # be used to use a fixed, rather than the dynamically obtained, address when Pi-hole # responds in the following cases: IP blocking mode is used and this query is to be # blocked, regular expressions with the ;reply=IP regex extension. - overwrite_v4 = true ### CHANGED, default = false + force4 = true ### CHANGED, default = false # Use a specific IPv6 address in IP blocking mode? See description for the IPv4 variant # above for further details. - overwrite_v6 = true ### CHANGED, default = false + force6 = true ### CHANGED, default = false # Custom IPv4 address for IP blocking mode #