This commit is contained in:
sushen339
2025-11-18 14:05:51 +08:00
parent fed71d17cf
commit e1ef100119
3 changed files with 42 additions and 12 deletions
BIN
View File
Binary file not shown.
+10 -2
View File
@@ -281,8 +281,16 @@ void show_persist_list(void) {
msg(C_CYAN, "=== 📋 本地持久化封禁列表 ===");
FILE *fp = fopen(PERSIST_FILE, "r");
if (!fp || fseek(fp, 0, SEEK_END) == 0) {
if (fp) fclose(fp);
if (!fp) {
printf("(暂无持久化记录)\n");
return;
}
/* 检查文件是否为空 */
fseek(fp, 0, SEEK_END);
long file_size = ftell(fp);
if (file_size <= 0) {
fclose(fp);
printf("(暂无持久化记录)\n");
return;
}
+23 -1
View File
@@ -186,11 +186,32 @@ void show_subnet_aggregation(void) {
}
}
/* 输出聚合结果,只显示count>=2的 */
/* 输出聚合结果,只显示count>=2的,并去重:如果大段和小段数量相同则只显示小段 */
bool has_output = false;
int show_count = 0;
for (int i = 0; i < agg_count && show_count < 10; ++i) {
if (agg[i].count >= 2) {
/* 检查是否有更小掩码的段具有相同count */
bool skip = false;
if (agg[i].mask == 8) {
for (int j = 0; j < agg_count; ++j) {
if (agg[j].mask > 8 && agg[j].count == agg[i].count &&
strncmp(agg[j].subnet, agg[i].subnet, strlen(agg[i].subnet)) == 0) {
skip = true;
break;
}
}
} else if (agg[i].mask == 16) {
for (int j = 0; j < agg_count; ++j) {
if (agg[j].mask > 16 && agg[j].count == agg[i].count &&
strncmp(agg[j].subnet, agg[i].subnet, strlen(agg[i].subnet)) == 0) {
skip = true;
break;
}
}
}
if (!skip) {
has_output = true;
if (agg[i].mask == 8) {
printf(" - %-18s %s(%d 个)%s\n",
@@ -205,6 +226,7 @@ void show_subnet_aggregation(void) {
show_count++;
}
}
}
if (!has_output) {
printf(" - (散乱分布 IPv4)\n");