/* Pi-hole: A black hole for Internet advertisements * (c) 2017 Pi-hole, LLC (https://pi-hole.net) * Network-wide ad blocking via your own hardware. * * FTL Engine * Config routines * * This file is copyright under the latest version of the EUPL. * Please see LICENSE file for your rights under this license. */ #include "FTL.h" #include "config/config.h" #include "config/toml_reader.h" #include "config/toml_writer.h" #include "config/setupVars.h" #include "log.h" #include "log.h" // readFTLlegacy() #include "legacy_reader.h" // file_exists() #include "files.h" // write_dnsmasq_config() #include "config/dnsmasq_config.h" // lock_shm(), unlock_shm() #include "shmem.h" // dnsmasq_failed #include "daemon.h" // delete_all_sessions() #include "api/api.h" // exit_code #include "signals.h" // validation functions #include "config/validator.h" // getEnvVars() #include "config/env.h" // set_mbedtls_debug_threshold() #include "webserver/webserver.h" // sha256sum() #include "files.h" // restart_ftl() #include "signals.h" // cli_mode #include "args.h" // Global variables struct config config = { 0 }; static bool config_initialized = false; uint8_t last_checksum[SHA256_DIGEST_SIZE] = { 0 }; // Private prototypes static bool port_in_use(const in_port_t port); // Set debug flags from config struct to global debug_flags array // This is called whenever the config is reloaded and debug flags may have // changed void set_debug_flags(struct config *conf) { // Reset debug flags memset(debug_flags, false, sizeof(debug_flags)); // Loop over all debug options and check if at least one is enabled unsigned int elements_set = 0u; for(unsigned int i = 0; i < DEBUG_ELEMENTS-1; i++) { struct conf_item *debug_item = get_debug_item(conf, i); if(debug_item->v.b) { // Add offset of 1 as the first element is "ANY" debug_flags[i + 1] = true; debug_flags[DEBUG_ANY] = true; elements_set++; } } // If all debug flags are set, we set the "ALL" flag. We subtract 1 from // DEBUG_ELEMENTS as the last element is "ALL" itself conf->debug.all.v.b = elements_set == DEBUG_ELEMENTS-1; // Keep mbedTLS in sync, it decides on formatting before we see the // message. Only the live configuration may move the process-global // threshold, a candidate can still be discarded - replace_config() // applies it once the candidate is installed if(conf == &config) set_mbedtls_debug_threshold(conf->debug.tls.v.b); } void set_all_debug(struct config *conf, const bool status) { // Loop over all debug options and check if all are enabled unsigned int elements_set = 0u; for(unsigned int i = 0; i < DEBUG_ELEMENTS-1; i++) { struct conf_item *debug_item = get_debug_item(conf, i); if(debug_item->v.b) elements_set++; } const bool all_set = elements_set == DEBUG_ELEMENTS-1; // If ALL is false and not all debug flags are set, we do not manipulate // the debug flags at all. This is necessary to avoid overwriting individual // debug flag settings when the user has set some of them to true and // "ALL" to false. if(status == false && !all_set) return; // Loop over all debug options and set them to the desired status // We do not set the last element as this is "ALL" itself for(unsigned int i = 0; i < DEBUG_ELEMENTS-1; i++) { // Get pointer to memory location of this conf_item struct conf_item *debug_item = get_debug_item(conf, i); // Set status debug_item->v.b = status; } } // Extract and store key from full path char **gen_config_path(const char *pathin, const char delim) { char *path = (char*)pathin; char *saveptr = path; // Allocate memory for the path elements char **paths = calloc(MAX_CONFIG_PATH_DEPTH, sizeof(char*)); // Sanity check if(!pathin) { log_err("Config path is empty"); return paths; } size_t pathlen = 0; // Extract all path elements while(*path != '\0') { // Advance to either the next delimiter // But only until the end of the string while(*path != delim && *path != '\0') path++; // Get length of the extracted string size_t len = path - saveptr; // Create a private copy of this element in the chain of elements paths[pathlen] = calloc(len + 1, sizeof(char)); // No need to NULL-terminate, strncpy does this for us strncpy(paths[pathlen], saveptr, len); // Did we reach the end of the string? if(*path == '\0') break; // Advance to next character saveptr = ++path; // Advance to next path element pathlen++; // Safety measure: Exit if this path is too deep if(pathlen > MAX_CONFIG_PATH_DEPTH-1) break; } return paths; } void free_config_path(char **paths) { if(paths == NULL) return; for(unsigned int i = 0; i < MAX_CONFIG_PATH_DEPTH; i++) if(paths[i] != NULL) { free(paths[i]); paths[i] = NULL; } } bool __attribute__ ((pure)) check_paths_equal(char **paths1, char **paths2, unsigned int max_level) { if(paths1 == NULL || paths2 == NULL) return false; for(unsigned int i = 0; i < MAX_CONFIG_PATH_DEPTH; i++) { if(i > 0 && paths1[i] == NULL && paths2[i] == NULL) { // Exact match so far and we reached the end, e.g. // config.dns.upstreams.(null) <-> config.dns.upstreams.(null) return true; } if(i > max_level) { // Reached end of maximum to inspect level (to get children) return true; } if(paths1[i] == NULL || paths2[i] == NULL || strcmp(paths1[i],paths2[i]) != 0) { // One of the paths is shorter than the other or one of the elements // doesn't match return false; } } return true; } // Passwords, write-only items and the password hashes are never logged, and // only sessions allowed to change the configuration may read the hashes bool is_secret_conf_item(const struct conf_item *conf_item) { return conf_item->t == CONF_PASSWORD || (conf_item->f & FLAG_WRITE_ONLY) || strcmp(conf_item->k, "webserver.api.pwhash") == 0 || strcmp(conf_item->k, "webserver.api.app_pwhash") == 0; } struct conf_item *get_conf_item(struct config *conf, const unsigned int n) { // Sanity check if(n > CONFIG_ELEMENTS-1) { log_err("Config item with index %u requested but we have only %u elements", n, (unsigned int)CONFIG_ELEMENTS-1); return NULL; } // Return n-th config element return (struct conf_item *)conf + n; } struct conf_item *get_debug_item(struct config *conf, const enum debug_flag debug) { // Sanity check if(debug > DEBUG_MAX-1) { log_err("Debug config item with index %u requested but we have only %i debug elements", debug, DEBUG_MAX-1); return NULL; } // Return n-th config element return (struct conf_item *)&conf->debug + debug; } unsigned int __attribute__ ((pure)) config_path_depth(char **paths) { // Determine depth of this config path for(unsigned int i = 0; i < MAX_CONFIG_PATH_DEPTH; i++) if(paths[i] == NULL) return i; // This should never happen as we have a maximum depth of // MAX_CONFIG_PATH_DEPTH return MAX_CONFIG_PATH_DEPTH; } void duplicate_config(struct config *dst, struct config *src) { // Lock shared memory while we read the (possibly shared) source // config. replace_config() frees the previous config under the same // lock, so holding it here prevents a use-after-free when another // thread swaps the config out while we are still copying its strings. lock_shm(); // Post-processing: // Initialize and verify config data for(unsigned int i = 0; i < CONFIG_ELEMENTS; i++) { // Get pointer to memory location of this conf_item (original) struct conf_item *conf_item = get_conf_item(src, i); // Get pointer to memory location of this conf_item (copy) struct conf_item *copy_item = get_conf_item(dst, i); // Copy constant/static fields memcpy(copy_item, conf_item, sizeof(*conf_item)); // Duplicate allowed values (if defined) // Note: This is no necessary as we simply leave the allowed values // object living forever and merely copy the pointer to its heap living // space around (it is never freed) // if(conf_item->a != NULL) copy_item->a = cJSON_Duplicate(conf_item->a, true); // Make a type-dependent copy of the value switch(conf_item->t) { case CONF_BOOL: case CONF_INT: case CONF_UINT: case CONF_UINT16: case CONF_LONG: case CONF_DOUBLE: case CONF_STRING: case CONF_PASSWORD: // This is a pseudo-type, it is read-only and cannot be read case CONF_ENUM_PTR_TYPE: case CONF_ENUM_BUSY_TYPE: case CONF_ENUM_BLOCKING_MODE: case CONF_ENUM_REFRESH_HOSTNAMES: case CONF_ENUM_PRIVACY_LEVEL: case CONF_ENUM_LISTENING_MODE: case CONF_ENUM_WEB_THEME: case CONF_ENUM_TEMP_UNIT: case CONF_ENUM_BLOCKING_EDNS_MODE: case CONF_STRUCT_IN_ADDR: case CONF_STRUCT_IN6_ADDR: case CONF_ALL_DEBUG_BOOL: // Nothing to do, the memcpy above has already covered this break; case CONF_STRING_ALLOCATED: copy_item->v.s = strdup(conf_item->v.s); break; case CONF_JSON_STRING_ARRAY: copy_item->v.json = cJSON_Duplicate(conf_item->v.json, true); break; } } unlock_shm(); } // True = Identical, False = Different bool compare_config_item(const enum conf_type t, const union conf_value *val1, const union conf_value *val2) { // Make a type-dependent copy of the value switch(t) { case CONF_BOOL: case CONF_INT: case CONF_UINT: case CONF_UINT16: case CONF_LONG: case CONF_DOUBLE: case CONF_ENUM_PTR_TYPE: case CONF_ENUM_BUSY_TYPE: case CONF_ENUM_BLOCKING_MODE: case CONF_ENUM_REFRESH_HOSTNAMES: case CONF_ENUM_PRIVACY_LEVEL: case CONF_ENUM_LISTENING_MODE: case CONF_ENUM_WEB_THEME: case CONF_ENUM_TEMP_UNIT: case CONF_ENUM_BLOCKING_EDNS_MODE: case CONF_STRUCT_IN_ADDR: case CONF_STRUCT_IN6_ADDR: case CONF_ALL_DEBUG_BOOL: // Compare entire union return memcmp(val1, val2, sizeof(*val1)) == 0; case CONF_STRING: case CONF_STRING_ALLOCATED: // Compare strings return strcmp(val1->s, val2->s) == 0; case CONF_JSON_STRING_ARRAY: // Compare JSON object/array return cJSON_Compare(val1->json, val2->json, true); case CONF_PASSWORD: // This is a pseudo item, we assume it has always been changed when // it is specified return strcmp(val2->s, PASSWORD_VALUE) != 0; } return false; } void free_config(struct config *conf, const bool terminating) { // Post-processing: // Initialize and verify config data for(unsigned int i = 0; i < CONFIG_ELEMENTS; i++) { // Get pointer to memory location of this conf_item struct conf_item *conf_item = get_conf_item(conf, i); // Free allowed values (if defined) // Note: This is no necessary as we simply leave the allowed values // object living forever and merely copy the pointer to its heap living // space around (it is never freed) // if(conf->a != NULL) cJSON_Delete(conf->a); // Make a type-dependent copy of the value switch(conf_item->t) { case CONF_BOOL: case CONF_INT: case CONF_UINT: case CONF_UINT16: case CONF_LONG: case CONF_DOUBLE: case CONF_STRING: case CONF_PASSWORD: // This is a pseudo item, it cannot be freed case CONF_ENUM_PTR_TYPE: case CONF_ENUM_BUSY_TYPE: case CONF_ENUM_BLOCKING_MODE: case CONF_ENUM_REFRESH_HOSTNAMES: case CONF_ENUM_PRIVACY_LEVEL: case CONF_ENUM_LISTENING_MODE: case CONF_ENUM_WEB_THEME: case CONF_ENUM_TEMP_UNIT: case CONF_ENUM_BLOCKING_EDNS_MODE: case CONF_STRUCT_IN_ADDR: case CONF_STRUCT_IN6_ADDR: case CONF_ALL_DEBUG_BOOL: // Nothing to do break; case CONF_STRING_ALLOCATED: // Do not free log file path if we are // terminating or nothing can be logged anymore if(terminating && conf_item->f & FLAG_FTL_LOG) continue; free(conf_item->v.s); conf_item->v.s = NULL; conf_item->t = CONF_STRING; // not allocated anymore break; case CONF_JSON_STRING_ARRAY: // Delete default JSON only when terminating. // During config replacements, it is simply // handed over from the old to the new config // structure to avoid unnecessary memory // duplications if(terminating) cJSON_Delete(conf_item->d.json); cJSON_Delete(conf_item->v.json); break; } } } void initConfig(struct config *conf) { if(config_initialized) return; config_initialized = true; // struct dns conf->dns.upstreams.k = "dns.upstreams"; conf->dns.upstreams.h = "Upstream DNS Servers to be used by Pi-hole. If this is not set, Pi-hole will not resolve any non-local queries.\n\n Example: [ \"8.8.8.8\", \"127.0.0.1#5335\", \"docker-resolver\" ]"; conf->dns.upstreams.a = cJSON_CreateStringReference("Array of IP addresses and/or hostnames, optionally with a port (#...)"); conf->dns.upstreams.t = CONF_JSON_STRING_ARRAY; conf->dns.upstreams.d.json = cJSON_CreateArray(); conf->dns.upstreams.f = FLAG_RESTART_FTL; conf->dns.upstreams.c = validate_array_no_newline; conf->dns.CNAMEdeepInspect.k = "dns.CNAMEdeepInspect"; conf->dns.CNAMEdeepInspect.h = "Use this option to control deep CNAME inspection. Disabling it might be beneficial for very low-end devices"; conf->dns.CNAMEdeepInspect.t = CONF_BOOL; conf->dns.CNAMEdeepInspect.d.b = true; conf->dns.CNAMEdeepInspect.c = validate_stub; // Only type-based checking conf->dns.blockESNI.k = "dns.blockESNI"; conf->dns.blockESNI.h = "Should _esni. subdomains of blocked domains also be blocked by default? Encrypted Server Name Indication (ESNI) is certainly a good step into the right direction to enhance privacy on the web. It prevents on-path observers, including ISPs, coffee shop owners and firewalls, from intercepting the TLS Server Name Indication (SNI) extension by encrypting it. This prevents the SNI from being used to determine which websites users are visiting.\n\n ESNI will obviously cause issues for pixelserv-tls which will be unable to generate matching certificates on-the-fly when it cannot read the SNI. According to the IETF draft (link above), we can easily restore pixelserv-tls's operation by replying NXDOMAIN to _esni. subdomains of blocked domains as this mimics a \"not configured for this domain\" behavior.\n\n ESNI is mostly obsolete. It was previously rolled out by Cloudflare and Firefox, but they, as well as almost every client and server, are now using Encrypted Client Hello (ECH) instead of ESNI. ECH is served via the HTTPS record on the same RRname, so it will automatically be blocked."; conf->dns.blockESNI.t = CONF_BOOL; conf->dns.blockESNI.d.b = true; conf->dns.blockESNI.c = validate_stub; // Only type-based checking conf->dns.EDNS0ECS.k = "dns.EDNS0ECS"; conf->dns.EDNS0ECS.h = "Should we overwrite the query source when client information is provided through EDNS0 client subnet (ECS) information? This allows Pi-hole to obtain client IPs even if they are hidden behind the NAT of a router. This feature has been requested and discussed on Discourse where further information how to use it can be found: https://discourse.pi-hole.net/t/support-for-add-subnet-option-from-dnsmasq-ecs-edns0-client-subnet/35940"; conf->dns.EDNS0ECS.t = CONF_BOOL; conf->dns.EDNS0ECS.d.b = true; conf->dns.EDNS0ECS.c = validate_stub; // Only type-based checking conf->dns.ignoreLocalhost.k = "dns.ignoreLocalhost"; conf->dns.ignoreLocalhost.h = "Should FTL hide queries made by localhost?"; conf->dns.ignoreLocalhost.t = CONF_BOOL; conf->dns.ignoreLocalhost.d.b = false; conf->dns.ignoreLocalhost.c = validate_stub; // Only type-based checking conf->dns.showDNSSEC.k = "dns.showDNSSEC"; conf->dns.showDNSSEC.h = "Should FTL analyze and show internally generated DNSSEC queries?"; conf->dns.showDNSSEC.t = CONF_BOOL; conf->dns.showDNSSEC.d.b = true; conf->dns.showDNSSEC.c = validate_stub; // Only type-based checking conf->dns.analyzeOnlyAandAAAA.k = "dns.analyzeOnlyAandAAAA"; conf->dns.analyzeOnlyAandAAAA.h = "Should FTL analyze *only* A and AAAA queries?"; conf->dns.analyzeOnlyAandAAAA.t = CONF_BOOL; conf->dns.analyzeOnlyAandAAAA.d.b = false; conf->dns.analyzeOnlyAandAAAA.c = validate_stub; // Only type-based checking conf->dns.piholePTR.k = "dns.piholePTR"; conf->dns.piholePTR.h = "Controls whether and how FTL will reply with for address for which a local interface exists. Changing this setting causes FTL to restart."; { struct enum_options piholePTR[] = { { get_ptr_type_str(PTR_NONE), "Pi-hole will not respond automatically on PTR requests to local interface addresses. Ensure pi.hole and/or hostname records exist elsewhere." }, { get_ptr_type_str(PTR_HOSTNAME), "Serve the machine's hostname. The hostname is queried from the kernel through uname(2)->nodename. If the machine has multiple network interfaces, it can also have multiple nodenames. In this case, it is unspecified and up to the kernel which one will be returned. On Linux, the returned string is what has been set using sethostname(2) which is typically what has been set in /etc/hostname." }, { get_ptr_type_str(PTR_HOSTNAMEFQDN), "Serve the machine's hostname (see limitations above) as fully qualified domain by adding the local domain. If no local domain has been defined (config option dns.domain.name), FTL tries to query the domain name from the kernel using getdomainname(2). If this fails, FTL appends \".no_fqdn_available\" to the hostname." }, { get_ptr_type_str(PTR_PIHOLE), "Respond with \"pi.hole\"." } }; CONFIG_ADD_ENUM_OPTIONS(conf->dns.piholePTR.a, piholePTR); } conf->dns.piholePTR.t = CONF_ENUM_PTR_TYPE; conf->dns.piholePTR.d.ptr_type = PTR_PIHOLE; conf->dns.piholePTR.f = FLAG_RESTART_FTL; conf->dns.piholePTR.c = validate_stub; // Only type-based checking conf->dns.replyWhenBusy.k = "dns.replyWhenBusy"; conf->dns.replyWhenBusy.h = "How should FTL handle queries when the gravity database is not available?"; { struct enum_options replyWhenBusy[] = { { get_busy_reply_str(BUSY_BLOCK), "Block all queries when the database is busy." }, { get_busy_reply_str(BUSY_ALLOW), "Allow all queries when the database is busy." }, { get_busy_reply_str(BUSY_REFUSE), "Refuse all queries which arrive while the database is busy." }, { get_busy_reply_str(BUSY_DROP), "Just drop the queries, i.e., never reply to them at all. Despite \"REFUSE\" sounding similar to \"DROP\", it turned out that many clients will just immediately retry, causing up to several thousands of queries per second. This does not happen in \"DROP\" mode." } }; CONFIG_ADD_ENUM_OPTIONS(conf->dns.replyWhenBusy.a, replyWhenBusy); } conf->dns.replyWhenBusy.t = CONF_ENUM_BUSY_TYPE; conf->dns.replyWhenBusy.d.busy_reply = BUSY_ALLOW; conf->dns.replyWhenBusy.c = validate_stub; // Only type-based checking conf->dns.blockTTL.k = "dns.blockTTL"; conf->dns.blockTTL.h = "FTL's internal TTL to be handed out for blocked queries in seconds. This settings allows users to select a value different from the dnsmasq config option local-ttl. This is useful in context of locally used hostnames that are known to stay constant over long times (printers, etc.).\n\n Note that large values may render whitelisting ineffective due to client-side caching of blocked queries."; conf->dns.blockTTL.a = cJSON_CreateStringReference("A positive integer value in seconds"); conf->dns.blockTTL.t = CONF_UINT; conf->dns.blockTTL.d.ui = 2; conf->dns.blockTTL.c = validate_stub; // Only type-based checking conf->dns.hosts.k = "dns.hosts"; conf->dns.hosts.h = "Array of custom DNS records\n\n Example: [ \"127.0.0.1 mylocal\", \"192.168.0.1 therouter\" ]"; conf->dns.hosts.a = cJSON_CreateStringReference("Array of custom DNS records each one in HOSTS form: \"IP HOSTNAME [HOSTNAME ...]\""); conf->dns.hosts.t = CONF_JSON_STRING_ARRAY; conf->dns.hosts.d.json = cJSON_CreateArray(); conf->dns.hosts.c = validate_dns_hosts; conf->dns.domainNeeded.k = "dns.domainNeeded"; conf->dns.domainNeeded.h = "If set, queries for plain names, without dots or domain parts, are never forwarded to upstream nameservers"; conf->dns.domainNeeded.t = CONF_BOOL; conf->dns.domainNeeded.f = FLAG_RESTART_FTL; conf->dns.domainNeeded.d.b = false; conf->dns.domainNeeded.c = validate_stub; // Only type-based checking conf->dns.expandHosts.k = "dns.expandHosts"; conf->dns.expandHosts.h = "If set, the domain is added to simple names (without a period) in /etc/hosts in the same way as for DHCP-derived names"; conf->dns.expandHosts.t = CONF_BOOL; conf->dns.expandHosts.f = FLAG_RESTART_FTL; conf->dns.expandHosts.d.b = false; conf->dns.expandHosts.c = validate_stub; // Only type-based checking conf->dns.bogusPriv.k = "dns.bogusPriv"; conf->dns.bogusPriv.h = "Should all reverse lookups for private IP ranges (i.e., 192.168.x.y, etc) which are not found in /etc/hosts or the DHCP leases file be answered with \"no such domain\" rather than being forwarded upstream?"; conf->dns.bogusPriv.t = CONF_BOOL; conf->dns.bogusPriv.f = FLAG_RESTART_FTL; conf->dns.bogusPriv.d.b = true; conf->dns.bogusPriv.c = validate_stub; // Only type-based checking conf->dns.dnssec.k = "dns.dnssec"; conf->dns.dnssec.h = "Validate DNS replies using DNSSEC?"; conf->dns.dnssec.t = CONF_BOOL; conf->dns.dnssec.f = FLAG_RESTART_FTL; conf->dns.dnssec.c = validate_stub; // Only type-based checking conf->dns.dnssec.d.b = false; conf->dns.interface.k = "dns.interface"; conf->dns.interface.h = "Interface to use for DNS (see also dns.listeningMode) and DHCP (if enabled). Leave empty for auto-detection."; conf->dns.interface.a = cJSON_CreateStringReference("a valid interface name"); conf->dns.interface.t = CONF_STRING; conf->dns.interface.f = FLAG_RESTART_FTL; conf->dns.interface.d.s = (char*)""; conf->dns.interface.c = validate_str_no_newline; conf->dns.hostRecord.k = "dns.hostRecord"; conf->dns.hostRecord.h = "Add an A, AAAA and PTR record to the DNS. This adds a singular name to the DNS with associated IPv4 (A) and IPv6 (AAAA) records\n\n Example: \"laptop,laptop.lan,192.168.0.1,1234::100\""; conf->dns.hostRecord.a = cJSON_CreateStringReference("A string in the format \"[,....],[],[][,]\""); conf->dns.hostRecord.t = CONF_STRING; conf->dns.hostRecord.f = FLAG_RESTART_FTL; conf->dns.hostRecord.d.s = (char*)""; conf->dns.hostRecord.c = validate_str_no_newline; conf->dns.listeningMode.k = "dns.listeningMode"; conf->dns.listeningMode.h = "Pi-hole interface listening modes"; { struct enum_options listeningMode[] = { { get_listeningMode_str(LISTEN_LOCAL), "Allow only local requests. This setting accepts DNS queries only from hosts whose address is on a local subnet, i.e., a subnet for which an interface exists on the server. It is intended to be set as a default on installation, to allow unconfigured installations to be useful but also safe from being used for DNS amplification attacks if (accidentally) running public." }, { get_listeningMode_str(LISTEN_SINGLE), "Permit all origins, accept only on the specified interface. Respond only to queries arriving on the specified interface. The loopback (lo) interface is automatically added to the list of interfaces to use when this option is used. Make sure your Pi-hole is properly firewalled!" }, { get_listeningMode_str(LISTEN_BIND), "By default, FTL binds the wildcard address. If this is not what you want, you can use this option as it forces FTL to really bind only the interfaces it is listening on. Note that this may result in issues when the interface may go down (cable unplugged, etc.). About the only time when this is useful is when running another nameserver on the same port on the same machine. This may also happen if you run a virtualization API such as libvirt. When this option is used, IP alias interface labels (e.g. enp2s0:0) are checked rather than interface names." }, { get_listeningMode_str(LISTEN_ALL), "Permit all origins, accept on all interfaces. Make sure your Pi-hole is properly firewalled! This truly allows any traffic to be replied to and is a dangerous thing to do as your Pi-hole could become an open resolver. You should always ask yourself if the first option doesn't work for you as well." }, { get_listeningMode_str(LISTEN_NONE), "Do not add any configuration concerning the listening mode to the dnsmasq configuration file. This is useful if you want to manually configure the listening mode in auxiliary configuration files. This option is really meant for advanced users only, support for this option may be limited." } }; CONFIG_ADD_ENUM_OPTIONS(conf->dns.listeningMode.a, listeningMode); } conf->dns.listeningMode.t = CONF_ENUM_LISTENING_MODE; conf->dns.listeningMode.f = FLAG_RESTART_FTL; conf->dns.listeningMode.d.listeningMode = LISTEN_LOCAL; conf->dns.listeningMode.c = validate_stub; // Only type-based checking conf->dns.queryLogging.k = "dns.queryLogging"; conf->dns.queryLogging.h = "Log DNS queries and replies to pihole.log"; conf->dns.queryLogging.t = CONF_BOOL; conf->dns.queryLogging.f = FLAG_RESTART_FTL; conf->dns.queryLogging.d.b = true; conf->dns.queryLogging.c = validate_stub; // Only type-based checking conf->dns.cnameRecords.k = "dns.cnameRecords"; conf->dns.cnameRecords.h = "List of CNAME records which indicate that is really . If the is given, it overwrites the value of local-ttl"; conf->dns.cnameRecords.a = cJSON_CreateStringReference("Array of CNAMEs, each one in the following form: \",[,]\""); conf->dns.cnameRecords.t = CONF_JSON_STRING_ARRAY; conf->dns.cnameRecords.f = FLAG_RESTART_FTL; conf->dns.cnameRecords.d.json = cJSON_CreateArray(); conf->dns.cnameRecords.c = validate_dns_cnames; conf->dns.port.k = "dns.port"; conf->dns.port.h = "Port used by the DNS server"; conf->dns.port.a = cJSON_CreateStringReference("Any available valid (1 - 65535) port number"); conf->dns.port.t = CONF_UINT16; conf->dns.port.f = FLAG_RESTART_FTL; conf->dns.port.d.u16 = 53u; conf->dns.port.c = validate_stub; // Only type-based checking conf->dns.localise.k = "dns.localise"; conf->dns.localise.h = "Enable/Disable the localise-queries option of dnsmasq. When this setting is disabled dnsmasq will return all possible values for local DNS Records. Enabled by default"; conf->dns.localise.t = CONF_BOOL; conf->dns.localise.f = FLAG_RESTART_FTL; conf->dns.localise.d.b = true; conf->dns.localise.c = validate_stub; // Only type-based checking conf->dns.revServers.k = "dns.revServers"; conf->dns.revServers.h = "Reverse server (formerly called \"conditional forwarding\")\n\n If not configured as your DHCP server, Pi-hole typically won't be able to determine the names of devices on your local network. As a result, tables such as Top Clients will only show IP addresses.\n\n One solution for this is to configure Pi-hole to forward these requests to your DHCP server (most likely your router), but only for devices on your home network. To configure this we will need to know the IP address of your DHCP server and which addresses belong to your local network.\n\n Example: [ \"true,192.168.0.0/24,192.168.0.1,fritz.box\" ]"; conf->dns.revServers.a = cJSON_CreateStringReference("Array of reverse servers each one in the following form:\n\n \",[/],[#][,]\"\n\nExplanation of individual components:\n\n - \"\": either \"true\" or \"false\"\n\n - \"[/]\": Address range for the reverse server feature in CIDR notation. If the prefix length is omitted, either 32 (IPv4) or 128 (IPv6) are substituted (exact address match). This is almost certainly not what you want here.\n Example: \"192.168.0.0/24\" for the range 192.168.0.1 - 192.168.0.255\n\n - \"[#]\": Target server to be used for the reverse server feature\n Example: \"192.168.0.1#53\"\n\n - \"\": Domain used for the reverse server feature (e.g., \"fritz.box\")\n Example: \"fritz.box\""); conf->dns.revServers.t = CONF_JSON_STRING_ARRAY; conf->dns.revServers.d.json = cJSON_CreateArray(); conf->dns.revServers.c = validate_dns_revServers; conf->dns.revServers.f = FLAG_RESTART_FTL; // sub-struct dns.cache conf->dns.domain.name.k = "dns.domain.name"; conf->dns.domain.name.h = "The DNS domain used by your Pi-hole.\n\n This DNS domain is purely local. FTL may answer queries from its local cache and configuration but *never* forwards any requests upstream *unless* you have configured a dns.revServer exactly for this domain. In the latter case, all queries for this domain are sent exclusively to this server (including reverse lookups).\n\n For DHCP, this has two effects; firstly it causes the DHCP server to return the domain to any hosts which request it, and secondly it sets the domain which it is legal for DHCP-configured hosts to claim. The intention is to constrain hostnames so that an untrusted host on the LAN cannot advertise its name via DHCP as e.g. \"google.com\" and capture traffic not meant for it. If no domain suffix is specified, then any DHCP hostname with a domain part (ie with a period) will be disallowed and logged. If a domain is specified, then hostnames with a domain part are allowed, provided the domain part matches the suffix. In addition, when a suffix is set then hostnames without a domain part have the suffix added as an optional domain part. For instance, we can set domain=mylab.com and have a machine whose DHCP hostname is \"laptop\". The IP address for that machine is available both as \"laptop\" and \"laptop.mylab.com\".\n\n You can disable setting a domain by setting this option to an empty string."; conf->dns.domain.name.a = cJSON_CreateStringReference("Any valid domain"); conf->dns.domain.name.t = CONF_STRING; conf->dns.domain.name.f = FLAG_RESTART_FTL; conf->dns.domain.name.d.s = (char*)"lan"; conf->dns.domain.name.c = validate_dns_domain; conf->dns.domain.local.k = "dns.domain.local"; conf->dns.domain.local.h = "If set, the domain configured by dns.domain.name is considered local and queries for this domain are never forwarded upstream unless a dns.revServer is configured for this domain.\n\n If unset, queries for this domain are forwarded upstream to (possibly public) server which is probably not what you want *unless* you have added extra configuration for this domain *or* your upstream servers are able to handle local domains (e.g., router)."; conf->dns.domain.local.t = CONF_BOOL; conf->dns.domain.local.f = FLAG_RESTART_FTL; conf->dns.domain.local.d.b = true; conf->dns.domain.local.c = validate_stub; // Only type-based checking // sub-struct dns.cache conf->dns.cache.size.k = "dns.cache.size"; conf->dns.cache.size.h = "Cache size of the DNS server. Note that expiring cache entries naturally make room for new insertions over time.\n\nSetting this number too high will have an adverse effect as not only more space is needed, but also lookup speed gets degraded in the 10,000+ range. dnsmasq may issue a warning when you go beyond 10,000+ cache entries."; conf->dns.cache.size.a = cJSON_CreateStringReference("A positive integer value"); conf->dns.cache.size.t = CONF_UINT; conf->dns.cache.size.f = FLAG_RESTART_FTL; conf->dns.cache.size.d.ui = 10000u; conf->dns.cache.size.c = validate_stub; // Only type-based checking conf->dns.cache.optimizer.k = "dns.cache.optimizer"; conf->dns.cache.optimizer.h = "Query cache optimizer: If a DNS name exists in the cache, but its time-to-live has expired only recently, the data will be used anyway (a refreshing from upstream is triggered). This can improve DNS query delays especially over unreliable Internet connections. This feature comes at the expense of possibly sometimes returning out-of-date data and less efficient cache utilization, since old data cannot be flushed when its TTL expires, so the cache becomes mostly least-recently-used. To mitigate issues caused by massively outdated DNS replies, the maximum overaging of cached records is limited. We strongly recommend staying below 86400 (1 day) with this option.\n\n Setting the TTL excess time to zero will serve stale cache data regardless how long it has expired. This is not recommended as it may lead to stale data being served for a long time. Setting this option to any negative value will disable this feature altogether."; conf->dns.cache.optimizer.a = cJSON_CreateStringReference("A positive integer value in seconds, or any negative to disable this feature"); conf->dns.cache.optimizer.t = CONF_INT; conf->dns.cache.optimizer.f = FLAG_RESTART_FTL; conf->dns.cache.optimizer.d.i = 3600u; conf->dns.cache.optimizer.c = validate_stub; // Only type-based checking conf->dns.cache.upstreamBlockedTTL.k = "dns.cache.upstreamBlockedTTL"; conf->dns.cache.upstreamBlockedTTL.h = "This setting allows you to specify the TTL used for queries blocked upstream. Once the TTL expires, the query will be forwarded to the upstream server again to check if the block is still valid. Defaults to caching for one day (86400 seconds). Setting this value to zero disables caching of queries blocked upstream."; conf->dns.cache.upstreamBlockedTTL.a = cJSON_CreateStringReference("A positive integer value in seconds, or zero to disable caching of upstream blocked queries"); conf->dns.cache.upstreamBlockedTTL.t = CONF_UINT; conf->dns.cache.upstreamBlockedTTL.d.ui = 86400; conf->dns.cache.upstreamBlockedTTL.c = validate_stub; // Only type-based checking conf->dns.cache.rrtype.k = "dns.cache.rrtype"; 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."; conf->dns.cache.rrtype.a = cJSON_CreateStringReference("Valid DNS record types in the following form: [,...]"); conf->dns.cache.rrtype.t = CONF_STRING; conf->dns.cache.rrtype.f = FLAG_RESTART_FTL; conf->dns.cache.rrtype.d.s = (char*)"ANY"; conf->dns.cache.rrtype.c = validate_str_no_newline; // sub-struct dns.blocking conf->dns.blocking.active.k = "dns.blocking.active"; conf->dns.blocking.active.h = "Should FTL block queries?"; conf->dns.blocking.active.t = CONF_BOOL; conf->dns.blocking.active.d.b = true; conf->dns.blocking.active.c = validate_stub; // Only type-based checking conf->dns.blocking.mode.k = "dns.blocking.mode"; conf->dns.blocking.mode.h = "How should FTL reply to blocked queries?"; { struct enum_options blockingmode[] = { { get_blocking_mode_str(MODE_NULL), "In NULL mode, which is both the default and recommended mode for Pi-hole FTLDNS, blocked queries will be answered with the \"unspecified address\" (0.0.0.0 or ::). The \"unspecified address\" is a reserved IP address specified by RFC 3513 - Internet Protocol Version 6 (IPv6) Addressing Architecture, section 2.5.2." }, { get_blocking_mode_str(MODE_IP_NODATA_AAAA), "In IP-NODATA-AAAA mode, blocked queries will be answered with the local IPv4 addresses of your Pi-hole. Blocked AAAA queries will be answered with NODATA-IPV6 and clients will only try to reach your Pi-hole over its static IPv4 address." }, { get_blocking_mode_str(MODE_IP), "In IP mode, blocked queries will be answered with the local IP addresses of your Pi-hole." }, { get_blocking_mode_str(MODE_NX), "In NXDOMAIN mode, blocked queries will be answered with an empty response (i.e., there won't be an answer section) and status NXDOMAIN. A NXDOMAIN response should indicate that there is no such domain to the client making the query." }, { get_blocking_mode_str(MODE_NODATA), "In NODATA mode, blocked queries will be answered with an empty response (no answer section) and status NODATA. A NODATA response indicates that the domain exists, but there is no record for the requested query type." } }; CONFIG_ADD_ENUM_OPTIONS(conf->dns.blocking.mode.a, blockingmode); } conf->dns.blocking.mode.t = CONF_ENUM_BLOCKING_MODE; conf->dns.blocking.mode.d.blocking_mode = MODE_NULL; conf->dns.blocking.mode.c = validate_stub; // Only type-based checking conf->dns.blocking.edns.k = "dns.blocking.edns"; conf->dns.blocking.edns.h = "Should FTL enrich blocked replies with EDNS0 information?"; { struct enum_options blocking_edns[] = { { get_edns_mode_str(EDNS_MODE_NONE), "In NONE mode, no additional EDNS information is added to blocked queries" }, { get_edns_mode_str(EDNS_MODE_CODE), "In CODE mode, blocked queries will be enriched with EDNS info-code BLOCKED (15)" }, { get_edns_mode_str(EDNS_MODE_TEXT), "In TEXT mode, blocked queries will be enriched with EDNS info-code BLOCKED (15) and a text message describing the reason for the block" } }; CONFIG_ADD_ENUM_OPTIONS(conf->dns.blocking.edns.a, blocking_edns); } conf->dns.blocking.edns.t = CONF_ENUM_BLOCKING_EDNS_MODE; conf->dns.blocking.edns.d.edns_mode = EDNS_MODE_TEXT; conf->dns.blocking.edns.c = validate_stub; // Only type-based checking // sub-struct dns.special_domains conf->dns.specialDomains.mozillaCanary.k = "dns.specialDomains.mozillaCanary"; conf->dns.specialDomains.mozillaCanary.h = "Should Pi-hole always reply with NXDOMAIN to A and AAAA queries of use-application-dns.net to disable Firefox automatic DNS-over-HTTP?\n\n This follows the recommendation on https://support.mozilla.org/en-US/kb/configuring-networks-disable-dns-over-https"; conf->dns.specialDomains.mozillaCanary.t = CONF_BOOL; conf->dns.specialDomains.mozillaCanary.d.b = true; conf->dns.specialDomains.mozillaCanary.c = validate_stub; // Only type-based checking conf->dns.specialDomains.iCloudPrivateRelay.k = "dns.specialDomains.iCloudPrivateRelay"; conf->dns.specialDomains.iCloudPrivateRelay.h = "Should Pi-hole always reply with NXDOMAIN to A and AAAA queries of mask.icloud.com and mask-h2.icloud.com to disable Apple's iCloud Private Relay to prevent Apple devices from bypassing Pi-hole?\n\n This follows the recommendation on https://developer.apple.com/support/prepare-your-network-for-icloud-private-relay"; conf->dns.specialDomains.iCloudPrivateRelay.t = CONF_BOOL; conf->dns.specialDomains.iCloudPrivateRelay.d.b = true; conf->dns.specialDomains.iCloudPrivateRelay.c = validate_stub; // Only type-based checking conf->dns.specialDomains.designatedResolver.k = "dns.specialDomains.designatedResolver"; conf->dns.specialDomains.designatedResolver.h = "Should Pi-hole always reply with NODATA to all queries to zone resolver.arpa to prevent devices from bypassing Pi-hole using Discovery of Designated Resolvers?\n\n This is based on recommendations at the end of RFC 9462, section 4."; conf->dns.specialDomains.designatedResolver.t = CONF_BOOL; conf->dns.specialDomains.designatedResolver.d.b = true; conf->dns.specialDomains.designatedResolver.c = validate_stub; // Only type-based checking // sub-struct dns.reply_addr 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.\n\n This setting can be used to use a fixed, rather than the dynamically obtained, address when Pi-hole responds to the following names:\n - \"pi.hole\"\n - \"\"\n - \"pi.hole.\"\n - \".\""; conf->dns.reply.host.force4.t = CONF_BOOL; conf->dns.reply.host.force4.d.b = false; conf->dns.reply.host.force4.c = validate_stub; // Only type-based checking conf->dns.reply.host.v4.k = "dns.reply.host.IPv4"; conf->dns.reply.host.v4.h = "Custom IPv4 address for the Pi-hole host"; conf->dns.reply.host.v4.a = cJSON_CreateStringReference("A valid IPv4 address or empty string (\"\")"); conf->dns.reply.host.v4.t = CONF_STRUCT_IN_ADDR; memset(&conf->dns.reply.host.v4.d.in_addr, 0, sizeof(struct in_addr)); conf->dns.reply.host.v4.c = validate_stub; // Only type-based checking 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.d.b = false; conf->dns.reply.host.force6.c = validate_stub; // Only type-based checking conf->dns.reply.host.v6.k = "dns.reply.host.IPv6"; conf->dns.reply.host.v6.h = "Custom IPv6 address for the Pi-hole host"; conf->dns.reply.host.v6.a = cJSON_CreateStringReference("A valid IPv6 address or empty string (\"\")"); conf->dns.reply.host.v6.t = CONF_STRUCT_IN6_ADDR; memset(&conf->dns.reply.host.v6.d.in6_addr, 0, sizeof(struct in6_addr)); conf->dns.reply.host.v6.c = validate_stub; // Only type-based checking // sub-struct dns.reply.blocking 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.\n\n This setting can be used to use a fixed, rather than the dynamically obtained, address when Pi-hole responds in the following cases:\n - IP blocking mode is used and this query is to be blocked\n - regular expressions with the ;reply=IP regex extension."; conf->dns.reply.blocking.force4.t = CONF_BOOL; conf->dns.reply.blocking.force4.d.b = false; conf->dns.reply.blocking.force4.c = validate_stub; // Only type-based checking conf->dns.reply.blocking.v4.k = "dns.reply.blocking.IPv4"; conf->dns.reply.blocking.v4.h = "Custom IPv4 address for IP blocking mode"; conf->dns.reply.blocking.v4.a = cJSON_CreateStringReference("A valid IPv4 address or empty string (\"\")"); conf->dns.reply.blocking.v4.t = CONF_STRUCT_IN_ADDR; memset(&conf->dns.reply.blocking.v4.d.in_addr, 0, sizeof(struct in_addr)); conf->dns.reply.blocking.v4.c = validate_stub; // Only type-based checking 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.d.b = false; conf->dns.reply.blocking.force6.c = validate_stub; // Only type-based checking conf->dns.reply.blocking.v6.k = "dns.reply.blocking.IPv6"; conf->dns.reply.blocking.v6.h = "Custom IPv6 address for IP blocking mode"; conf->dns.reply.blocking.v6.a = cJSON_CreateStringReference("A valid IPv6 address or empty string (\"\")"); conf->dns.reply.blocking.v6.t = CONF_STRUCT_IN6_ADDR; memset(&conf->dns.reply.blocking.v6.d.in6_addr, 0, sizeof(struct in6_addr)); conf->dns.reply.blocking.v6.c = validate_stub; // Only type-based checking // sub-struct dns.rate_limit conf->dns.rateLimit.count.k = "dns.rateLimit.count"; conf->dns.rateLimit.count.h = "Rate-limited queries are answered with a REFUSED reply and not further processed by FTL.\n\n The default settings for FTL's rate-limiting are to permit no more than 1000 queries in 60 seconds. Both numbers can be customized independently. It is important to note that rate-limiting is happening on a per-client basis. Other clients can continue to use FTL while rate-limited clients are short-circuited at the same time.\n\n For this setting, both numbers, the maximum number of queries within a given time, and the length of the time interval (seconds) have to be specified. For instance, if you want to set a rate limit of 1 query per hour, the option should look like dns.rateLimit.count=1 and dns.rateLimit.interval=3600. The time interval is relative to when FTL has finished starting (start of the daemon + possible delay by DELAY_STARTUP) then it will advance in steps of the rate-limiting interval. If a client reaches the maximum number of queries it will be blocked until the end of the current interval. This will be logged to /var/log/pihole/FTL.log, e.g. Rate-limiting 10.0.1.39 for at least 44 seconds. If the client continues to send queries while being blocked already and this number of queries during the blocking exceeds the limit the client will continue to be blocked until the end of the next interval (FTL.log will contain lines like Still rate-limiting 10.0.1.39 as it made additional 5007 queries). As soon as the client requests less than the set limit, it will be unblocked (Ending rate-limitation of 10.0.1.39).\n\n Rate-limiting may be disabled altogether by setting both values to zero (this results in the same behavior as before FTL v5.7).\n\n How many queries are permitted..."; conf->dns.rateLimit.count.a = cJSON_CreateStringReference("A positive integer value"); conf->dns.rateLimit.count.t = CONF_UINT; conf->dns.rateLimit.count.d.ui = 1000; conf->dns.rateLimit.count.c = validate_stub; // Only type-based checking conf->dns.rateLimit.interval.k = "dns.rateLimit.interval"; conf->dns.rateLimit.interval.h = "... in the set interval before rate-limiting?"; conf->dns.rateLimit.interval.a = cJSON_CreateStringReference("A positive integer value in seconds"); conf->dns.rateLimit.interval.t = CONF_UINT; conf->dns.rateLimit.interval.d.ui = 60; conf->dns.rateLimit.interval.c = validate_stub; // Only type-based checking // sub-struct dhcp conf->dhcp.active.k = "dhcp.active"; conf->dhcp.active.h = "Is the embedded DHCP server enabled?"; conf->dhcp.active.t = CONF_BOOL; conf->dhcp.active.f = FLAG_RESTART_FTL; conf->dhcp.active.d.b = false; conf->dhcp.active.c = validate_stub; // Only type-based checking conf->dhcp.start.k = "dhcp.start"; conf->dhcp.start.h = "Start address of the DHCP address pool\n\n Example: \"192.168.0.10\""; conf->dhcp.start.a = cJSON_CreateStringReference("A valid IPv4 address, or empty string (\"\")"); conf->dhcp.start.t = CONF_STRUCT_IN_ADDR; conf->dhcp.start.f = FLAG_RESTART_FTL; memset(&conf->dhcp.start.d.in_addr, 0, sizeof(struct in_addr)); conf->dhcp.start.c = validate_stub; // Only type-based checking conf->dhcp.end.k = "dhcp.end"; conf->dhcp.end.h = "End address of the DHCP address pool\n\n Example: \"192.168.0.250\""; conf->dhcp.end.a = cJSON_CreateStringReference("A valid IPv4 address, or empty string (\"\")"); conf->dhcp.end.t = CONF_STRUCT_IN_ADDR; conf->dhcp.end.f = FLAG_RESTART_FTL; memset(&conf->dhcp.end.d.in_addr, 0, sizeof(struct in_addr)); conf->dhcp.end.c = validate_stub; // Only type-based checking conf->dhcp.router.k = "dhcp.router"; conf->dhcp.router.h = "Address of the gateway to be used (typically the address of your router in a home installation)\n\n Example: \"192.168.0.1\""; conf->dhcp.router.a = cJSON_CreateStringReference("A valid IPv4 address, or empty string (\"\")"); conf->dhcp.router.t = CONF_STRUCT_IN_ADDR; conf->dhcp.router.f = FLAG_RESTART_FTL; memset(&conf->dhcp.router.d.in_addr, 0, sizeof(struct in_addr)); conf->dhcp.router.c = validate_stub; // Only type-based checking conf->dhcp.netmask.k = "dhcp.netmask"; conf->dhcp.netmask.h = "The netmask used by your Pi-hole. For directly connected networks (i.e., networks on which the machine running Pi-hole has an interface) the netmask is optional and may be set to an empty string (\"\"): it will then be determined from the interface configuration itself.\n\n For networks which receive DHCP service via a relay agent, we cannot determine the netmask itself, so it should explicitly be specified, otherwise Pi-hole guesses based on the class (A, B or C) of the network address.\n\n Example: \"255.255.255.0\""; conf->dhcp.netmask.a = cJSON_CreateStringReference("Any valid netmask, or an empty string (\"\") for auto-discovery"); conf->dhcp.netmask.t = CONF_STRUCT_IN_ADDR; conf->dhcp.netmask.f = FLAG_RESTART_FTL; memset(&conf->dhcp.netmask.d.in_addr, 0, sizeof(struct in_addr)); conf->dhcp.netmask.c = validate_netmask; conf->dhcp.leaseTime.k = "dhcp.leaseTime"; conf->dhcp.leaseTime.h = "If the lease time is given, then leases will be given for that length of time. If not given, the default lease time is one hour for IPv4 and one day for IPv6."; conf->dhcp.leaseTime.a = cJSON_CreateStringReference("The lease time can be in seconds, or minutes (e.g., \"45m\") or hours (e.g., \"1h\") or days (like \"2d\") or even weeks (\"1w\"). You may also use \"infinite\" as string but be aware of the drawbacks"); conf->dhcp.leaseTime.t = CONF_STRING; conf->dhcp.leaseTime.f = FLAG_RESTART_FTL; conf->dhcp.leaseTime.d.s = (char*)""; conf->dhcp.leaseTime.c = validate_str_no_newline; conf->dhcp.ipv6.k = "dhcp.ipv6"; conf->dhcp.ipv6.h = "Should Pi-hole make an attempt to also satisfy IPv6 address requests (be aware that IPv6 works a whole lot different than IPv4)"; conf->dhcp.ipv6.t = CONF_BOOL; conf->dhcp.ipv6.f = FLAG_RESTART_FTL; conf->dhcp.ipv6.d.b = false; conf->dhcp.ipv6.c = validate_stub; // Only type-based checking conf->dhcp.multiDNS.k = "dhcp.multiDNS"; conf->dhcp.multiDNS.h = "Advertise DNS server multiple times to clients. Some devices will add their own proprietary DNS servers to the list of DNS servers, which can cause issues with Pi-hole. This option will advertise the Pi-hole DNS server multiple times to clients, which should prevent this from happening."; conf->dhcp.multiDNS.t = CONF_BOOL; conf->dhcp.multiDNS.f = FLAG_RESTART_FTL; conf->dhcp.multiDNS.d.b = false; conf->dhcp.multiDNS.c = validate_stub; // Only type-based checking conf->dhcp.rapidCommit.k = "dhcp.rapidCommit"; conf->dhcp.rapidCommit.h = "Enable DHCPv4 Rapid Commit Option specified in RFC 4039. Should only be enabled if either the server is the only server for the subnet to avoid conflicts"; conf->dhcp.rapidCommit.t = CONF_BOOL; conf->dhcp.rapidCommit.f = FLAG_RESTART_FTL; conf->dhcp.rapidCommit.d.b = false; conf->dhcp.rapidCommit.c = validate_stub; // Only type-based checking conf->dhcp.logging.k = "dhcp.logging"; conf->dhcp.logging.h = "Enable logging for DHCP. This will log all relevant DHCP-related activity, including, e.g., all the options sent to DHCP clients and the tags used to determine them (if any). This can be useful for debugging DHCP issues. The generated output is saved to the file specified by files.log.dnsmasq below."; conf->dhcp.logging.t = CONF_BOOL; conf->dhcp.logging.f = FLAG_RESTART_FTL; conf->dhcp.logging.d.b = false; conf->dhcp.logging.c = validate_stub; // Only type-based checking conf->dhcp.ignoreUnknownClients.k = "dhcp.ignoreUnknownClients"; conf->dhcp.ignoreUnknownClients.h = "Ignore unknown DHCP clients.\n If this option is set, Pi-hole ignores all clients which are not explicitly configured through dhcp.hosts. This can be useful to prevent unauthorized clients from getting an IP address from the DHCP server.\n\n It should be noted that this option is not a security feature, as clients can still assign themselves an IP address and use the network. It is merely a convenience feature to prevent unknown clients from getting a valid IP configuration assigned automatically.\n\n Note that you will need to configure new clients manually in dhcp.hosts before they can use the network when this feature is enabled."; conf->dhcp.ignoreUnknownClients.t = CONF_BOOL; conf->dhcp.ignoreUnknownClients.f = FLAG_RESTART_FTL; conf->dhcp.ignoreUnknownClients.d.b = false; conf->dhcp.ignoreUnknownClients.c = validate_stub; // Only type-based checking conf->dhcp.hosts.k = "dhcp.hosts"; conf->dhcp.hosts.h = "Per host parameters for the DHCP server. This allows a machine with a particular hardware address to be always allocated the same hostname, IP address and lease time or to specify static DHCP leases\n\n Example: [ \"00:20:e0:3b:13:af,192.168.0.123,laptop,24h\", \"00:20:e0:ab:cd:ef,192.168.0.124,desktop,24h\"]"; conf->dhcp.hosts.a = cJSON_CreateStringReference("Array of static leases each one in the following form: \"[][,id:|*][,set:][,tag:][,][,][,][,ignore]\""); conf->dhcp.hosts.t = CONF_JSON_STRING_ARRAY; conf->dhcp.hosts.f = FLAG_RESTART_FTL; conf->dhcp.hosts.d.json = cJSON_CreateArray(); conf->dhcp.hosts.c = validate_array_no_newline; // struct ntp conf->ntp.ipv4.active.k = "ntp.ipv4.active"; conf->ntp.ipv4.active.h = "Should FTL act as network time protocol (NTP) server (IPv4)?"; conf->ntp.ipv4.active.t = CONF_BOOL; conf->ntp.ipv4.active.f = FLAG_RESTART_FTL; conf->ntp.ipv4.active.d.b = true; conf->ntp.ipv4.active.c = validate_stub; // Only type-based checking conf->ntp.ipv4.address.k = "ntp.ipv4.address"; conf->ntp.ipv4.address.h = "IPv4 address to listen on for NTP requests"; conf->ntp.ipv4.address.a = cJSON_CreateStringReference("A valid IPv4 address, or empty string (\"\"). For wildcard (0.0.0.0)"); conf->ntp.ipv4.address.t = CONF_STRUCT_IN_ADDR; conf->ntp.ipv4.address.f = FLAG_RESTART_FTL; memset(&conf->ntp.ipv4.address.d.in_addr, 0, sizeof(struct in_addr)); conf->ntp.ipv4.address.c = validate_stub; // Only type-based checking conf->ntp.ipv6.active.k = "ntp.ipv6.active"; conf->ntp.ipv6.active.h = "Should FTL act as network time protocol (NTP) server (IPv6)?"; conf->ntp.ipv6.active.t = CONF_BOOL; conf->ntp.ipv6.active.f = FLAG_RESTART_FTL; conf->ntp.ipv6.active.d.b = true; conf->ntp.ipv6.active.c = validate_stub; // Only type-based checking conf->ntp.ipv6.address.k = "ntp.ipv6.address"; conf->ntp.ipv6.address.h = "IPv6 address to listen on for NTP requests"; conf->ntp.ipv6.address.a = cJSON_CreateStringReference("A valid IPv6 address, or empty string (\"\"). For wildcard (::)"); conf->ntp.ipv6.address.t = CONF_STRUCT_IN6_ADDR; conf->ntp.ipv6.address.f = FLAG_RESTART_FTL; memset(&conf->ntp.ipv6.address.d.in6_addr, 0, sizeof(struct in6_addr)); conf->ntp.ipv6.address.c = validate_stub; // Only type-based checking conf->ntp.sync.active.k = "ntp.sync.active"; conf->ntp.sync.active.h = "Should FTL try to synchronize the system time with an upstream NTP server?"; conf->ntp.sync.active.t = CONF_BOOL; conf->ntp.sync.active.f = FLAG_RESTART_FTL; conf->ntp.sync.active.d.b = true; conf->ntp.sync.active.c = validate_stub; // Only type-based checking conf->ntp.sync.server.k = "ntp.sync.server"; conf->ntp.sync.server.h = "NTP upstream server to sync with, e.g., \"pool.ntp.org\". Note that the NTP server should be located as close as possible to you in order to minimize the time offset possibly introduced by different routing paths."; conf->ntp.sync.server.a = cJSON_CreateStringReference("A valid NTP upstream server"); conf->ntp.sync.server.t = CONF_STRING; conf->ntp.sync.server.d.s = (char*)"pool.ntp.org"; conf->ntp.sync.server.c = validate_dns_domain_or_ip; conf->ntp.sync.interval.k = "ntp.sync.interval"; conf->ntp.sync.interval.h = "Interval in seconds between successive synchronization attempts with the NTP server"; conf->ntp.sync.interval.a = cJSON_CreateStringReference("A positive integer value in seconds"); conf->ntp.sync.interval.t = CONF_UINT; conf->ntp.sync.interval.f = FLAG_RESTART_FTL; conf->ntp.sync.interval.d.ui = 3600; conf->ntp.sync.interval.c = validate_stub; // Only type-based checking conf->ntp.sync.count.k = "ntp.sync.count"; conf->ntp.sync.count.h = "Number of NTP syncs to perform and average before updating the system time"; conf->ntp.sync.count.a = cJSON_CreateStringReference("A positive integer value"); conf->ntp.sync.count.t = CONF_UINT; conf->ntp.sync.count.d.ui = 8; conf->ntp.sync.count.c = validate_ui_min_1; conf->ntp.sync.rtc.set.k = "ntp.sync.rtc.set"; conf->ntp.sync.rtc.set.h = "Should FTL update a real-time clock (RTC) if available?"; conf->ntp.sync.rtc.set.t = CONF_BOOL; conf->ntp.sync.rtc.set.d.b = false; conf->ntp.sync.rtc.set.c = validate_stub; // Only type-based checking conf->ntp.sync.rtc.device.k = "ntp.sync.rtc.device"; conf->ntp.sync.rtc.device.h = "Path to the RTC device to update.\n\n Example: \"/dev/rtc0\""; conf->ntp.sync.rtc.device.a = cJSON_CreateStringReference("A valid RTC device path, or empty string (\"\") for auto-discovery"); conf->ntp.sync.rtc.device.t = CONF_STRING; conf->ntp.sync.rtc.device.d.s = (char*)""; conf->ntp.sync.rtc.device.c = validate_stub; // Only type-based checking conf->ntp.sync.rtc.utc.k = "ntp.sync.rtc.utc"; conf->ntp.sync.rtc.utc.h = "Should the RTC be set to UTC?"; conf->ntp.sync.rtc.utc.t = CONF_BOOL; conf->ntp.sync.rtc.utc.d.b = true; conf->ntp.sync.rtc.utc.c = validate_stub; // Only type-based checking // struct resolver conf->resolver.resolveIPv6.k = "resolver.resolveIPv6"; conf->resolver.resolveIPv6.h = "Should FTL try to resolve IPv6 addresses to hostnames?"; conf->resolver.resolveIPv6.t = CONF_BOOL; conf->resolver.resolveIPv6.d.b = true; conf->resolver.resolveIPv6.c = validate_stub; // Only type-based checking conf->resolver.macNames.k = "resolver.macNames"; conf->resolver.macNames.h = "Control whether FTL should attempt to obtain client names from the network table by MAC address.\n\nThis can provide hostnames for devices that do not have a hostname or have multiple IP addresses (e.g. IPv4 and IPv6).\nHowever, MAC-derived names can be ambiguous (e.g., when a MAC appears for multiple IPs due to a router/NAT or MAC reuse), which may lead to incorrect hostnames being shown. Disabling this option can prevent such issues but may lead to more clients without hostnames."; conf->resolver.macNames.t = CONF_BOOL; conf->resolver.macNames.d.b = true; conf->resolver.macNames.c = validate_stub; // Only type-based checking conf->resolver.resolveIPv4.k = "resolver.resolveIPv4"; conf->resolver.resolveIPv4.h = "Should FTL try to resolve IPv4 addresses to hostnames?"; conf->resolver.resolveIPv4.t = CONF_BOOL; conf->resolver.resolveIPv4.d.b = true; conf->resolver.resolveIPv4.c = validate_stub; // Only type-based checking conf->resolver.networkNames.k = "resolver.networkNames"; conf->resolver.networkNames.h = "Control whether FTL should use the fallback option to try to obtain client names from checking the network table. This behavior can be disabled with this option.\n\n Assume an IPv6 client without a host names. However, the network table knows - though the client's MAC address - that this is the same device where we have a host name for another IP address (e.g., a DHCP server managed IPv4 address). In this case, we use the host name associated to the other address as this is the same device."; conf->resolver.networkNames.t = CONF_BOOL; conf->resolver.networkNames.d.b = true; conf->resolver.networkNames.c = validate_stub; // Only type-based checking conf->resolver.refreshNames.k = "resolver.refreshNames"; conf->resolver.refreshNames.h = "With this option, you can change how (and if) hourly PTR requests are made to check for changes in client and upstream server hostnames."; { struct enum_options refreshNames[] = { { get_refresh_hostnames_str(REFRESH_IPV4_ONLY), "Do hourly PTR lookups only for IPv4 addresses. This is the new default since Pi-hole FTL v5.3.2. It should resolve issues with more and more very short-lived PE IPv6 addresses coming up in a lot of networks." }, { get_refresh_hostnames_str(REFRESH_ALL), "Do hourly PTR lookups for all addresses. This was the default until FTL v5.3(.1). It has been replaced as it can create a lot of PTR queries for those with many IPv6 addresses in their networks." }, { get_refresh_hostnames_str(REFRESH_UNKNOWN), "Only resolve unknown hostnames. Already existing hostnames are never refreshed, i.e., there will be no PTR queries made for clients where hostnames are known. This also means that known hostnames will not be updated once known." }, { get_refresh_hostnames_str(REFRESH_NONE), "Don't do any hourly PTR lookups. This means we look host names up exactly once (when we first see a client) and never again. You may miss future changes of host names." } }; CONFIG_ADD_ENUM_OPTIONS(conf->resolver.refreshNames.a, refreshNames); } conf->resolver.refreshNames.t = CONF_ENUM_REFRESH_HOSTNAMES; conf->resolver.refreshNames.d.refresh_hostnames = REFRESH_IPV4_ONLY; conf->resolver.refreshNames.c = validate_stub; // Only type-based checking // struct database conf->database.DBimport.k = "database.DBimport"; conf->database.DBimport.h = "Should FTL load information from the database on startup to be aware of the most recent history?"; conf->database.DBimport.t = CONF_BOOL; conf->database.DBimport.d.b = true; conf->database.DBimport.c = validate_stub; // Only type-based checking conf->database.maxDBdays.k = "database.maxDBdays"; conf->database.maxDBdays.h = "How long should queries be stored in the database [days]?"; conf->database.maxDBdays.a = cJSON_CreateStringReference("A positive integer value in days, or 0 to disable the database"); // Unsigned: every reader takes .v.ui - database-thread.c, query-table.c // and common.c - and the help text above promises a positive value. As // CONF_INT the two disagreed, and a -1 stored through .v.i came back out // of .v.ui as 4294967295 conf->database.maxDBdays.t = CONF_UINT; conf->database.maxDBdays.d.ui = (365/4); conf->database.maxDBdays.c = validate_stub; // Only type-based checking conf->database.DBinterval.k = "database.DBinterval"; conf->database.DBinterval.h = "How often do we store queries in FTL's database [seconds]?"; conf->database.DBinterval.a = cJSON_CreateStringReference("A positive integer value in seconds"); conf->database.DBinterval.t = CONF_UINT; conf->database.DBinterval.d.ui = 60; // Used as a divisor by the database thread conf->database.DBinterval.c = validate_ui_min_1; conf->database.useWAL.k = "database.useWAL"; conf->database.useWAL.h = "Should FTL enable Write-Ahead Log (WAL) mode for the on-disk query database (configured via files.database)?\n\n It is recommended to leave this setting enabled for performance reasons. About the only reason to disable WAL mode is if you are experiencing specific issues with it, e.g., when using a database that is accessed from multiple hosts via a network share. When this setting is disabled, FTL will use SQLite3's default journal mode (rollback journal in DELETE mode)."; conf->database.useWAL.t = CONF_BOOL; // Note: We would not necessarily need to restart FTL when this setting // is changed, but we do it anyway as this ensures the database is // properly re-initialized and the new journal mode is used. As this is // a setting that will be changed very rarely, this seems the better // compromise than adding special code that can transform the database // while being active. // The in-memory database is not affected by this setting as it uses a // MEMORY journal mode anyway (there is nothing to be restored after power // loss). The gravity database is also not affected as it is only written // to on an individual basis (explicit API calls) and not continuously // (like the query database). conf->database.useWAL.f = FLAG_RESTART_FTL; conf->database.useWAL.d.b = true; conf->database.useWAL.c = validate_stub; // Only type-based checking conf->database.forceDisk.k = "database.forceDisk"; conf->database.forceDisk.h = "Should FTL force the use of disk storage for the history database? By default, FTL uses an in-memory database for much improved performance when browsing the history from the dashboard. However, on systems with very limited RAM and only occasional usage of the web interface, it may be useful to force the use of disk storage instead of holding everything in memory.\n\n Note that using disk storage *will* reduce performance, especially on systems with slow storage media (e.g., SD cards)."; conf->database.forceDisk.t = CONF_BOOL; conf->database.forceDisk.f = FLAG_RESTART_FTL; conf->database.forceDisk.d.b = false; conf->database.forceDisk.c = validate_stub; // Only type-based checking // sub-struct database.network conf->database.network.parseARPcache.k = "database.network.parseARPcache"; conf->database.network.parseARPcache.h = "Should FTL analyze the local ARP cache? When disabled, client identification and the network table will stop working reliably."; conf->database.network.parseARPcache.t = CONF_BOOL; conf->database.network.parseARPcache.d.b = true; conf->database.network.parseARPcache.c = validate_stub; // Only type-based checking conf->database.network.expire.k = "database.network.expire"; conf->database.network.expire.h = "How long should IP addresses be kept in the network_addresses table [days]? IP addresses (and associated host names) older than the specified number of days are removed to avoid dead entries in the network overview table."; conf->database.network.expire.a = cJSON_CreateStringReference("A positive integer value in days"); conf->database.network.expire.t = CONF_UINT; conf->database.network.expire.d.ui = conf->database.maxDBdays.d.ui; conf->database.network.expire.c = validate_stub; // Only type-based checking // struct webserver conf->webserver.domain.k = "webserver.domain"; conf->webserver.domain.h = "On which domain is the web interface served?"; conf->webserver.domain.a = cJSON_CreateStringReference("A valid domain"); conf->webserver.domain.t = CONF_STRING; conf->webserver.domain.f = FLAG_RESTART_FTL; conf->webserver.domain.d.s = (char*)"pi.hole"; conf->webserver.domain.c = validate_domain; conf->webserver.acl.k = "webserver.acl"; conf->webserver.acl.h = "Webserver access control list (ACL) allowing for restrictions to be put on the list of IP addresses which have access to the web server. The ACL is a comma separated list of IP subnets, where each subnet is prepended by either a - or a + sign. A plus sign means allow, where a minus sign means deny.\n\n If a subnet mask is omitted, such as -1.2.3.4, this means to deny only that single IP address. If this value is not set (empty string), all accesses are allowed. Otherwise, the default setting is to deny all accesses. On each request the full list is traversed, and the last (!) match wins. IPv6 addresses may be specified in CIDR-form [a:b::c]/64.\n\n Example 1: \"+127.0.0.1,+[::1]\" ---> deny all access, except from 127.0.0.1 and ::1\n\n Example 2: \"+192.168.0.0/16\" ---> deny all accesses, except from the 192.168.0.0/16 subnet\n\n Example 3: \"+[::]/0\" ---> allow only IPv6 access."; conf->webserver.acl.a = cJSON_CreateStringReference("A valid ACL"); conf->webserver.acl.f = FLAG_RESTART_FTL; conf->webserver.acl.t = CONF_STRING; conf->webserver.acl.d.s = (char*)""; conf->webserver.acl.c = validate_stub; // Type-based checking + civetweb syntax checking conf->webserver.port.k = "webserver.port"; conf->webserver.port.h = "Ports to be used by the webserver.\n\n Comma-separated list of ports to listen on. It is possible to specify an IP address to bind to. In this case, an IP address and a colon must be prepended to the port number. For example, to bind to the loopback interface on port 80 (IPv4) and to all interfaces port 8080 (IPv4), use \"127.0.0.1:80,8080\". \"[::]:80\" can be used to listen to IPv6 connections to port 80. IPv6 addresses of network interfaces can be specified as well, e.g. \"[::1]:80\" for the IPv6 loopback interface. \"[::]:80\" will bind to port 80 IPv6 only.\n\n In order to use port 80 for all interfaces, both IPv4 and IPv6, use either the configuration \"80,[::]:80\" (create one socket for IPv4 and one for IPv6 only), or \"+80\" (create one socket for both, IPv4 and IPv6). The '+' notation to use IPv4 and IPv6 will only work if no network interface is specified. Depending on your operating system version and IPv6 network environment, some configurations might not work as expected, so you have to test to find the configuration most suitable for your needs. In case \"+80\" does not work for your environment, you need to use \"80,[::]:80\".\n\n If the port is TLS/SSL, a letter 's' (secure) must be appended, for example, \"80,443s\" will open port 80 and port 443, and connections on port 443 will be encrypted. For non-encrypted ports, it is allowed to append letter 'r' (as in redirect). Redirected ports will redirect all their traffic to the first configured SSL port. For example, if webserver.port is \"80r,443s\", then all HTTP traffic coming at port 80 will be redirected to HTTPS port 443.\n\n When specifying 'o' (optional) behind a port, inability to use this port is not considered an error. For instance, specifying \"80o,8080o\" will allow the webserver to listen on either 80, 8080, both or even none of the two ports. This flag may be combined with 'r' and 's' like \"80or,443os,8080,4443s\" (80 redirecting to SSL if available, 443 encrypted if available, 8080 mandatory and unencrypted, 4443 mandatory and encrypted).\n\n If this value is not set (empty string), the web server will not be started and, hence, the API will not be available."; conf->webserver.port.a = cJSON_CreateStringReference("A comma-separated list of <[ip_address:]port>"); conf->webserver.port.f = FLAG_RESTART_FTL; conf->webserver.port.t = CONF_STRING; conf->webserver.port.d.s = (char*)"80o,443os,[::]:80o,[::]:443os"; conf->webserver.port.c = validate_stub; // Type-based checking + civetweb syntax checking conf->webserver.threads.k = "webserver.threads"; conf->webserver.threads.h = "Maximum number of worker threads allowed.\n\n The Pi-hole web server handles each incoming connection in a separate thread. Therefore, the value of this option is effectively the number of concurrent HTTP connections that can be handled. Any other connections are queued until they can be processed by a unoccupied thread.\n\n The total number of threads you see may be lower than the configured value as threads are only created when needed due to incoming connections.\n\n The value 0 means the number of threads is 50 (as per default settings of CivetWeb) for backwards-compatible behavior."; conf->webserver.threads.a = cJSON_CreateStringReference("A positive integer value, or 0 for default (50)"); conf->webserver.threads.t = CONF_UINT; conf->webserver.threads.f = FLAG_RESTART_FTL; conf->webserver.threads.d.ui = 50; conf->webserver.threads.c = validate_stub; // Only type-based checking conf->webserver.headers.k = "webserver.headers"; conf->webserver.headers.h = "Additional HTTP headers added to the web server responses.\n\n The headers are added to all responses, including those for the API.\n Note about the default additional headers:\n - X-DNS-Prefetch-Control: off: Usually browsers proactively perform domain name resolution on links that the user may choose to follow. We disable DNS prefetching here.\n - Content-Security-Policy: [...] 'unsafe-inline' is both required by Chart.js styling some elements directly, and index.html containing some inlined Javascript code.\n - X-Frame-Options: DENY: The page can not be displayed in a frame, regardless of the site attempting to do so.\n - X-Xss-Protection: 0: Disables XSS filtering in browsers that support it. This header is usually enabled by default in browsers, and is not recommended as it can hurt the security of the site. (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection).\n - X-Content-Type-Options: nosniff: Marker used by the server to indicate that the MIME types advertised in the Content-Type headers should not be changed and be followed. This allows to opt-out of MIME type sniffing, or, in other words, it is a way to say that the webmasters knew what they were doing. Site security testers usually expect this header to be set.\n - Referrer-Policy: strict-origin-when-cross-origin: A referrer will be sent for same-site origins, but cross-origin requests will send no referrer information.\n The latter four headers are set as expected by https://securityheaders.io"; conf->webserver.headers.a = cJSON_CreateStringReference("An array of HTTP headers"); conf->webserver.headers.t = CONF_JSON_STRING_ARRAY; conf->webserver.headers.f = FLAG_RESTART_FTL; conf->webserver.headers.d.json = cJSON_CreateArray(); cJSON_AddItemToArray(conf->webserver.headers.d.json, cJSON_CreateStringReference("X-DNS-Prefetch-Control: off")); cJSON_AddItemToArray(conf->webserver.headers.d.json, cJSON_CreateStringReference("Content-Security-Policy: default-src 'none'; connect-src 'self'; font-src 'self'; frame-ancestors 'none'; img-src 'self'; manifest-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; form-action 'self'")); cJSON_AddItemToArray(conf->webserver.headers.d.json, cJSON_CreateStringReference("X-Frame-Options: DENY")); cJSON_AddItemToArray(conf->webserver.headers.d.json, cJSON_CreateStringReference("X-XSS-Protection: 0")); cJSON_AddItemToArray(conf->webserver.headers.d.json, cJSON_CreateStringReference("X-Content-Type-Options: nosniff")); cJSON_AddItemToArray(conf->webserver.headers.d.json, cJSON_CreateStringReference("Referrer-Policy: strict-origin-when-cross-origin")); conf->webserver.headers.c = validate_stub; // Only type-based checking conf->webserver.serve_all.k = "webserver.serve_all"; conf->webserver.serve_all.h = "Should the web server serve all files in webserver.paths.webroot directory?\n\n If disabled, only files within the path defined through webserver.paths.webhome and /api will be served."; conf->webserver.serve_all.t = CONF_BOOL; conf->webserver.serve_all.d.b = false; conf->webserver.serve_all.c = validate_stub; conf->webserver.advancedOpts.k = "webserver.advancedOpts"; conf->webserver.advancedOpts.h = "Additional options passed directly to the web server.\n\n This can be used to set any option supported by the underlying web server (CivetWeb). The options are passed as an array of strings, where each string is an option in the form \"