mirror of https://github.com/dnomd343/ClearDNS
dnomd343
2 years ago
5 changed files with 60 additions and 53 deletions
@ -1,11 +1,13 @@ |
|||
#ifndef _COMMON_H_ |
|||
#define _COMMON_H_ |
|||
|
|||
extern char **adguard_command; |
|||
extern char **overture_command; |
|||
extern char **domestic_dnsproxy_command; |
|||
extern char **foreign_dnsproxy_command; |
|||
#define VERSION "1.3.0-dev" |
|||
|
|||
void load_start_command(char *adguard_workdir, char *overture_config, char *upstream_config, int is_debug); |
|||
//extern char **adguard_command;
|
|||
//extern char **overture_command;
|
|||
//extern char **domestic_dnsproxy_command;
|
|||
//extern char **foreign_dnsproxy_command;
|
|||
//
|
|||
//void load_start_command(char *adguard_workdir, char *overture_config, char *upstream_config, int is_debug);
|
|||
|
|||
#endif |
|||
|
@ -1,13 +1,9 @@ |
|||
cmake_minimum_required(VERSION 2.8.12) |
|||
|
|||
include_directories(${PROJECT_SOURCE_DIR}/include) |
|||
include_directories(/usr/lib/i386-linux-gnu/glib-2.0/include) |
|||
include_directories(/usr/lib/x86_64-linux-gnu/glib-2.0/include) |
|||
include_directories(/usr/lib/aarch64-linux-gnu/glib-2.0/include) |
|||
include_directories(/usr/lib64/glib-2.0/include) |
|||
include_directories(/usr/lib/glib-2.0/include) |
|||
include_directories(/usr/include/glib-2.0) |
|||
include_directories(${PROJECT_SOURCE_DIR}/include/utils) |
|||
|
|||
aux_source_directory(${PROJECT_SOURCE_DIR}/src SRC) |
|||
add_executable(cleardns ${SRC}) |
|||
target_link_libraries(cleardns glib-2.0) |
|||
add_subdirectory(utils) |
|||
|
|||
add_executable(cleardns cleardns.c) |
|||
target_link_libraries(cleardns utils) |
|||
|
@ -1,47 +1,53 @@ |
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include "logger.h" |
|||
#include "common.h" |
|||
#include "process.h" |
|||
|
|||
char *init_script = "/usr/bin/load"; |
|||
char *custom_script = "/etc/cleardns/custom.sh"; |
|||
//#include <stdio.h>
|
|||
//#include <string.h>
|
|||
//#include "common.h"
|
|||
//#include "process.h"
|
|||
|
|||
char *adguard_workdir = "/etc/cleardns/AdGuardHome"; |
|||
char *overture_config = "/etc/overture/config.yml"; |
|||
char *upstream_config = "/etc/cleardns/upstream.json"; |
|||
//char *init_script = "/usr/bin/load";
|
|||
//char *custom_script = "/etc/cleardns/custom.sh";
|
|||
//
|
|||
//char *adguard_workdir = "/etc/cleardns/AdGuardHome";
|
|||
//char *overture_config = "/etc/overture/config.yml";
|
|||
//char *upstream_config = "/etc/cleardns/upstream.json";
|
|||
|
|||
void show_command(char *title, char **command) { |
|||
int num = 0; |
|||
fprintf(stderr, "%s => \"", title); |
|||
while(command[num] != NULL) { |
|||
fprintf(stderr, "%s", command[num++]); |
|||
if (command[num] != NULL) { |
|||
fprintf(stderr, " "); |
|||
} |
|||
} |
|||
fprintf(stderr, "\"\n"); |
|||
} |
|||
//void show_command(char *title, char **command) {
|
|||
// int num = 0;
|
|||
// fprintf(stderr, "%s => \"", title);
|
|||
// while(command[num] != NULL) {
|
|||
// fprintf(stderr, "%s", command[num++]);
|
|||
// if (command[num] != NULL) {
|
|||
// fprintf(stderr, " ");
|
|||
// }
|
|||
// }
|
|||
// fprintf(stderr, "\"\n");
|
|||
//}
|
|||
|
|||
int main(int argc, char *argv[]) { // ClearDNS server
|
|||
int debug_mode = 0; |
|||
fprintf(stderr, "[ClearDNS] Server start.\n"); |
|||
for (char **p = argv; p < argv + argc; ++p) { |
|||
if (!strcmp(*p, "--debug")) { // --debug option
|
|||
++debug_mode; |
|||
} |
|||
} |
|||
|
|||
init_server(init_script, custom_script); // run init script and custom script
|
|||
|
|||
load_start_command(adguard_workdir, overture_config, upstream_config, debug_mode); // generate commands
|
|||
if (debug_mode) { // show exec command
|
|||
fprintf(stderr, "[ClearDNS] Debug mode.\n"); |
|||
show_command("[ClearDNS] adguard", adguard_command); |
|||
show_command("[ClearDNS] overture", overture_command); |
|||
show_command("[ClearDNS] dnsproxy (domestic)", domestic_dnsproxy_command); |
|||
show_command("[ClearDNS] dnsproxy (foreign)", foreign_dnsproxy_command); |
|||
} |
|||
log_info("ClearDNS server start (%s)", VERSION); |
|||
|
|||
server_daemon(); // run as daemon to manage process in docker
|
|||
// int debug_mode = 0;
|
|||
// fprintf(stderr, "[ClearDNS] Server start.\n");
|
|||
// for (char **p = argv; p < argv + argc; ++p) {
|
|||
// if (!strcmp(*p, "--debug")) { // --debug option
|
|||
// ++debug_mode;
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// init_server(init_script, custom_script); // run init script and custom script
|
|||
//
|
|||
// load_start_command(adguard_workdir, overture_config, upstream_config, debug_mode); // generate commands
|
|||
// if (debug_mode) { // show exec command
|
|||
// fprintf(stderr, "[ClearDNS] Debug mode.\n");
|
|||
// show_command("[ClearDNS] adguard", adguard_command);
|
|||
// show_command("[ClearDNS] overture", overture_command);
|
|||
// show_command("[ClearDNS] dnsproxy (domestic)", domestic_dnsproxy_command);
|
|||
// show_command("[ClearDNS] dnsproxy (foreign)", foreign_dnsproxy_command);
|
|||
// }
|
|||
//
|
|||
// server_daemon(); // run as daemon to manage process in docker
|
|||
return 0; |
|||
} |
|||
|
@ -0,0 +1,3 @@ |
|||
cmake_minimum_required(VERSION 2.8.12) |
|||
|
|||
add_library(utils cJSON.c logger.c) |
Loading…
Reference in new issue