From a719fe831ef3b08350d1da417fdb7ebfa7ee8fac Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Tue, 27 Sep 2022 20:43:51 +0800 Subject: [PATCH] feat: setting config file from env --- include/constant.h | 2 +- src/cleardns.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/constant.h b/include/constant.h index 75140d2..fd4ce04 100644 --- a/include/constant.h +++ b/include/constant.h @@ -12,7 +12,7 @@ #define DIVERTER_TIMEOUT 6 -#define VERSION "1.3.0-beta1" +#define VERSION "1.3.0-beta2" #define CONFIG_FILE "cleardns.yml" #define ADGUARD_USER "admin" diff --git a/src/cleardns.c b/src/cleardns.c index 0e9d5d9..18c1f22 100644 --- a/src/cleardns.c +++ b/src/cleardns.c @@ -17,6 +17,12 @@ char* init(int argc, char *argv[]) { // return config file char *config = string_init(CONFIG_FILE); + if (getenv("CONFIG") != NULL) { + config = string_init(getenv("CONFIG")); + } + if (getenv("DEBUG") != NULL && !strcmp(getenv("DEBUG"), "TRUE")) { + LOG_LEVEL = LOG_DEBUG; // enable debug mode + } for (int i = 0; i < argc; ++i) { if (!strcmp(argv[i], "--debug")) { LOG_LEVEL = LOG_DEBUG; // enable debug mode