实现IP黑白名单、国家|地区封禁、省份封禁

This commit is contained in:
刘祥超
2020-11-09 10:45:44 +08:00
parent 0a2b2d9fe9
commit 5682c9ba3e
34 changed files with 1354 additions and 8 deletions

View File

@@ -0,0 +1,21 @@
package iplibrary
import (
"runtime"
"testing"
)
func TestIP2Long(t *testing.T) {
t.Log(IP2Long("192.168.1.100"))
t.Log(IP2Long("192.168.1.101"))
t.Log(IP2Long("202.106.0.20"))
t.Log(IP2Long("192.168.1")) // wrong ip, should return 0
}
func BenchmarkIP2Long(b *testing.B) {
runtime.GOMAXPROCS(1)
for i := 0; i < b.N; i++ {
_ = IP2Long("192.168.1.100")
}
}