diff --git a/include/applet/dnsproxy.h b/include/applet/dnsproxy.h index 81a26e7..6a8bce8 100644 --- a/include/applet/dnsproxy.h +++ b/include/applet/dnsproxy.h @@ -7,6 +7,7 @@ typedef struct { uint16_t port; uint32_t cache; + uint8_t ipv6; // bool value uint8_t debug; // bool value uint8_t verify; // bool value uint8_t parallel; // bool value diff --git a/include/loader/config.h b/include/loader/config.h index d0c5f33..2a2f9bc 100644 --- a/include/loader/config.h +++ b/include/loader/config.h @@ -5,6 +5,7 @@ typedef struct { uint16_t port; + uint8_t ipv6; // bool value uint8_t verify; // bool value uint8_t parallel; // bool value char **bootstrap; diff --git a/src/applet/dnsproxy.c b/src/applet/dnsproxy.c index 593b4b2..4b86264 100644 --- a/src/applet/dnsproxy.c +++ b/src/applet/dnsproxy.c @@ -21,6 +21,7 @@ dnsproxy* dnsproxy_init(uint16_t port) { // init dnsproxy options dnsproxy *info = (dnsproxy *)malloc(sizeof(dnsproxy)); info->port = port; info->cache = 0; // disable cache in default + info->ipv6 = TRUE; info->debug = FALSE; info->verify = TRUE; info->parallel = TRUE; @@ -35,6 +36,7 @@ void dnsproxy_dump(const char *caption, dnsproxy *info) { // show dnsproxy optio char *str_dump; log_debug("%s port -> %u", caption, info->port); log_debug("%s cache -> %u", caption, info->cache); + log_debug("%s ipv6 -> %s", caption, show_bool(info->ipv6)); log_debug("%s debug -> %s", caption, show_bool(info->debug)); log_debug("%s verify -> %s", caption, show_bool(info->verify)); log_debug("%s parallel -> %s", caption, show_bool(info->parallel)); @@ -94,6 +96,8 @@ char* dnsproxy_config(dnsproxy *info) { // generate json configure from dnsproxy if (info->optimistic) { cJSON_AddTrueToObject(config, "cache-optimistic"); // cache-optimistic --(default)--> `false` } + // TODO: load ipv6 option + log_warn("TODO: load ipv6 option"); cJSON *port = cJSON_CreateArray(); cJSON_AddItemToArray(port, cJSON_CreateNumber(info->port)); diff --git a/src/loader/config.c b/src/loader/config.c index e5b3117..f462337 100644 --- a/src/loader/config.c +++ b/src/loader/config.c @@ -14,6 +14,7 @@ cleardns_config* config_init() { // init config struct of cleardns config->cache.optimistic = FALSE; config->domestic.port = DOMESTIC_PORT; + config->domestic.ipv6 = TRUE; config->domestic.verify = TRUE; config->domestic.parallel = TRUE; config->domestic.bootstrap = string_list_init(); @@ -21,6 +22,7 @@ cleardns_config* config_init() { // init config struct of cleardns config->domestic.primary = string_list_init(); config->foreign.port = FOREIGN_PORT; + config->foreign.ipv6 = TRUE; config->foreign.verify = TRUE; config->foreign.parallel = TRUE; config->foreign.bootstrap = string_list_init(); @@ -56,6 +58,7 @@ void config_dump(cleardns_config *config) { // dump config info of cleardns log_debug("Cache optimistic -> %s", show_bool(config->cache.optimistic)); log_debug("Domestic port -> %u", config->domestic.port); + log_debug("Domestic ipv6 -> %s", show_bool(config->domestic.ipv6)); log_debug("Domestic verify -> %s", show_bool(config->domestic.verify)); log_debug("Domestic parallel -> %s", show_bool(config->domestic.parallel)); string_list_debug("Domestic bootstrap", config->domestic.bootstrap); @@ -63,6 +66,7 @@ void config_dump(cleardns_config *config) { // dump config info of cleardns string_list_debug("Domestic primary", config->domestic.primary); log_debug("Foreign port -> %u", config->foreign.port); + log_debug("Foreign ipv6 -> %s", show_bool(config->foreign.ipv6)); log_debug("Foreign verify -> %s", show_bool(config->foreign.verify)); log_debug("Foreign parallel -> %s", show_bool(config->foreign.parallel)); string_list_debug("Foreign bootstrap", config->foreign.bootstrap); diff --git a/src/loader/loader.c b/src/loader/loader.c index 6914654..09b3bd2 100644 --- a/src/loader/loader.c +++ b/src/loader/loader.c @@ -29,6 +29,7 @@ void load_diverter_assets() { dnsproxy* load_domestic(cleardns_config *config) { dnsproxy *domestic = dnsproxy_init(config->domestic.port); + domestic->ipv6 = config->domestic.ipv6; domestic->verify = config->domestic.verify; domestic->parallel = config->domestic.parallel; if (config->cache.enable) { @@ -43,6 +44,7 @@ dnsproxy* load_domestic(cleardns_config *config) { dnsproxy* load_foreign(cleardns_config *config) { dnsproxy *foreign = dnsproxy_init(config->foreign.port); + foreign->ipv6 = config->foreign.ipv6; foreign->verify = config->foreign.verify; foreign->parallel = config->foreign.parallel; if (config->cache.enable) { diff --git a/src/loader/parser.c b/src/loader/parser.c index b03c657..ca8d9d7 100644 --- a/src/loader/parser.c +++ b/src/loader/parser.c @@ -37,6 +37,11 @@ void upstream_parser(char *caption, upstream_config *config, cJSON *json) { // u config->port = json_int_value(key_name, json); free(key_name); } + if (!strcmp(json->string, "ipv6")) { + key_name = string_join(caption, ".ipv6"); + config->ipv6 = json_bool_value(key_name, json); + free(key_name); + } if (!strcmp(json->string, "verify")) { key_name = string_join(caption, ".verify"); config->verify = json_bool_value(key_name, json);