Serialize rule writes and add tests

This commit is contained in:
2026-04-17 10:21:37 +08:00
parent 66c25b06a7
commit eb8c76492c
7 changed files with 682 additions and 35 deletions

View File

@@ -6,6 +6,7 @@
- 仅管理本工具创建的 `MGMT:<UUID>` 规则。
- 支持 TCP / UDP / both支持 IPv4 / IPv6 / both。
- 支持 `iptables-persistent` / `netfilter-persistent save` 持久化。
- 所有写操作通过 `flock` 串行化,降低多实例并发竞争风险。
- 附带单元测试与真实 iptables 集成测试。
## 目录结构
@@ -143,7 +144,7 @@ tests/run_all.sh --skip-integration
- `tests/test_common.sh`:输入校验
- `tests/test_storage.sh`:规则存储
- `tests/test_env_check.sh`:环境检查与修复
- `tests/test_rules_unit.sh`mock iptables 下的增删回滚
- `tests/test_rules_unit.sh`mock iptables 下的增删回滚与并发写保护
- `tests/test_integration.sh`:真实 iptables 生命周期 + save/reload 持久化回放测试
`tests/test_integration.sh` 的执行策略: