Compare commits

..

No commits in common. "15b093d3f6f30eff1003699b7d4da65a042c6ea1" and "969927106ef9eb03564fd5e1501260cc1b957d4a" have entirely different histories.

5 changed files with 19 additions and 46 deletions

48
conf.c
View File

@ -144,12 +144,6 @@ static void parse_global_module(char *content, conf * conf)
if (copy_new_mem(val_begin, val_begin_len, &conf->RECV_MAIL) != 0)
return;
}
if (strcasecmp(var, "PUBLIC_IP") == 0) {
val_begin_len = val_end - val_begin;
if (copy_new_mem(val_begin, val_begin_len, &conf->PUBLIC_IP) != 0)
return;
}
content = strchr(lineEnd + 1, '\n');
}
@ -212,43 +206,27 @@ void read_conf(char *filename, conf * configure)
void free_conf(conf * conf)
{
if (conf->DAEMON)
free(conf->DAEMON);
if (conf->PHONE)
free(conf->PHONE);
if (conf->DING_WEBHOOK)
free(conf->DING_WEBHOOK);
if (conf->SEND_QQ)
free(conf->SEND_QQ);
if (conf->QQMAIL_KEY)
free(conf->QQMAIL_KEY);
if (conf->RECV_MAIL)
free(conf->RECV_MAIL);
if (conf->PUBLIC_IP)
free(conf->PUBLIC_IP);
free(conf->DAEMON);
free(conf->PHONE);
free(conf->DING_WEBHOOK);
free(conf->SEND_QQ);
free(conf->QQMAIL_KEY);
free(conf->RECV_MAIL);
return;
}
void ptintf_conf(conf * conf)
{
if (conf->DAEMON)
printf("%s\n", conf->DAEMON);
printf("%s\n", conf->DAEMON);
printf("%d\n", conf->TIME);
printf("%d\n", conf->REFUSE_NUMBER);
printf("%d\n", conf->IS_MAIL);
printf("%d\n", conf->IS_DING_WEBHOOK);
if (conf->PHONE)
printf("%s\n", conf->PHONE);
if (conf->DING_WEBHOOK)
printf("%s\n", conf->DING_WEBHOOK);
printf("%s\n", conf->PHONE);
printf("%s\n", conf->DING_WEBHOOK);
printf("%d\n", conf->IS_QQMAIL);
if (conf->SEND_QQ)
printf("%s\n", conf->SEND_QQ);
if (conf->QQMAIL_KEY)
printf("%s\n", conf->QQMAIL_KEY);
if (conf->RECV_MAIL)
printf("%s\n", conf->RECV_MAIL);
if (conf->PUBLIC_IP)
printf("%s\n", conf->PUBLIC_IP);
printf("%s\n", conf->SEND_QQ);
printf("%s\n", conf->QQMAIL_KEY);
printf("%s\n", conf->RECV_MAIL);
}

3
conf.h
View File

@ -12,9 +12,6 @@ typedef struct CONF {
int TIME;
int REFUSE_NUMBER;
// 获取公网IP Url地址
char *PUBLIC_IP;
int IS_MAIL;

View File

@ -28,7 +28,7 @@ function run()
free -hl &>> ${LOG_FILE}
echo "System process:" &>> ${LOG_FILE}
ps -auxwwf &>> ${LOG_FILE}
ps -auxwwjf &>> ${LOG_FILE}
echo "Network Connections" &>> ${LOG_FILE}
netstat -tnulp &>> ${LOG_FILE}

View File

@ -62,8 +62,7 @@ static char *GET_PUBLIC_IP(char *URL)
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
} else {
//printf("%lu bytes retrieved\n", (unsigned long)chunk.size);
//printf("%s", chunk.memory);
;
printf("%s", chunk.memory);
}
curl_easy_cleanup(curl_handle);
@ -364,7 +363,8 @@ int main(int argc, char *argv[], char **env)
//ptintf_conf(conf);
// 新版本获取公网IP
public_ip = GET_PUBLIC_IP(conf->PUBLIC_IP);
public_ip = GET_PUBLIC_IP("http://ip.sb");
//printf("%s", public_ip);
signal(SIGCHLD, sig_child); // 创建捕捉子进程退出信号

View File

@ -2,9 +2,7 @@ global {
DAEMON = "off"; // on开启后台运行off不开启
TIME = "60"; // 睡眠时间
PUBLIC_IP = "http://inet-ip.info"; // 获取公网IP
REFUSE_NUMBER = 3; // 拒绝攻击次数
REFUSE_NUMBER = 3; // 拒绝攻击次数
IS_MAIL = 0; // 开启邮件告警
@ -12,6 +10,6 @@ global {
PHONE = "15565979082"; // @的人手机号
DING_WEBHOOK = "https://oapi.dingtalk.com/robot/send?access_token=7f069c672cb878987aa6772cca336740eece4ce36bde12b51b45e9f440e0565a"; // 钉钉WEBHOOK
IS_QQMAIL = 0; // 开启QQ邮箱告警
IS_QQMAIL = 1; // 开启QQ邮箱告警
RECV_MAIL = "1605227279@qq.com"; // 接收者QQ
}