修改MD
This commit is contained in:
21
cap.c
21
cap.c
@@ -2,22 +2,20 @@
|
||||
#include "common.h"
|
||||
#include "libipset.h"
|
||||
|
||||
#define CACHE_TTL 600 // 设定缓存的存活时间为 600 秒 (10 分钟)
|
||||
#define MAX_CACHE_SIZE 100 // 缓存最多存储 100 个 IP 地址
|
||||
|
||||
struct ip_cache_node *ip_cache_head = NULL; // 缓存链表的头节点
|
||||
int cache_size = 0; // 当前缓存中的 IP 数量
|
||||
|
||||
pid_t pid = -1;
|
||||
|
||||
pid_t pid = -1; // 子进程全局PID
|
||||
#define SHM_SIZE 1024 // 共享内存大小
|
||||
#define SHM_KEY 1234 // 共享内存键值
|
||||
int shmid = -1;
|
||||
int RULE_NAME_NUMBER = 0;
|
||||
char *RULE_NAME = NULL;
|
||||
int RULE_NAME_NUMBER = 0; // ipset 集合集合数
|
||||
char *RULE_NAME = NULL; // 共享内存
|
||||
char *ip2region_area = NULL; // ip2region 解析结果
|
||||
char *command_result = NULL; // 执行命令的结果
|
||||
|
||||
char *ip2region_area = NULL; // ip2region 解析结果
|
||||
char *command_result = NULL; // 执行命令的结果
|
||||
#define CACHE_TTL 600 // 设定缓存的存活时间为 600 秒 (10 分钟)
|
||||
#define MAX_CACHE_SIZE 100 // 缓存最多存储 100 个 IP 地址
|
||||
struct ip_cache_node *ip_cache_head = NULL; // 缓存链表的头节点
|
||||
int cache_size = 0; // 当前缓存中的 IP 数量
|
||||
|
||||
// 定义链表结构,用于缓存 IP 地址
|
||||
struct ip_cache_node {
|
||||
@@ -26,6 +24,7 @@ struct ip_cache_node {
|
||||
struct ip_cache_node *next; // 指向下一个节点
|
||||
};
|
||||
|
||||
|
||||
// 检查 IP 是否已在缓存中并是否过期
|
||||
int is_ip_in_cache(const char *ip)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user