优化
This commit is contained in:
parent
6f25fb3672
commit
99893d8c3d
@ -89,6 +89,8 @@ May 22 2024 15:05:59 Compile、link.
|
||||
```text
|
||||
配置文件
|
||||
global {
|
||||
|
||||
DAEMON = "off"; // on开启后台运行,off不开启
|
||||
TIME = "1"; // 睡眠时间(大于等于1,单位秒)
|
||||
|
||||
PUBLIC_IP = "http://inet-ip.aixiao.me/"; // 获取公网IP
|
||||
@ -109,8 +111,8 @@ global {
|
||||
IP2REGION = 1; // 是否使用本地 ip2region 地址定位库(1使用,非1不使用)
|
||||
REGION_LIST = "河南 郑州 上海"; // 地域列表(空格隔开)
|
||||
|
||||
NGINX = 0; // 是否启用Nginx白名单
|
||||
NGINX_LOG_FILE= "/var/log/nginx/access.log"; // Nginx 日志文件
|
||||
NGINX = 1; // 是否启用Nginx白名单
|
||||
NGINX_LOG_FILE= "/usr/local/nginx/logs/access.log"; // Nginx 日志文件
|
||||
NGINX_REGION_LIST = "中国 河南 郑州 上海 内网"; // 地域列表(空格隔开)
|
||||
|
||||
IS_DING_WEBHOOK = 0; // 开启叮叮告警(1开启,非1关闭)
|
||||
|
48
conf.c
48
conf.c
@ -120,11 +120,6 @@ static void parse_global_module(char *content, conf * conf)
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcasecmp(var, "IS_QQMAIL") == 0) {
|
||||
val_begin_len = val_end - val_begin;
|
||||
conf->IS_QQMAIL = atoi(val_begin);
|
||||
}
|
||||
|
||||
if (strcasecmp(var, "RECV_MAIL") == 0) {
|
||||
val_begin_len = val_end - val_begin;
|
||||
if (copy_new_mem(val_begin, val_begin_len, &conf->RECV_MAIL) != 0)
|
||||
@ -277,31 +272,29 @@ void read_conf(char *filename, conf * configure)
|
||||
|
||||
void free_conf(conf * conf)
|
||||
{
|
||||
if (conf->DAEMON)
|
||||
free(conf->DAEMON);
|
||||
if (conf->PHONE)
|
||||
if (conf->PHONE != NULL)
|
||||
free(conf->PHONE);
|
||||
if (conf->DING_WEBHOOK)
|
||||
if (conf->DING_WEBHOOK != NULL)
|
||||
free(conf->DING_WEBHOOK);
|
||||
if (conf->RECV_MAIL)
|
||||
if (conf->RECV_MAIL != NULL)
|
||||
free(conf->RECV_MAIL);
|
||||
if (conf->PUBLIC_IP)
|
||||
if (conf->PUBLIC_IP != NULL)
|
||||
free(conf->PUBLIC_IP);
|
||||
if (conf->IPV4_WHITE_LIST)
|
||||
if (conf->IPV4_WHITE_LIST != NULL)
|
||||
free(conf->IPV4_WHITE_LIST);
|
||||
|
||||
if (conf->REGION_LIST)
|
||||
if (conf->REGION_LIST != NULL)
|
||||
free(conf->REGION_LIST);
|
||||
|
||||
if (conf->CLAMAV_TIME)
|
||||
if (conf->CLAMAV_TIME != NULL)
|
||||
free(conf->CLAMAV_TIME);
|
||||
if (conf->CLAMAV_ARG)
|
||||
if (conf->CLAMAV_ARG != NULL)
|
||||
free(conf->CLAMAV_ARG);
|
||||
|
||||
// NGINX
|
||||
if (conf->NGINX_LOG_FILE)
|
||||
if (conf->NGINX_LOG_FILE != NULL)
|
||||
free(conf->NGINX_LOG_FILE);
|
||||
if (conf->NGINX_REGION_LIST)
|
||||
if (conf->NGINX_REGION_LIST != NULL)
|
||||
free(conf->NGINX_REGION_LIST);
|
||||
|
||||
return;
|
||||
@ -309,37 +302,36 @@ void free_conf(conf * conf)
|
||||
|
||||
void ptintf_conf(conf * conf)
|
||||
{
|
||||
if (conf->DAEMON)
|
||||
if (conf->DAEMON != NULL)
|
||||
printf("DAEMON %s\n", conf->DAEMON);
|
||||
printf("TIME %d\n", conf->TIME);
|
||||
|
||||
printf("IS_MAIL %d\n", conf->IS_MAIL);
|
||||
printf("IS_DING_WEBHOOK %d\n", conf->IS_DING_WEBHOOK);
|
||||
if (conf->PHONE)
|
||||
if (conf->PHONE != NULL)
|
||||
printf("PHONE %s\n", conf->PHONE);
|
||||
if (conf->DING_WEBHOOK)
|
||||
if (conf->DING_WEBHOOK != NULL)
|
||||
printf("DING_WEBHOOK %s\n", conf->DING_WEBHOOK);
|
||||
printf("IS_QQMAIL %d\n", conf->IS_QQMAIL);
|
||||
|
||||
if (conf->RECV_MAIL)
|
||||
if (conf->RECV_MAIL != NULL)
|
||||
printf("RECV_MAIL %s\n", conf->RECV_MAIL);
|
||||
if (conf->PUBLIC_IP)
|
||||
if (conf->PUBLIC_IP != NULL)
|
||||
printf("PUBLIC_IP %s\n", conf->PUBLIC_IP);
|
||||
|
||||
printf("IPV4_RESTRICTION %d\n", conf->IPV4_RESTRICTION);
|
||||
if (conf->IPV4_WHITE_LIST)
|
||||
if (conf->IPV4_WHITE_LIST != NULL)
|
||||
printf("IPV4_WHITE_LIST %s\n", conf->IPV4_WHITE_LIST);
|
||||
|
||||
printf("REGION %d\n", conf->REGION);
|
||||
if (conf->REGION_LIST)
|
||||
if (conf->REGION_LIST != NULL)
|
||||
printf("REGION_LIST %s\n", conf->REGION_LIST);
|
||||
|
||||
if (conf->CLAMAV_ARG)
|
||||
if (conf->CLAMAV_ARG != NULL)
|
||||
printf("CLAMAV_ARG %s %d\n", conf->CLAMAV_ARG, conf->CLAMAV_ARG_LEN);
|
||||
|
||||
// Nginx
|
||||
if (conf->NGINX_LOG_FILE)
|
||||
if (conf->NGINX_LOG_FILE != NULL)
|
||||
printf("CLAMAV_ARG %s %d\n", conf->NGINX_LOG_FILE, conf->NGINX_LOG_FILE_LEN);
|
||||
if (conf->NGINX_REGION_LIST)
|
||||
if (conf->NGINX_REGION_LIST != NULL)
|
||||
printf("CLAMAV_ARG %s %d\n", conf->NGINX_REGION_LIST, conf->NGINX_REGION_LIST_LEN);
|
||||
}
|
||||
|
6
conf.h
6
conf.h
@ -46,17 +46,13 @@ typedef struct CONF
|
||||
char *NGINX_REGION_LIST;
|
||||
int NGINX_REGION_LIST_LEN;
|
||||
|
||||
int IS_MAIL;
|
||||
|
||||
// 钉钉
|
||||
int IS_DING_WEBHOOK;
|
||||
char *PHONE;
|
||||
char *DING_WEBHOOK;
|
||||
|
||||
// 第三方邮箱
|
||||
int IS_QQMAIL;
|
||||
//char *SEND_QQ;
|
||||
//char *QQMAIL_KEY;
|
||||
int IS_MAIL;
|
||||
char *RECV_MAIL;
|
||||
} conf;
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
global {
|
||||
|
||||
DAEMON = "off"; // on开启后台运行,off不开启
|
||||
TIME = "1"; // 睡眠时间(大于等于1,单位秒)
|
||||
|
||||
PUBLIC_IP = "http://inet-ip.aixiao.me/"; // 获取公网IP
|
||||
@ -19,8 +21,8 @@ global {
|
||||
IP2REGION = 1; // 是否使用本地 ip2region 地址定位库(1使用,非1不使用)
|
||||
REGION_LIST = "河南 郑州 上海"; // 地域列表(空格隔开)
|
||||
|
||||
NGINX = 0; // 是否启用Nginx白名单
|
||||
NGINX_LOG_FILE= "/var/log/nginx/access.log"; // Nginx 日志文件
|
||||
NGINX = 1; // 是否启用Nginx白名单
|
||||
NGINX_LOG_FILE= "/usr/local/nginx/logs/access.log"; // Nginx 日志文件
|
||||
NGINX_REGION_LIST = "中国 河南 郑州 上海 内网"; // 地域列表(空格隔开)
|
||||
|
||||
IS_DING_WEBHOOK = 0; // 开启叮叮告警(1开启,非1关闭)
|
||||
|
Loading…
Reference in New Issue
Block a user