diff --git a/README.md b/README.md index b70ddac..3530e82 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ - IPIP 数据库 (可选) - ip2region 数据库 (可选) - DB-IP 数据库 (可选) + - IP2Location DB3 LITE 数据库 (可选) - CDN 服务提供商查询 - 支持管道处理 - 支持交互式查询 @@ -246,6 +247,7 @@ $ nali update --db qqwry,cdn - IPIP `['ipip']` - Ip2Resion `['ip2region', 'i2r']` - DBIP `['dbip', 'db-ip']` +- IP2Location `['ip2location']` #### Windows平台 @@ -320,6 +322,7 @@ export NALI_HOME=/var/nali - [IPIP数据库](https://www.ipip.net/product/ip.html) - [IPIP数据库解析](https://github.com/ipipdotnet/ipdb-go) - [ip2region数据库](https://github.com/lionsoul2014/ip2region) +- [IP2Location DB3 LITE](https://lite.ip2location.com/database/db3-ip-country-region-city) - [Cobra CLI库](https://github.com/spf13/cobra) - [Nali-cli](https://github.com/SukkaW/nali-cli) diff --git a/README_en.md b/README_en.md index a3520e3..d6131a7 100644 --- a/README_en.md +++ b/README_en.md @@ -238,7 +238,7 @@ supported database: - Chunzhen `['chunzhen', 'qqwry']` - IPIP `['ipip']` - Ip2Resion `['ip2region', 'i2r']` -- - DBIP `['dbip', 'db-ip']` +- DBIP `['dbip', 'db-ip']` - IP2Location `['ip2location']` #### Windows diff --git a/internal/db/default.go b/internal/db/default.go index 9a43b74..d16de94 100644 --- a/internal/db/default.go +++ b/internal/db/default.go @@ -63,7 +63,7 @@ func GetDefaultDBList() List { Types: TypesIPv4, }, &DB{ - Name: "ip2location", + Name: "ip2location", Format: FormatIP2Location, File: "IP2LOCATION-LITE-DB3.IPV6.BIN", Languages: LanguagesAll, diff --git a/internal/db/type.go b/internal/db/type.go index c5cf9fd..022c841 100644 --- a/internal/db/type.go +++ b/internal/db/type.go @@ -6,11 +6,11 @@ import ( "github.com/zu1k/nali/pkg/cdn" "github.com/zu1k/nali/pkg/dbif" "github.com/zu1k/nali/pkg/geoip" + "github.com/zu1k/nali/pkg/ip2location" "github.com/zu1k/nali/pkg/ip2region" "github.com/zu1k/nali/pkg/ipip" "github.com/zu1k/nali/pkg/qqwry" "github.com/zu1k/nali/pkg/zxipv6wry" - "github.com/zu1k/nali/pkg/ip2location" ) type DB struct { @@ -61,11 +61,11 @@ func (d *DB) get() (db dbif.DB) { type Format string const ( - FormatMMDB Format = "mmdb" - FormatQQWry = "qqwry" - FormatZXIPv6Wry = "zxipv6wry" - FormatIPIP = "ipip" - FormatIP2Region = "ip2region" + FormatMMDB Format = "mmdb" + FormatQQWry = "qqwry" + FormatZXIPv6Wry = "zxipv6wry" + FormatIPIP = "ipip" + FormatIP2Region = "ip2region" FormatIP2Location = "ip2location" FormatCDNSkkYml = "cdn-skk-yml" diff --git a/pkg/dbif/db.go b/pkg/dbif/db.go index e5b8040..c6a7bdf 100644 --- a/pkg/dbif/db.go +++ b/pkg/dbif/db.go @@ -5,11 +5,11 @@ import ( "github.com/zu1k/nali/pkg/cdn" "github.com/zu1k/nali/pkg/geoip" + "github.com/zu1k/nali/pkg/ip2location" "github.com/zu1k/nali/pkg/ip2region" "github.com/zu1k/nali/pkg/ipip" "github.com/zu1k/nali/pkg/qqwry" "github.com/zu1k/nali/pkg/zxipv6wry" - "github.com/zu1k/nali/pkg/ip2location" ) type QueryType uint diff --git a/pkg/ip2location/ip2locationdb.go b/pkg/ip2location/ip2locationdb.go index 5cd1ab1..cd9f901 100644 --- a/pkg/ip2location/ip2locationdb.go +++ b/pkg/ip2location/ip2locationdb.go @@ -23,7 +23,7 @@ func NewIP2LocationDB(filePath string) (*IP2LocationDB, error) { return nil, err } else { db, err := ip2location.OpenDB(filePath) - + if err != nil { log.Fatal(err) } @@ -37,7 +37,7 @@ func (x IP2LocationDB) Find(query string, params ...string) (result fmt.Stringer return nil, errors.New("Query should be valid IP") } record, err := x.db.Get_all(ip.String()) - + if err != nil { return }