From 78a09dfa9d648cf9fb41c3cb647bd5fa497dbda0 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 5 Feb 2023 12:24:42 +0100 Subject: [PATCH] Make a few more config values camelCase Signed-off-by: DL6ER --- src/api/config.c | 4 +- src/api/docs/content/specs/config.yaml | 24 ++--- src/api/history.c | 8 +- src/api/stats.c | 12 +-- src/config/cli.c | 2 +- src/config/config.c | 129 ++++++++++++------------- src/config/config.h | 16 +-- src/config/dnsmasq_config.c | 28 +++--- src/dnsmasq/rfc2131.c | 16 +-- src/setupVars.c | 18 ++-- test/pihole.toml | 14 +-- 11 files changed, 134 insertions(+), 137 deletions(-) diff --git a/src/api/config.c b/src/api/config.c index 3141e39c..377b0812 100644 --- a/src/api/config.c +++ b/src/api/config.c @@ -482,7 +482,7 @@ static int api_config_get(struct ftl_conn *api) continue; } JSON_ADD_ITEM_TO_OBJECT(leaf, "default", dval); - const bool modified = memcmp(&conf_item->v, &conf_item->d, sizeof(union conf_value)) != 0; + const bool modified = !compare_config_item(conf_item->t, &conf_item->v, &conf_item->d); JSON_ADD_BOOL_TO_OBJECT(leaf, "modified", modified); // Add config item flags @@ -623,7 +623,7 @@ static int api_config_patch(struct ftl_conn *api) struct conf_item *conf_item = get_conf_item(&config, i); // Skip processing if value didn't change compared to current value - if(compare_config_item(new_item, conf_item)) + if(compare_config_item(conf_item->t, &new_item->v, &conf_item->v)) { log_debug(DEBUG_CONFIG, "Config item %s: Unchanged", conf_item->k); continue; diff --git a/src/api/docs/content/specs/config.yaml b/src/api/docs/content/specs/config.yaml index a836218b..f2d42cdf 100644 --- a/src/api/docs/content/specs/config.yaml +++ b/src/api/docs/content/specs/config.yaml @@ -200,7 +200,7 @@ components: type: string cacheSize: type: integer - query_logging: + queryLogging: type: boolean cnames: type: array @@ -208,7 +208,7 @@ components: type: string port: type: integer - rev_server: + revServer: type: object properties: active: @@ -276,11 +276,11 @@ components: type: string router: type: string - leasetime: + leaseTime: type: string ipv6: type: boolean - rapid_commit: + rapidCommit: type: boolean hosts: type: array @@ -351,11 +351,11 @@ components: type: boolean pwhash: type: string - exclude_clients: + excludeClients: type: array items: type: string - exclude_domains: + excludeDomains: type: array items: type: string @@ -529,12 +529,12 @@ components: hostRecord: "" listeningMode: "local" cacheSize: 10000 - query_logging: true + queryLogging: true cnames: - "*.example.com,default.example.com" - "hourly.yetanother.com,yetanother.com,3600" port: 53 - rev_server: + revServer: active: false cidr: "192.168.0.0/24" target: "192.168.0.1" @@ -564,9 +564,9 @@ components: start: "192.168.0.10" end: "192.168.0.250" router: "192.168.0.1" - leasetime: "24h" + leaseTime: "24h" ipv6: true - rapid_commit: true + rapidCommit: true hosts: - "11:22:33:44:55:66,192.168.1.123" - "11:22:33:44:55:67,192.168.1.124,hostname" @@ -599,8 +599,8 @@ components: localAPIauth: false prettyJSON: false pwhash: '' - exclude_clients: [ '1.2.3.4', 'localhost', 'fe80::345' ] - exclude_domains: [ 'google.de', 'pi-hole.net' ] + excludeClients: [ '1.2.3.4', 'localhost', 'fe80::345' ] + excludeDomains: [ 'google.de', 'pi-hole.net' ] temp: limit: 60.0 unit: "C" diff --git a/src/api/history.c b/src/api/history.c index 1e74d582..32a54c65 100644 --- a/src/api/history.c +++ b/src/api/history.c @@ -126,8 +126,8 @@ int api_history_clients(struct ftl_conn *api) // returned data. We initialize it with false bool *skipclient = calloc(counters->clients, sizeof(bool)); - unsigned int exclude_clients = cJSON_GetArraySize(config.webserver.api.exclude_clients.v.json); - if(exclude_clients > 0) + unsigned int excludeClients = cJSON_GetArraySize(config.webserver.api.excludeClients.v.json); + if(excludeClients > 0) { for(int clientID = 0; clientID < counters->clients; clientID++) { @@ -136,9 +136,9 @@ int api_history_clients(struct ftl_conn *api) if(client == NULL) continue; // Check if this client should be skipped - for(unsigned int i = 0; i < exclude_clients; i++) + for(unsigned int i = 0; i < excludeClients; i++) { - cJSON *item = cJSON_GetArrayItem(config.webserver.api.exclude_clients.v.json, i); + cJSON *item = cJSON_GetArrayItem(config.webserver.api.excludeClients.v.json, i); if(strcmp(getstr(client->ippos), item->valuestring) == 0 || strcmp(getstr(client->namepos), item->valuestring) == 0) skipclient[clientID] = true; diff --git a/src/api/stats.c b/src/api/stats.c index 6094155a..c4b1302d 100644 --- a/src/api/stats.c +++ b/src/api/stats.c @@ -199,7 +199,7 @@ int api_stats_top_domains(struct ftl_conn *api) clearSetupVarsArray(); // Get domains which the user doesn't want to see - unsigned int exclude_domains = cJSON_GetArraySize(config.webserver.api.exclude_domains.v.json); + unsigned int excludeDomains = cJSON_GetArraySize(config.webserver.api.excludeDomains.v.json); int n = 0; cJSON *top_domains = JSON_NEW_ARRAY(); @@ -217,9 +217,9 @@ int api_stats_top_domains(struct ftl_conn *api) { // Check if this client should be skipped bool skip_domain = false; - for(unsigned int j = 0; j < exclude_domains; j++) + for(unsigned int j = 0; j < excludeDomains; j++) { - cJSON *item = cJSON_GetArrayItem(config.webserver.api.exclude_domains.v.json, j); + cJSON *item = cJSON_GetArrayItem(config.webserver.api.excludeDomains.v.json, j); if(strcmp(getstr(domain->domainpos), item->valuestring) == 0) { skip_domain = true; @@ -337,7 +337,7 @@ int api_stats_top_clients(struct ftl_conn *api) qsort(temparray, counters->clients, sizeof(int[2]), cmpdesc); // Get clients which the user doesn't want to see - unsigned int exclude_clients = cJSON_GetArraySize(config.webserver.api.exclude_clients.v.json); + unsigned int excludeClients = cJSON_GetArraySize(config.webserver.api.excludeClients.v.json); int n = 0; cJSON *top_clients = JSON_NEW_ARRAY(); @@ -353,9 +353,9 @@ int api_stats_top_clients(struct ftl_conn *api) // Skip this client if there is a filter on it bool skip_domain = false; - for(unsigned int j = 0; j < exclude_clients; j++) + for(unsigned int j = 0; j < excludeClients; j++) { - cJSON *item = cJSON_GetArrayItem(config.webserver.api.exclude_clients.v.json, j); + cJSON *item = cJSON_GetArrayItem(config.webserver.api.excludeClients.v.json, j); if(strcmp(getstr(client->ippos), item->valuestring) == 0 || strcmp(getstr(client->namepos), item->valuestring) == 0) { diff --git a/src/config/cli.c b/src/config/cli.c index 5bdf9eaa..3eecf980 100644 --- a/src/config/cli.c +++ b/src/config/cli.c @@ -325,7 +325,7 @@ bool set_config_from_CLI(const char *key, const char *value) return false; // Check if value changed compared to current value - if(!compare_config_item(new_item, conf_item)) + if(!compare_config_item(conf_item->t, &new_item->v, &conf_item->v)) { // Config item changed diff --git a/src/config/config.c b/src/config/config.c index 99582809..289364d9 100644 --- a/src/config/config.c +++ b/src/config/config.c @@ -223,13 +223,10 @@ void duplicate_config(struct config *dst, struct config *src) } // True = Identical, False = Different -bool compare_config_item(const struct conf_item *conf_item1, const struct conf_item *conf_item2) +bool compare_config_item(const enum conf_type t, const union conf_value *val1, const union conf_value *val2) { - if(conf_item1->t != conf_item2->t) - return false; - // Make a type-dependent copy of the value - switch(conf_item1->t) + switch(t) { case CONF_BOOL: case CONF_INT: @@ -248,14 +245,14 @@ bool compare_config_item(const struct conf_item *conf_item1, const struct conf_i case CONF_STRUCT_IN_ADDR: case CONF_STRUCT_IN6_ADDR: // Compare entire union - return memcmp(&conf_item1->v, &conf_item2->v, sizeof(conf_item1->v)) == 0; + return memcmp(val1, val2, sizeof(*val1)) == 0; case CONF_STRING: case CONF_STRING_ALLOCATED: // Compare strings - return strcmp(conf_item1->v.s, conf_item2->v.s) == 0; + return strcmp(val1->s, val2->s) == 0; case CONF_JSON_STRING_ARRAY: // Compare JSON object/array - return cJSON_Compare(conf_item1->v.json, conf_item2->v.json, true); + return cJSON_Compare(val1->json, val2->json, true); } return false; } @@ -461,27 +458,27 @@ void initConfig(struct config *conf) CONFIG_ADD_ENUM_OPTIONS(conf->dns.listeningMode.a, listeningMode); } conf->dns.listeningMode.t = CONF_ENUM_LISTENING_MODE; - conf->dns.listeningMode.f = FLAG_RESTART_DNSMASQ; + conf->dns.listeningMode.f = FLAG_RESTART_DNSMASQ | FLAG_ADVANCED_SETTING; conf->dns.listeningMode.d.listeningMode = LISTEN_LOCAL; conf->dns.cacheSize.k = "dns.cacheSize"; conf->dns.cacheSize.h = "Cache size of the DNS server. Note that expiring cache entries naturally make room for new insertions over time. Setting 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.cacheSize.t = CONF_UINT; - conf->dns.cacheSize.f = FLAG_RESTART_DNSMASQ; + conf->dns.cacheSize.f = FLAG_RESTART_DNSMASQ | FLAG_ADVANCED_SETTING; conf->dns.cacheSize.d.ui = 2000u; - conf->dns.query_logging.k = "dns.query_logging"; - conf->dns.query_logging.h = "Log DNS queries and replies to pihole.log"; - conf->dns.query_logging.t = CONF_BOOL; - conf->dns.query_logging.f = FLAG_RESTART_DNSMASQ; - conf->dns.query_logging.d.b = true; + 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_DNSMASQ; + conf->dns.queryLogging.d.b = true; - conf->dns.cnames.k = "dns.cnames"; - conf->dns.cnames.h = "List of CNAME records which indicate that is really . If the is given, it overwrites the value of local-ttl"; - conf->dns.cnames.a = cJSON_CreateStringReference("Array of static leases each on in one of the following forms: \",[,]\""); - conf->dns.cnames.t = CONF_JSON_STRING_ARRAY; - conf->dns.cnames.f = FLAG_RESTART_DNSMASQ | FLAG_ADVANCED_SETTING; - conf->dns.cnames.d.json = cJSON_CreateArray(); + 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 static leases each on in one of the following forms: \",[,]\""); + conf->dns.cnameRecords.t = CONF_JSON_STRING_ARRAY; + conf->dns.cnameRecords.f = FLAG_RESTART_DNSMASQ | FLAG_ADVANCED_SETTING; + conf->dns.cnameRecords.d.json = cJSON_CreateArray(); conf->dns.port.k = "dns.port"; conf->dns.port.h = "Port used by the DNS server"; @@ -586,33 +583,33 @@ void initConfig(struct config *conf) conf->dns.reply.blocking.v6.f = FLAG_ADVANCED_SETTING; memset(&conf->dns.reply.blocking.v6.d.in6_addr, 0, sizeof(struct in6_addr)); - // sub-struct rev_server - conf->dns.rev_server.active.k = "dns.rev_server.active"; - conf->dns.rev_server.active.h = "Is the reverse server (former also called \"conditional forwarding\") feature enabled?"; - conf->dns.rev_server.active.t = CONF_BOOL; - conf->dns.rev_server.active.d.b = false; - conf->dns.rev_server.active.f = FLAG_RESTART_DNSMASQ; + // sub-struct revServer + conf->dns.revServer.active.k = "dns.revServer.active"; + conf->dns.revServer.active.h = "Is the reverse server (former also called \"conditional forwarding\") feature enabled?"; + conf->dns.revServer.active.t = CONF_BOOL; + conf->dns.revServer.active.d.b = false; + conf->dns.revServer.active.f = FLAG_RESTART_DNSMASQ; - conf->dns.rev_server.cidr.k = "dns.rev_server.cidr"; - conf->dns.rev_server.cidr.h = "Address range for the reverse server feature in CIDR notation. If the prefix length is omitted, either 32 (IPv4) or 128 (IPv6) are substitutet (exact address match). This is almost certainly not what you want here."; - conf->dns.rev_server.cidr.a = cJSON_CreateStringReference("[/], e.g., \"192.168.0.0/24\" for the range 192.168.0.1 - 192.168.0.255"); - conf->dns.rev_server.cidr.t = CONF_STRING; - conf->dns.rev_server.cidr.d.s = (char*)""; - conf->dns.rev_server.cidr.f = FLAG_RESTART_DNSMASQ; + conf->dns.revServer.cidr.k = "dns.revServer.cidr"; + conf->dns.revServer.cidr.h = "Address range for the reverse server feature in CIDR notation. If the prefix length is omitted, either 32 (IPv4) or 128 (IPv6) are substitutet (exact address match). This is almost certainly not what you want here."; + conf->dns.revServer.cidr.a = cJSON_CreateStringReference("[/], e.g., \"192.168.0.0/24\" for the range 192.168.0.1 - 192.168.0.255"); + conf->dns.revServer.cidr.t = CONF_STRING; + conf->dns.revServer.cidr.d.s = (char*)""; + conf->dns.revServer.cidr.f = FLAG_RESTART_DNSMASQ; - conf->dns.rev_server.target.k = "dns.rev_server.target"; - conf->dns.rev_server.target.h = "Target server tp be used for the reverse server feature"; - conf->dns.rev_server.target.a = cJSON_CreateStringReference("[#], e.g., \"192.168.0.1\""); - conf->dns.rev_server.target.t = CONF_STRING; - conf->dns.rev_server.target.d.s = (char*)""; - conf->dns.rev_server.target.f = FLAG_RESTART_DNSMASQ; + conf->dns.revServer.target.k = "dns.revServer.target"; + conf->dns.revServer.target.h = "Target server tp be used for the reverse server feature"; + conf->dns.revServer.target.a = cJSON_CreateStringReference("[#], e.g., \"192.168.0.1\""); + conf->dns.revServer.target.t = CONF_STRING; + conf->dns.revServer.target.d.s = (char*)""; + conf->dns.revServer.target.f = FLAG_RESTART_DNSMASQ; - conf->dns.rev_server.domain.k = "dns.rev_server.domain"; - conf->dns.rev_server.domain.h = "Domain used for the reverse server feature"; - conf->dns.rev_server.domain.a = cJSON_CreateStringReference(", typically set to the same value as dns.domain"); - conf->dns.rev_server.domain.t = CONF_STRING; - conf->dns.rev_server.domain.d.s = (char*)""; - conf->dns.rev_server.domain.f = FLAG_RESTART_DNSMASQ; + conf->dns.revServer.domain.k = "dns.revServer.domain"; + conf->dns.revServer.domain.h = "Domain used for the reverse server feature"; + conf->dns.revServer.domain.a = cJSON_CreateStringReference(", typically set to the same value as dns.domain"); + conf->dns.revServer.domain.t = CONF_STRING; + conf->dns.revServer.domain.d.s = (char*)""; + conf->dns.revServer.domain.f = FLAG_RESTART_DNSMASQ; // sub-struct dhcp conf->dhcp.active.k = "dhcp.active"; @@ -642,12 +639,12 @@ void initConfig(struct config *conf) conf->dhcp.router.f = FLAG_RESTART_DNSMASQ; conf->dhcp.router.d.s = (char*)""; - 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_DNSMASQ | FLAG_ADVANCED_SETTING; - conf->dhcp.leasetime.d.s = (char*)""; + 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_DNSMASQ | FLAG_ADVANCED_SETTING; + conf->dhcp.leaseTime.d.s = (char*)""; 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)"; @@ -655,11 +652,11 @@ void initConfig(struct config *conf) conf->dhcp.ipv6.f = FLAG_RESTART_DNSMASQ; conf->dhcp.ipv6.d.b = false; - conf->dhcp.rapid_commit.k = "dhcp.rapid_commit"; - conf->dhcp.rapid_commit.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.rapid_commit.t = CONF_BOOL; - conf->dhcp.rapid_commit.f = FLAG_RESTART_DNSMASQ; - conf->dhcp.rapid_commit.d.b = false; + 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_DNSMASQ; + conf->dhcp.rapidCommit.d.b = false; 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"; @@ -823,17 +820,17 @@ void initConfig(struct config *conf) conf->webserver.api.pwhash.t = CONF_STRING; conf->webserver.api.pwhash.d.s = (char*)""; - conf->webserver.api.exclude_clients.k = "webserver.api.exclude_clients"; - conf->webserver.api.exclude_clients.h = "Array of clients to be excluded from certain API responses\n Example: [ \"192.168.2.56\", \"fe80::341\", \"localhost\" ]"; - conf->webserver.api.exclude_clients.a = cJSON_CreateStringReference("array of IP addresses and/or hostnames"); - conf->webserver.api.exclude_clients.t = CONF_JSON_STRING_ARRAY; - conf->webserver.api.exclude_clients.d.json = cJSON_CreateArray(); + conf->webserver.api.excludeClients.k = "webserver.api.excludeClients"; + conf->webserver.api.excludeClients.h = "Array of clients to be excluded from certain API responses\n Example: [ \"192.168.2.56\", \"fe80::341\", \"localhost\" ]"; + conf->webserver.api.excludeClients.a = cJSON_CreateStringReference("array of IP addresses and/or hostnames"); + conf->webserver.api.excludeClients.t = CONF_JSON_STRING_ARRAY; + conf->webserver.api.excludeClients.d.json = cJSON_CreateArray(); - conf->webserver.api.exclude_domains.k = "webserver.api.exclude_domains"; - conf->webserver.api.exclude_domains.h = "Array of domains to be excluded from certain API responses\n Example: [ \"google.de\", \"pi-hole.net\" ]"; - conf->webserver.api.exclude_domains.a = cJSON_CreateStringReference("array of IP addresses and/or hostnames"); - conf->webserver.api.exclude_domains.t = CONF_JSON_STRING_ARRAY; - conf->webserver.api.exclude_domains.d.json = cJSON_CreateArray(); + conf->webserver.api.excludeDomains.k = "webserver.api.excludeDomains"; + conf->webserver.api.excludeDomains.h = "Array of domains to be excluded from certain API responses\n Example: [ \"google.de\", \"pi-hole.net\" ]"; + conf->webserver.api.excludeDomains.a = cJSON_CreateStringReference("array of IP addresses and/or hostnames"); + conf->webserver.api.excludeDomains.t = CONF_JSON_STRING_ARRAY; + conf->webserver.api.excludeDomains.d.json = cJSON_CreateArray(); // sub-struct webserver.api.temp conf->webserver.api.temp.limit.k = "webserver.api.temp.limit"; diff --git a/src/config/config.h b/src/config/config.h index e0d168bd..db775260 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -120,8 +120,8 @@ struct config { struct conf_item hostRecord; struct conf_item listeningMode; struct conf_item cacheSize; - struct conf_item query_logging; - struct conf_item cnames; + struct conf_item queryLogging; + struct conf_item cnameRecords; struct conf_item port; struct { struct conf_item active; @@ -155,7 +155,7 @@ struct config { struct conf_item cidr; struct conf_item target; struct conf_item domain; - } rev_server; + } revServer; } dns; struct { @@ -163,9 +163,9 @@ struct config { struct conf_item start; struct conf_item end; struct conf_item router; - struct conf_item leasetime; + struct conf_item leaseTime; struct conf_item ipv6; - struct conf_item rapid_commit; + struct conf_item rapidCommit; struct conf_item hosts; } dhcp; @@ -205,8 +205,8 @@ struct config { struct conf_item localAPIauth; struct conf_item prettyJSON; struct conf_item pwhash; - struct conf_item exclude_clients; - struct conf_item exclude_domains; + struct conf_item excludeClients; + struct conf_item excludeDomains; struct { struct conf_item limit; struct conf_item unit; @@ -287,7 +287,7 @@ struct conf_item *get_debug_item(const enum debug_flag debug); unsigned int config_path_depth(char **paths) __attribute__ ((pure)); void duplicate_config(struct config *dst, struct config *src); void free_config(struct config *conf); -bool compare_config_item(const struct conf_item *conf_item1, const struct conf_item *conf_item2); +bool compare_config_item(const enum conf_type t, const union conf_value *val1, const union conf_value *val2); char **gen_config_path(const char *pathin, const char delim); void free_config_path(char **paths); bool check_paths_equal(char **paths1, char **paths2, unsigned int max_level) __attribute__ ((pure)); diff --git a/src/config/dnsmasq_config.c b/src/config/dnsmasq_config.c index 64f9d53e..e11f1c17 100644 --- a/src/config/dnsmasq_config.c +++ b/src/config/dnsmasq_config.c @@ -266,7 +266,7 @@ bool __attribute__((const)) write_dnsmasq_config(struct config *conf, bool test_ fputs("localise-queries\n", pihole_conf); fputs("\n", pihole_conf); - if(conf->dns.query_logging.v.b) + if(conf->dns.queryLogging.v.b) { fputs("# Enable query logging\n", pihole_conf); fputs("log-queries\n", pihole_conf); @@ -377,23 +377,23 @@ bool __attribute__((const)) write_dnsmasq_config(struct config *conf, bool test_ } fputs("\n", pihole_conf); - if(conf->dns.rev_server.active.v.b) + if(conf->dns.revServer.active.v.b) { fputs("# Reverse server setting\n", pihole_conf); fprintf(pihole_conf, "rev-server=%s,%s\n", - conf->dns.rev_server.cidr.v.s, conf->dns.rev_server.target.v.s); + conf->dns.revServer.cidr.v.s, conf->dns.revServer.target.v.s); // If we have a reverse domain, we forward all queries to this domain to // the same destination - if(strlen(conf->dns.rev_server.domain.v.s) > 0) + if(strlen(conf->dns.revServer.domain.v.s) > 0) fprintf(pihole_conf, "server=/%s/%s\n", - conf->dns.rev_server.domain.v.s, conf->dns.rev_server.target.v.s); + conf->dns.revServer.domain.v.s, conf->dns.revServer.target.v.s); // Forward unqualified names to the target only when the "never forward // non-FQDN" option is NOT ticked if(!conf->dns.domainNeeded.v.b) fprintf(pihole_conf, "server=//%s\n", - conf->dns.rev_server.target.v.s); + conf->dns.revServer.target.v.s); fputs("\n", pihole_conf); } @@ -405,11 +405,11 @@ bool __attribute__((const)) write_dnsmasq_config(struct config *conf, bool test_ fprintf(pihole_conf, "dhcp-range=%s,%s,%s\n", conf->dhcp.start.v.s, conf->dhcp.end.v.s, - conf->dhcp.leasetime.v.s); + conf->dhcp.leaseTime.v.s); fprintf(pihole_conf, "dhcp-option=option:router,%s\n", conf->dhcp.router.v.s); - if(conf->dhcp.rapid_commit.v.b) + if(conf->dhcp.rapidCommit.v.b) fputs("dhcp-rapid-commit\n", pihole_conf); if(conf->dhcp.ipv6.v.b) @@ -432,13 +432,13 @@ bool __attribute__((const)) write_dnsmasq_config(struct config *conf, bool test_ } } - if(cJSON_GetArraySize(conf->dns.cnames.v.json) > 0) + if(cJSON_GetArraySize(conf->dns.cnameRecords.v.json) > 0) { fputs("# User-defined custom CNAMEs\n", pihole_conf); - const int n = cJSON_GetArraySize(conf->dns.cnames.v.json); + const int n = cJSON_GetArraySize(conf->dns.cnameRecords.v.json); for(int i = 0; i < n; i++) { - cJSON *server = cJSON_GetArrayItem(conf->dns.cnames.v.json, i); + cJSON *server = cJSON_GetArrayItem(conf->dns.cnameRecords.v.json, i); if(server != NULL && cJSON_IsString(server)) fprintf(pihole_conf, "cname=%s\n", server->valuestring); } @@ -616,12 +616,12 @@ bool read_legacy_cnames_config(void) // modifies the string inplace trim_whitespace(value); - // Add entry to config.dns.cnames + // Add entry to config.dns.cnameRecords cJSON *item = cJSON_CreateString(value); - cJSON_AddItemToArray(config.dns.cnames.v.json, item); + cJSON_AddItemToArray(config.dns.cnameRecords.v.json, item); log_debug(DEBUG_CONFIG, DNSMASQ_CNAMES": Setting %s[%u] = %s\n", - config.dns.cnames.k, j++, item->valuestring); + config.dns.cnameRecords.k, j++, item->valuestring); } // Free allocated memory diff --git a/src/dnsmasq/rfc2131.c b/src/dnsmasq/rfc2131.c index 17e97b52..782f99ac 100644 --- a/src/dnsmasq/rfc2131.c +++ b/src/dnsmasq/rfc2131.c @@ -77,7 +77,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, struct dhcp_vendor *vendor; struct dhcp_mac *mac; struct dhcp_netid_list *id_list; - int clid_len = 0, ignore = 0, do_classes = 0, rapid_commit = 0, selecting = 0, pxearch = -1; + int clid_len = 0, ignore = 0, do_classes = 0, rapidCommit = 0, selecting = 0, pxearch = -1; const char *pxevendor = NULL; struct dhcp_packet *mess = (struct dhcp_packet *)daemon->dhcp_packet.iov_base; unsigned char *end = (unsigned char *)(mess + 1); @@ -1157,14 +1157,14 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, if (option_bool(OPT_RAPID_COMMIT) && option_find(mess, sz, OPTION_RAPID_COMMIT, 0)) { - rapid_commit = 1; + rapidCommit = 1; /* If a lease exists for this host and another address, squash it. */ if (lease && lease->addr.s_addr != mess->yiaddr.s_addr) { lease_prune(lease, now); lease = NULL; } - goto rapid_commit; + goto rapidCommit; } log_tags(tagif_netid, ntohl(mess->xid)); @@ -1285,7 +1285,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, daemon->metrics[METRIC_DHCPREQUEST]++; log_packet("DHCPREQUEST", &mess->yiaddr, emac, emac_len, iface_name, NULL, NULL, mess->xid); - rapid_commit: + rapidCommit: if (!message) { struct dhcp_config *addr_config; @@ -1357,11 +1357,11 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, if (message) { - daemon->metrics[rapid_commit ? METRIC_NOANSWER : METRIC_DHCPNAK]++; - log_packet(rapid_commit ? "NOANSWER" : "DHCPNAK", &mess->yiaddr, emac, emac_len, iface_name, NULL, message, mess->xid); + daemon->metrics[rapidCommit ? METRIC_NOANSWER : METRIC_DHCPNAK]++; + log_packet(rapidCommit ? "NOANSWER" : "DHCPNAK", &mess->yiaddr, emac, emac_len, iface_name, NULL, message, mess->xid); /* rapid commit case: lease allocate failed but don't send DHCPNAK */ - if (rapid_commit) + if (rapidCommit) return 0; mess->yiaddr.s_addr = 0; @@ -1523,7 +1523,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, option_put(mess, end, OPTION_MESSAGE_TYPE, 1, DHCPACK); option_put(mess, end, OPTION_SERVER_IDENTIFIER, INADDRSZ, ntohl(server_id(context, override, fallback).s_addr)); option_put(mess, end, OPTION_LEASE_TIME, 4, time); - if (rapid_commit) + if (rapidCommit) option_put(mess, end, OPTION_RAPID_COMMIT, 0, 0); do_options(context, mess, end, req_options, hostname, get_domain(mess->yiaddr), netid, subnet_addr, fqdn_flags, borken_opt, pxearch, uuid, vendor_class_len, now, time, fuzz, pxevendor); diff --git a/src/setupVars.c b/src/setupVars.c index 820f85bb..4509ad92 100644 --- a/src/setupVars.c +++ b/src/setupVars.c @@ -238,10 +238,10 @@ void importsetupVarsConf(void) get_conf_bool_from_setupVars("BLOCKING_ENABLED", &config.dns.blocking.active); // Get clients which the user doesn't want to see - get_conf_string_array_from_setupVars("API_EXCLUDE_CLIENTS", &config.webserver.api.exclude_clients); + get_conf_string_array_from_setupVars("API_EXCLUDE_CLIENTS", &config.webserver.api.excludeClients); // Get domains which the user doesn't want to see - get_conf_string_array_from_setupVars("API_EXCLUDE_DOMAINS", &config.webserver.api.exclude_domains); + get_conf_string_array_from_setupVars("API_EXCLUDE_DOMAINS", &config.webserver.api.excludeDomains); // Try to obtain temperature hot value get_conf_temp_limit_from_setupVars(); @@ -273,21 +273,21 @@ void importsetupVarsConf(void) get_conf_listeningMode_from_setupVars(); // Try to obtain REV_SERVER settings - get_conf_bool_from_setupVars("REV_SERVER", &config.dns.rev_server.active); - get_conf_string_from_setupVars("REV_SERVER_CIDR", &config.dns.rev_server.cidr); - get_conf_string_from_setupVars("REV_SERVER_TARGET", &config.dns.rev_server.target); - get_conf_string_from_setupVars("REV_SERVER_DOMAIN", &config.dns.rev_server.domain); + get_conf_bool_from_setupVars("REV_SERVER", &config.dns.revServer.active); + get_conf_string_from_setupVars("REV_SERVER_CIDR", &config.dns.revServer.cidr); + get_conf_string_from_setupVars("REV_SERVER_TARGET", &config.dns.revServer.target); + get_conf_string_from_setupVars("REV_SERVER_DOMAIN", &config.dns.revServer.domain); // Try to obtain DHCP settings get_conf_bool_from_setupVars("DHCP_ACTIVE", &config.dhcp.active); get_conf_string_from_setupVars("DHCP_START", &config.dhcp.start); get_conf_string_from_setupVars("DHCP_END", &config.dhcp.end); get_conf_string_from_setupVars("DHCP_ROUTER", &config.dhcp.router); - get_conf_string_from_setupVars("DHCP_LEASETIME", &config.dhcp.leasetime); + get_conf_string_from_setupVars("DHCP_LEASETIME", &config.dhcp.leaseTime); get_conf_bool_from_setupVars("DHCP_IPv6", &config.dhcp.ipv6); - get_conf_bool_from_setupVars("DHCP_rapid_commit", &config.dhcp.rapid_commit); + get_conf_bool_from_setupVars("DHCP_RAPID_COMMIT", &config.dhcp.rapidCommit); - get_conf_bool_from_setupVars("QUERY_LOGGING", &config.dns.query_logging); + get_conf_bool_from_setupVars("queryLogging", &config.dns.queryLogging); } char* __attribute__((pure)) find_equals(char *s) diff --git a/test/pihole.toml b/test/pihole.toml index 30985f5e..db38864b 100644 --- a/test/pihole.toml +++ b/test/pihole.toml @@ -174,7 +174,7 @@ cacheSize = 2000 # Log DNS queries and replies to pihole.log - query_logging = true + queryLogging = true # List of CNAME records which indicate that is really . If the is # given, it overwrites the value of local-ttl @@ -182,7 +182,7 @@ # Possible values are: # Array of static leases each on in one of the following forms: # ",[,]" - cnames = [ ] + cnameRecords = [ ] # Port used by the DNS server port = 53 @@ -311,7 +311,7 @@ # ... in the set interval before rate-limiting? interval = 0 ### CHANGED, default = 60 - [dns.rev_server] + [dns.revServer] # Is the reverse server (former also called "conditional forwarding") feature enabled? active = false @@ -366,7 +366,7 @@ # 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 - leasetime = "" + leaseTime = "" # Should Pi-hole make an attempt to also satisfy IPv6 address requests (be aware that # IPv6 works a whole lot different than IPv4) @@ -374,7 +374,7 @@ # 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 - rapid_commit = false + rapidCommit = false # 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 @@ -542,7 +542,7 @@ # # Possible values are: # array of IP addresses and/or hostnames - exclude_clients = [ + excludeClients = [ "1.2.3.4" ] ### CHANGED, default = [ ] @@ -551,7 +551,7 @@ # # Possible values are: # array of IP addresses and/or hostnames - exclude_domains = [ ] + excludeDomains = [ ] [webserver.api.temp] # Which upper temperature limit should be used by Pi-hole? Temperatures above this