mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-12-10 03:40:24 +08:00
支持规则集忽略局域网IP
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package utils
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"github.com/iwind/TeaGo/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestIP2Long(t *testing.T) {
|
||||
t.Log(IP2Long("0.0.0.0"))
|
||||
@@ -10,3 +13,16 @@ func TestIP2Long(t *testing.T) {
|
||||
t.Log(IP2Long("2001:db8:0:1::102"))
|
||||
t.Log(IP2Long("::1"))
|
||||
}
|
||||
|
||||
func TestIsLocalIP(t *testing.T) {
|
||||
var a = assert.NewAssertion(t)
|
||||
a.IsFalse(IsLocalIP("a"))
|
||||
a.IsFalse(IsLocalIP("1.2.3"))
|
||||
a.IsTrue(IsLocalIP("127.0.0.1"))
|
||||
a.IsTrue(IsLocalIP("192.168.0.1"))
|
||||
a.IsTrue(IsLocalIP("10.0.0.1"))
|
||||
a.IsTrue(IsLocalIP("172.16.0.1"))
|
||||
a.IsTrue(IsLocalIP("::1"))
|
||||
a.IsFalse(IsLocalIP("::1:2:3"))
|
||||
a.IsFalse(IsLocalIP("8.8.8.8"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user