简化IP名单中创建IP操作/支持IP以CIDR方式显示

This commit is contained in:
GoEdgeLab
2024-04-13 16:45:56 +08:00
parent 58e508c8e3
commit 7e4a5ecff7
11 changed files with 544 additions and 411 deletions

21
pkg/iputils/cidr_test.go Normal file
View File

@@ -0,0 +1,21 @@
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
package iputils_test
import (
"github.com/TeaOSLab/EdgeCommon/pkg/iputils"
"testing"
)
func TestParseCIDR(t *testing.T) {
for _, cidrString := range []string{
"192.168.2.100/24",
"2607:5300:203:afac::/125",
} {
cidr, err := iputils.ParseCIDR(cidrString)
if err != nil {
t.Fatal(err)
}
t.Log(cidr, "=> [", cidr.From(), "-", cidr.To(), "]")
}
}