From 90d6511510655287df3cea243dc45885d5b93c73 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Wed, 21 Sep 2022 15:28:41 +0800 Subject: [PATCH] feat: assets loader --- include/applet/crontab.h | 9 +++++++++ include/utils/process.h | 2 ++ src/applet/CMakeLists.txt | 2 +- src/applet/crontab.c | 12 ++++++++++++ src/cleardns.c | 6 ++++++ 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 include/applet/crontab.h create mode 100644 src/applet/crontab.c diff --git a/include/applet/crontab.h b/include/applet/crontab.h new file mode 100644 index 0000000..46ce7a5 --- /dev/null +++ b/include/applet/crontab.h @@ -0,0 +1,9 @@ +#ifndef CRONTAB_H_ +#define CRONTAB_H_ + +#include "config.h" +#include "process.h" + +process* assets_load(assets_config *info); + +#endif diff --git a/include/utils/process.h b/include/utils/process.h index db2a08c..2d8e5b0 100644 --- a/include/utils/process.h +++ b/include/utils/process.h @@ -1,6 +1,8 @@ #ifndef PROCESS_H_ #define PROCESS_H_ +#include + typedef struct { char *name; char **cmd; diff --git a/src/applet/CMakeLists.txt b/src/applet/CMakeLists.txt index 64b58e9..c6ddac0 100644 --- a/src/applet/CMakeLists.txt +++ b/src/applet/CMakeLists.txt @@ -1,4 +1,4 @@ cmake_minimum_required(VERSION 2.8.12) -add_library(applet adguard.c dnsproxy.c overture.c) +add_library(applet adguard.c dnsproxy.c overture.c crontab.c) target_link_libraries(applet bcrypt utils) diff --git a/src/applet/crontab.c b/src/applet/crontab.c new file mode 100644 index 0000000..0e90649 --- /dev/null +++ b/src/applet/crontab.c @@ -0,0 +1,12 @@ +#include "process.h" +#include "config.h" +#include "logger.h" + +process* assets_load(assets_config *info) { // load assets update options + log_info("assets test ok"); + + // TODO: update assets process + // TODO: save cron exp in `/var/spool/cron/crontabs/root` + + return process_init("Crontab", "crond"); +} diff --git a/src/cleardns.c b/src/cleardns.c index 74d9c15..8b67147 100644 --- a/src/cleardns.c +++ b/src/cleardns.c @@ -12,6 +12,7 @@ #include "sundry.h" #include "structure.h" #include "assets.h" +#include "crontab.h" char* init(int argc, char *argv[]) { // return config file char *config = string_init(CONFIG_FILE); @@ -66,6 +67,10 @@ int main(int argc, char *argv[]) { // ClearDNS service load_config(config_file); free(config_file); + assets_load(loader.assets); + + return 0; + if (LOG_LEVEL == LOG_DEBUG) { // debug mode enabled loader.filter->debug = TRUE; loader.diverter->debug = TRUE; @@ -75,6 +80,7 @@ int main(int argc, char *argv[]) { // ClearDNS service process_list_init(); // TODO: crontab of assets + process_list_append(dnsproxy_load("Domestic", loader.domestic, "domestic.json")); process_list_append(dnsproxy_load("Foreign", loader.foreign, "foreign.json")); process_list_append(overture_load(loader.diverter, "overture.json"));