|
|
@ -8,6 +8,12 @@ |
|
|
|
|
|
|
|
struct cleardns loader; |
|
|
|
|
|
|
|
void load_diverter_assets() { |
|
|
|
// ${ASSETS_DIR}${ASSET_GFW_LIST} >> ${WORK_DIR}${ASSET_GFW_LIST}
|
|
|
|
// ${ASSETS_DIR}${ASSET_CHINA_IP} >> ${WORK_DIR}${ASSET_CHINA_IP}
|
|
|
|
// ${ASSETS_DIR}${ASSET_CHINA_LIST} >> ${WORK_DIR}${ASSET_CHINA_LIST}
|
|
|
|
} |
|
|
|
|
|
|
|
dnsproxy* load_domestic(cleardns_config *config) { |
|
|
|
dnsproxy *domestic = dnsproxy_init(config->domestic.port); |
|
|
|
domestic->verify = config->domestic.verify; |
|
|
@ -42,26 +48,40 @@ overture* load_diverter(cleardns_config *config) { |
|
|
|
diverter->foreign_port = config->foreign.port; |
|
|
|
diverter->domestic_port = config->domestic.port; |
|
|
|
|
|
|
|
if (string_list_len(config->ttl)) { |
|
|
|
free(diverter->ttl_file); |
|
|
|
free(diverter->host_file); |
|
|
|
// TODO: load into ASSET_TTL
|
|
|
|
// TODO: load into ASSET_HOSTS
|
|
|
|
diverter->ttl_file = string_init(ASSET_TTL); |
|
|
|
char *ttl_file = string_join(WORK_DIR, ASSET_TTL); |
|
|
|
save_string_list(ttl_file, config->ttl); |
|
|
|
free(ttl_file); |
|
|
|
} |
|
|
|
if (string_list_len(config->hosts)) { |
|
|
|
free(diverter->host_file); |
|
|
|
diverter->host_file = string_init(ASSET_HOSTS); |
|
|
|
char *hosts_file = string_join(WORK_DIR, ASSET_HOSTS); |
|
|
|
save_string_list(hosts_file, config->hosts); |
|
|
|
free(hosts_file); |
|
|
|
} |
|
|
|
|
|
|
|
free(diverter->domestic_ip_file); |
|
|
|
free(diverter->foreign_domain_file); |
|
|
|
free(diverter->domestic_domain_file); |
|
|
|
// TODO: load into ASSET_CHINA_IP
|
|
|
|
// TODO: load into ASSET_GFW_LIST
|
|
|
|
// TODO: load into ASSET_CHINA_LIST
|
|
|
|
diverter->domestic_ip_file = string_init(ASSET_CHINA_IP); |
|
|
|
diverter->foreign_domain_file = string_init(ASSET_GFW_LIST); |
|
|
|
diverter->domestic_domain_file = string_init(ASSET_CHINA_LIST); |
|
|
|
|
|
|
|
// TODO: assets file append
|
|
|
|
char *gfwlist = string_join(WORK_DIR, ASSET_GFW_LIST); |
|
|
|
char *china_ip = string_join(WORK_DIR, ASSET_CHINA_IP); |
|
|
|
char *chinalist = string_join(WORK_DIR, ASSET_CHINA_LIST); |
|
|
|
save_string_list(gfwlist, config->diverter.gfwlist); |
|
|
|
save_string_list(china_ip, config->diverter.china_ip); |
|
|
|
save_string_list(chinalist, config->diverter.chinalist); |
|
|
|
free(chinalist); |
|
|
|
free(china_ip); |
|
|
|
free(gfwlist); |
|
|
|
|
|
|
|
diverter->reject_type = uint32_list_update(diverter->reject_type, config->reject); |
|
|
|
load_diverter_assets(); |
|
|
|
return diverter; |
|
|
|
} |
|
|
|
|
|
|
@ -84,6 +104,10 @@ void load_config(const char *config_file) { |
|
|
|
cleardns_config *config = config_init(); |
|
|
|
config_parser(config, config_file); |
|
|
|
config_dump(config); |
|
|
|
|
|
|
|
// TODO: extract assets file
|
|
|
|
// TODO: mkdir -p ${WORK_DIR}
|
|
|
|
|
|
|
|
if (!config->adguard.enable) { |
|
|
|
config->diverter.port = config->port; // override diverter port by dns port
|
|
|
|
} |
|
|
|