增加二进制文件包含必要资源文件功能

This commit is contained in:
2025-06-06 14:52:46 +08:00
parent dc5039d08d
commit 28aae5cec3
4 changed files with 84 additions and 16 deletions

12
main.go
View File

@@ -30,7 +30,7 @@ var (
Protocol *string // BPF 过滤器
IPSET_NUMBER int // 当前使用的 ipset 集合编号
MAX_IPSET_NAME = 12 // 最大 ipset 集合数量
MAX_IPSET_NAME = 100 // 最大 ipset 集合数量
IPSET_NAME string // 当前使用的 ipset 集合名称
IpList = list.New() // 存储 IPv4 地址的链表
@@ -350,7 +350,7 @@ func RunMainProcess() { // 主进程逻辑
// 遍历 ProcessedIPMap检查每个 IP 的记录是否已超过 24 小时
for ip, t := range ProcessedIPMap {
// 如果当前时间减去记录时间大于 1 小时,则删除该条目
if now.Sub(t) > 10*time.Minute {
if now.Sub(t) > 30*time.Minute {
delete(ProcessedIPMap, ip)
}
}
@@ -366,7 +366,7 @@ func RunMainProcess() { // 主进程逻辑
// 启动防火墙管理
go func() {
for {
if ipset_len, _ := NumIPSet(IPSET_NAME); ipset_len >= 65534 {
if ipset_len, _ := NumIPSet(IPSET_NAME); ipset_len >= 65535 {
log.Printf("\033[31m ipset %s 列表已满 %d \033[0m\n", IPSET_NAME, ipset_len)
// 创建新的 ipset 集合
@@ -384,7 +384,7 @@ func RunMainProcess() { // 主进程逻辑
}
time.Sleep(7 * time.Second)
time.Sleep(3 * time.Second)
}
}()
@@ -408,7 +408,7 @@ func HandleCmd() {
if help {
fmt.Printf(
"\t\tDenyip firewall\n" +
"\tVersion 0.1\n" +
"\tVersion 0.2\n" +
"\tE-mail: aixiao@aixiao.me\n" +
"\tDate: 20250102\n")
@@ -456,6 +456,8 @@ func main() {
runtime.GOMAXPROCS(runtime.NumCPU()) // 设置最大CPU核数
HandleCmd()
embed_ip2region()
// 守护进程模式
if *daemon {
StartDaemon()