Browse Source

feat: assets loader

dev
Dnomd343 2 years ago
parent
commit
90d6511510
  1. 9
      include/applet/crontab.h
  2. 2
      include/utils/process.h
  3. 2
      src/applet/CMakeLists.txt
  4. 12
      src/applet/crontab.c
  5. 6
      src/cleardns.c

9
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

2
include/utils/process.h

@ -1,6 +1,8 @@
#ifndef PROCESS_H_
#define PROCESS_H_
#include <stdint.h>
typedef struct {
char *name;
char **cmd;

2
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)

12
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");
}

6
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"));

Loading…
Cancel
Save