From 8c5e1607efee534d3e8aaf4f00edc459391334a0 Mon Sep 17 00:00:00 2001 From: dnomd343 Date: Sun, 11 Sep 2022 19:03:48 +0800 Subject: [PATCH] fix: cache size to int type --- include/dnsproxy.h | 2 +- src/cleardns.c | 6 +++--- src/dnsproxy.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/dnsproxy.h b/include/dnsproxy.h index 877321d..b193d22 100644 --- a/include/dnsproxy.h +++ b/include/dnsproxy.h @@ -3,13 +3,13 @@ typedef struct { int port; + int cache; int verify; // bool value int parallel; // bool value int optimistic; // bool value char **bootstrap; char **fallback; char **primary; - char *cache; } dnsproxy; dnsproxy* dnsproxy_init(int port); diff --git a/src/cleardns.c b/src/cleardns.c index 6ed014d..b8c5dfc 100644 --- a/src/cleardns.c +++ b/src/cleardns.c @@ -45,10 +45,10 @@ int main(int argc, char *argv[]) { // ClearDNS server dnsproxy_add_fallback(domestic, "tls://223.6.6.6"); dnsproxy_add_fallback(domestic, "tls://120.53.53.53"); - domestic->verify = FALSE; +// domestic->verify = FALSE; // domestic->parallel = FALSE; - domestic->optimistic = TRUE; -// domestic->cache = "0"; +// domestic->optimistic = TRUE; + domestic->cache = 0; dnsproxy_dump("Domestic", domestic); diff --git a/src/dnsproxy.c b/src/dnsproxy.c index ab378ea..9d39ec7 100644 --- a/src/dnsproxy.c +++ b/src/dnsproxy.c @@ -16,7 +16,7 @@ dnsproxy* dnsproxy_init(int port) { info->bootstrap = string_list_init(); info->fallback = string_list_init(); info->primary = string_list_init(); - info->cache = "4194304"; // 4MiB + info->cache = 4194304; // 4MiB return info; } @@ -28,7 +28,7 @@ void dnsproxy_dump(char *caption, dnsproxy *info) { log_debug("%s bootstrap -> %s", caption, string_list_dump(info->bootstrap)); log_debug("%s fallback -> %s", caption, string_list_dump(info->fallback)); log_debug("%s primary -> %s", caption, string_list_dump(info->primary)); - log_debug("%s cache -> %s", caption, info->cache); + log_debug("%s cache -> %d", caption, info->cache); } void dnsproxy_add_primary(dnsproxy *info, char *server) { @@ -51,9 +51,9 @@ void dnsproxy_gen_config(dnsproxy *info) { if (info->parallel) { cJSON_AddTrueToObject(config, "all-servers"); } - if (strcmp(info->cache, "0") != 0) { + if (info->cache) { cJSON_AddTrueToObject(config, "cache"); - cJSON_AddStringToObject(config, "cache-size", info->cache); + cJSON_AddNumberToObject(config, "cache-size", info->cache); } if (info->optimistic) { cJSON_AddTrueToObject(config, "cache-optimistic");