优化Firewalld添加端口方法,自动聚合连续的端口号

This commit is contained in:
刘祥超
2022-07-21 11:53:23 +08:00
parent 25c11f3d69
commit 62f9d1f09a
4 changed files with 156 additions and 37 deletions

View File

@@ -12,3 +12,15 @@ func TestParseAddrHost(t *testing.T) {
t.Log(addr + " => " + utils.ParseAddrHost(addr))
}
}
func TestMergePorts(t *testing.T) {
for _, ports := range [][]int{
{},
{80},
{80, 83, 85},
{80, 81, 83, 85, 86, 87, 88, 90},
{0, 0, 1, 1, 2, 2, 2, 3, 3, 3},
} {
t.Log(ports, "=>", utils.MergePorts(ports))
}
}