mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-12-07 23:30:25 +08:00
简化IP名单中创建IP操作/支持IP以CIDR方式显示
This commit is contained in:
21
pkg/iputils/cidr_test.go
Normal file
21
pkg/iputils/cidr_test.go
Normal 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(), "]")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user