新版IP库管理阶段性提交(未完成)

This commit is contained in:
刘祥超
2022-08-13 23:55:59 +08:00
parent 507457dec1
commit 4ddc1ac89f
42 changed files with 10035 additions and 3582 deletions

View File

@@ -0,0 +1,37 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package iplibrary_test
import (
"github.com/TeaOSLab/EdgeCommon/pkg/iplibrary"
"net"
"testing"
)
func TestNewFileReader(t *testing.T) {
reader, err := iplibrary.NewFileReader("./ip.db")
if err != nil {
t.Fatal(err)
}
for _, ip := range []string{
"127.0.0.1",
"192.168.0.1",
"192.168.0.150",
"192.168.1.100",
"192.168.2.100",
"192.168.3.50",
"192.168.0.150",
"192.168.4.80",
"8.8.8.8",
"111.197.165.199",
"175.178.206.125",
} {
var result = reader.Lookup(net.ParseIP(ip))
if result.IsOk() {
t.Log(ip+":", "countryId:", result.CountryId(), "provinceId:", result.ProvinceId(), "cityId:", result.CityId(), "provider:", result.ProviderId())
} else {
t.Log(ip+":", "not found")
}
}
}