diff --git a/README.md b/README.md
index 3edfd89..b70ddac 100644
--- a/README.md
+++ b/README.md
@@ -35,6 +35,7 @@
- Geoip2 城市数据库 (可选)
- IPIP 数据库 (可选)
- ip2region 数据库 (可选)
+ - DB-IP 数据库 (可选)
- CDN 服务提供商查询
- 支持管道处理
- 支持交互式查询
@@ -51,7 +52,7 @@
Nali 需要预先安装 Go >= 1.18. 安装后可以从源码安装软件:
```sh
-$ go install github.com/zu1k/nali
+$ go install github.com/zu1k/nali@latest
```
### 下载预编译的可执行程序
@@ -177,6 +178,26 @@ Address: 2001:428:6402:21b::6 [美国Louisiana州Monroe Qwest Communications Com
## 用户交互
+程序第一次运行后,会在工作目录生成配置文件 `config.yaml` (默认`~/.nali/config.yaml`),配置文件定义了数据库信息,默认用户无需进行修改
+
+数据库格式默认如下:
+
+```yaml
+- name: geoip
+ name-alias:
+ - geolite
+ - geolite2
+ format: mmdb
+ file: GeoLite2-City.mmdb
+ languages:
+ - ALL
+ types:
+ - IPv4
+ - IPv6
+```
+
+其中,`languages` 和 `types` 表示该数据库支持的语言和查询类型。 如果你需要增加数据库,需小心修改配置文件,如果有任何问题,欢迎提 issue 询问。
+
### 查看帮助
```
@@ -187,7 +208,7 @@ Usage:
Available Commands:
help Help about any command
- update update chunzhen ip database
+ update update qqwry, zxipv6wry, ip2region ip database and cdn
Flags:
-h, --help help for nali
@@ -198,22 +219,33 @@ Use "nali [command] --help" for more information about a command.
### 更新数据库
+更新所有可以自动更新的数据库
+
```
$ nali update
2020/07/17 12:53:46 正在下载最新纯真 IP 库...
2020/07/17 12:54:05 已将最新的纯真 IP 库保存到本地 /root/.nali/qqwry.dat
```
+或者指定数据库
+
+```
+$ nali update --db qqwry,cdn
+2020/07/17 12:53:46 正在下载最新纯真 IP 库...
+2020/07/17 12:54:05 已将最新的纯真 IP 库保存到本地 /root/.nali/qqwry.dat
+```
+
### 自选数据库
用户可以指定使用哪个数据库,需要设置环境变量: `NALI_DB_IP4`、`NALI_DB_IP6` 或者两个同时设置
支持的变量内容:
-- Geoip2 `['geoip', 'geoip2', 'geo']`
-- Chunzhen `['chunzhen', 'qqip', 'qqwry']`
-- IPIP `['ipip', 'ipipfree', 'ipip.net']`
-- Ip2Resion `['ip2region', 'region', 'i2r']`
+- Geoip2 `['geoip', 'geoip2']`
+- Chunzhen `['chunzhen', 'qqwry']`
+- IPIP `['ipip']`
+- Ip2Resion `['ip2region', 'i2r']`
+- DBIP `['dbip', 'db-ip']`
#### Windows平台
@@ -262,18 +294,18 @@ export NALI_DB_IP4=ipip
1.1.1.1 [Australia]
```
-### 更换数据库目录
+### 更换工作目录
如果未指定数据库存放目录,数据库默认将存放在 `~/.nali`
-设置环境变量 `NALI_DB_HOME` 来指定数据库目录
+设置环境变量 `NALI_HOME` 来指定工作目录,数据库存放在工作目录下。也可在配置文件中使用绝对路径指定其他数据库路径。
```
-set NALI_DB_HOME=D:\nalidb
+set NALI_HOME=D:\nali
or
-export NALI_DB_HOME=/home/nali
+export NALI_HOME=/var/nali
```
## 感谢列表
@@ -301,7 +333,7 @@ export NALI_DB_HOME=/home/nali
**Nali** © [zu1k](https://github.com/zu1k), 遵循 [MIT](./LICENSE) 证书.
-> Blog [@zu1k](https://zu1k.com) · GitHub [@zu1k](https://github.com/zu1k) · Twitter [@zu1k_lv](https://twitter.com/zu1k_lv) · Telegram Channel [@peekfun](https://t.me/peekfun)
+> Blog [zu1k.com](https://zu1k.com) · GitHub [@zu1k](https://github.com/zu1k) · Twitter [@zu1k_lv](https://twitter.com/zu1k_lv) · Telegram Channel [@peekfun](https://t.me/peekfun)
## Star统计
diff --git a/README_en.md b/README_en.md
index 1c9cbd3..41063c4 100644
--- a/README_en.md
+++ b/README_en.md
@@ -34,6 +34,7 @@ However the C version has too few functions, and the js version is too big and t
- Geoip2 city database
- IPIP free database
- ip2region database
+ - db-ip database
- Pipeline support
- Interactive query
- Offline query
@@ -50,7 +51,7 @@ However the C version has too few functions, and the js version is too big and t
Nali Requires Go >= 1.18. You can build it from source:
```sh
-$ go install github.com/zu1k/nali
+$ go install github.com/zu1k/nali@latest
```
### Install pre-build binariy
@@ -170,6 +171,24 @@ Address: 2001:428:6402:21b::6 [美国Louisiana州Monroe Qwest Communications Com
## Interface
+After nali runs for the first time, a configuration file `config.yaml` will be generated in the working directory (default `~/.nali/config.yaml`), the configuration file defines the database information.
+
+A database is defined as the follows:
+
+```yaml
+- name: geoip
+ name-alias:
+ - geolite
+ - geolite2
+ format: mmdb
+ file: GeoLite2-City.mmdb
+ languages:
+ - ALL
+ types:
+ - IPv4
+ - IPv6
+```
+
### Help
```
@@ -192,22 +211,33 @@ Use "nali [command] --help" for more information about a command.
### Update database
+Update all databases if avaliable:
+
```
$ nali update
2020/07/17 12:53:46 正在下载最新纯真 IP 库...
2020/07/17 12:54:05 已将最新的纯真 IP 库保存到本地 /root/.nali/qqwry.dat
```
+Updata selected databases:
+
+```
+$ nali update --db qqwry,cdn
+2020/07/17 12:53:46 正在下载最新纯真 IP 库...
+2020/07/17 12:54:05 已将最新的纯真 IP 库保存到本地 /root/.nali/qqwry.dat
+```
+
### Select database
Users can specify which database to use, set environment variables `NALI_DB_IP4`, `NALI_DB_IP6` or both.
supported database:
-- Geoip2 `['geoip', 'geoip2', 'geo']`
-- Chunzhen `['chunzhen', 'qqip', 'qqwry']`
-- IPIP `['ipip', 'ipipfree', 'ipip.net']`
-- Ip2Resion `['ip2region', 'region', 'i2r']`
+- Geoip2 `['geoip', 'geoip2']`
+- Chunzhen `['chunzhen', 'qqwry']`
+- IPIP `['ipip']`
+- Ip2Resion `['ip2region', 'i2r']`
+- - DBIP `['dbip', 'db-ip']`
#### Windows
@@ -260,14 +290,14 @@ The values that can be set for this parameter can be found in the list of suppor
If the database directory is not specified, the database will be placed in `~/.nali`
-Set environment variables `NALI_DB_HOME` to specify the database directory
+Set environment variables `NALI_HOME` to specify the working directory
```
-set NALI_DB_HOME=D:\nalidb
+set NALI_HOME=D:\nalidb
or
-export NALI_DB_HOME=/home/nali
+export NALI_HOME=/home/nali
```
## Thanks
@@ -295,7 +325,7 @@ Thanks to JetBrains for the Open Source License
**Nali** © [zu1k](https://github.com/zu1k), Released under the [MIT](./LICENSE) License.
-> Blog [@zu1k](https://zu1k.com) · GitHub [@zu1k](https://github.com/zu1k) · Twitter [@zu1k_lv](https://twitter.com/zu1k_lv) · Telegram Channel [@peekfun](https://t.me/peekfun)
+> Blog [zu1k.com](https://zu1k.com) · GitHub [@zu1k](https://github.com/zu1k) · Twitter [@zu1k_lv](https://twitter.com/zu1k_lv) · Telegram Channel [@peekfun](https://t.me/peekfun)
## Stargazers over time
diff --git a/internal/db/default.go b/internal/db/default.go
index 2c5c129..8899a28 100644
--- a/internal/db/default.go
+++ b/internal/db/default.go
@@ -2,17 +2,6 @@ package db
func GetDefaultDBList() List {
return List{
- &DB{
- Name: "geoip",
- NameAlias: []string{
- "geolite",
- "geolite2",
- },
- Format: FormatMMDB,
- File: "GeoLite2-City.mmdb",
- Languages: LanguagesAll,
- Types: TypesIP,
- },
&DB{
Name: "qqwry",
NameAlias: []string{
@@ -34,6 +23,28 @@ func GetDefaultDBList() List {
Languages: LanguagesZH,
Types: TypesIPv6,
},
+ &DB{
+ Name: "geoip",
+ NameAlias: []string{
+ "geoip2",
+ "geolite",
+ "geolite2",
+ },
+ Format: FormatMMDB,
+ File: "GeoLite2-City.mmdb",
+ Languages: LanguagesAll,
+ Types: TypesIP,
+ },
+ &DB{
+ Name: "dbip",
+ NameAlias: []string{
+ "db-ip",
+ },
+ Format: FormatMMDB,
+ File: "dbip.mmdb",
+ Languages: LanguagesAll,
+ Types: TypesIP,
+ },
&DB{
Name: "ipip",
Format: FormatIPIP,