Skip to content

Commit

Permalink
docs: Readme zh-CN first
Browse files Browse the repository at this point in the history
Signed-off-by: zu1k <i@lgf.im>
  • Loading branch information
zu1k committed Mar 3, 2022
1 parent 568c576 commit ed4d190
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 144 deletions.
147 changes: 76 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<br>Nali<br>
</h1>

<h4 align="center">An offline tool for querying IP geographic information and CDN provider.</h4>
<h4 align="center">一个查询IP地理信息和CDN提供商的离线终端工具.</h4>

<p align="center">
<a href="https://github.com/zu1k/nali/actions">
Expand All @@ -16,66 +16,67 @@
</a>
</p>

#### [中文文档](https://github.com/zu1k/nali/blob/master/README_zh-CN.md)
#### [English](https://github.com/zu1k/nali/blob/master/README_en.md)

## Origin
## 来源

Inspired by Nali C version and nali-cli js version.
该工具受 Nali C版本 和 nali-cli js版本的启发.

I want to query the IP geographic information and CDN service provider on the terminal, then found the Nali tool. Nali mean 'where' in Chinese, good name for this kind of tools.
我想要在终端对IP地理信息和CDN服务提供商进行查询,发现了Nali这个工具,Nali与哪里谐音,非常适合这类工具

However the C version has too few functions, and the js version is too big and the supported platforms are not complete, so I rewrite it in golang, add IPv6 support and Geoip2 database.
经过简单的使用,我发现最初的C语言版本功能缺失,而js版本包实在大的恐怖、而支持的平台非常有限,所以我用golang重写了这个工具,在原有功能的基础上增加了对IPv6的支持,并且增加了Geoip2数据库

## Feature

- Multi database support
- Chunzhen qqip database
- ZX ipv6 database
- Geoip2 city database
- IPIP free database
- ip2region database
- Pipeline support
- Interactive query
- Offline query
- Both ipv4 and ipv6 supported
- Multilingual support
- CDN provider query
- Full platform support
- Color print
## 功能

## Install
- 支持多种数据库
- 纯真 IPv4 离线数据库
- ZX IPv6 离线数据库
- Geoip2 城市数据库 (可选)
- IPIP 数据库 (可选)
- ip2region 数据库 (可选)
- CDN 服务提供商查询
- 支持管道处理
- 支持交互式查询
- 同时支持IPv4和IPv6
- 支持多语言
- 查询完全离线
- 全平台支持
- 支持彩色输出

### Install from source
## 安装

Nali Requires Go >= 1.18. You can build it from source:
### 从源码安装

Nali 需要预先安装 Go >= 1.18. 安装后可以从源码安装软件:

```sh
$ go install github.com/zu1k/nali
```

### Install pre-build binariy
### 下载预编译的可执行程序

Pre-built binaries are available here: [release](https://github.com/zu1k/nali/releases)
可以从Release页面下载预编译好的可执行程序: [Release](https://github.com/zu1k/nali/releases)

Download the binary compatible with your platform, unpack and copy to the directory in path
你需要选择适合你系统和硬件架构的版本下载,解压后可直接运行

## Usage
## 使用说明

### Query a simple IP address
### 查询一个IP的地理信息

```
$ nali 1.2.3.4
1.2.3.4 [澳大利亚 APNIC Debogon-prefix网络]
```

#### or use `pipe`
#### 或者 使用 `管道`

```
$ echo IP 6.6.6.6 | nali
IP 6.6.6.6 [美国 亚利桑那州华楚卡堡市美国国防部网络中心]
```

### Query multiple IP addresses
### 同时查询多个IP的地理信息

```
$ nali 1.2.3.4 4.3.2.1 123.23.3.0
Expand All @@ -84,9 +85,9 @@ $ nali 1.2.3.4 4.3.2.1 123.23.3.0
123.23.3.0 [越南 越南邮电集团公司]
```

### Interactive query
### 交互式查询

use `exit` or `quit` to quit
使用 `exit` `quit` 退出查询

```
$ nali
Expand All @@ -99,7 +100,9 @@ $ nali
quit
```

### Use with dig
### `dig` 命令配合使用

需要你系统中已经安装好 dig 程序

```
$ dig nali.lgf.im +short | nali
Expand All @@ -108,7 +111,9 @@ $ dig nali.lgf.im +short | nali
172.67.135.48 [美国 CloudFlare节点]
```

### Use with nslookup
### `nslookup` 命令配合使用

需要你系统中已经安装好 nslookup 程序

```
$ nslookup nali.lgf.im 8.8.8.8 | nali
Expand All @@ -124,19 +129,19 @@ Name: nali.lgf.im
Address: 172.67.135.48 [美国 CloudFlare节点]
```

### Use with any other program
### 与任意程序配合使用

Because nali can read the contents of the `stdin` pipeline, it can be used with any program
因为 nali 支持管道处理,所以可以和任意程序配合使用

```
bash abc.sh | nali
```

Nali will insert ip information after ip
Nali 将在 IP后面插入IP地理信息,CDN域名后面插入CDN服务提供商信息

### IPV6 support
### 支持IPv6

Use like ipv4
和 IPv4 用法完全相同

```
$ nslookup google.com | nali
Expand All @@ -150,7 +155,9 @@ Name: google.com
Address: 2a00:1450:400e:809::200e [荷兰Amsterdam Google Inc. 服务器网段]
```

### Query CDN provider
### 查询 CDN 服务提供商

因为 CDN 服务通常使用 CNAME 的域名解析方式,所以推荐与 `nslookup` 或者 `dig` 配合使用,在已经知道 CNAME 后可单独使用

```
$ nslookup www.gov.cn | nali
Expand All @@ -168,9 +175,9 @@ Name: zgovweb.v.bsgslb.cn [白山云 CDN]
Address: 2001:428:6402:21b::6 [美国Louisiana州Monroe Qwest Communications Company, LLC (CenturyLink)]
```

## Interface
## 用户交互

### Help
### 查看帮助

```
$ nali --help
Expand All @@ -179,88 +186,87 @@ Usage:
nali [command]
Available Commands:
completion generate the autocompletion script for the specified shell
help Help about any command
update update chunzhen ip database
Flags:
--gbk Use GBK decoder
-h, --help help for nali
-h, --help help for nali
-t, --toggle Help message for toggle
Use "nali [command] --help" for more information about a command.
```

### Update database
### 更新数据库

```
$ nali update
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.
用户可以指定使用哪个数据库,需要设置环境变量: `NALI_DB_IP4``NALI_DB_IP6` 或者两个同时设置

supported database:
支持的变量内容:

- Geoip2 `['geoip', 'geoip2', 'geo']`
- Chunzhen `['chunzhen', 'qqip', 'qqwry']`
- IPIP `['ipip', 'ipipfree', 'ipip.net']`
- Ip2Resion `['ip2region', 'region', 'i2r']`

#### Windows
#### Windows平台

##### Use geoip db
##### 使用geoip数据库

```
set NALI_DB_IP4=geoip
or use powershell
或者使用 powershell
$env:NALI_DB_IP4="geoip"
```

##### Use ipip db
##### 使用ipip数据库

```
set NALI_DB_IP6=ipip
or use powershell
或者使用 powershell
$env:NALI_DB_IP6="ipip"
```

#### Linux
#### Linux平台

##### Use geoip db
##### 使用geoip数据库

```
export NALI_DB_IP4=geoip
```

##### Use ipip db
##### 使用ipip数据库

```
export NALI_DB_IP6=ipip
export NALI_DB_IP4=ipip
```

### Multilingual support
### 多语言支持

Specify the language to be used by modifying the environment variable `NALI_LANG`, when using a non-Chinese language only the GeoIP2 database is supported
通过修改环境变量 `NALI_LANG` 来指定使用的语言,当使用非中文语言时仅支持GeoIP2这个数据库

The values that can be set for this parameter can be found in the list of supported databases for GeoIP2
该参数可设置的值见 GeoIP2 这个数据库的支持列表

```
# NALI_LANG=en nali 1.1.1.1
1.1.1.1 [Australia]
```

### Change database directory
### 更换数据库目录

If the database directory is not specified, the database will be placed in `~/.nali`
如果未指定数据库存放目录,数据库默认将存放在 `~/.nali`

Set environment variables `NALI_DB_HOME` to specify the database directory
设置环境变量 `NALI_DB_HOME` 来指定数据库目录

```
set NALI_DB_HOME=D:\nalidb
Expand All @@ -270,7 +276,7 @@ or
export NALI_DB_HOME=/home/nali
```

## Thanks
## 感谢列表

- [纯真QQIP离线数据库](http://www.cz88.net/fox/ipdat.shtml)
- [qqwry mirror](https://qqwry.mirror.noc.one/)
Expand All @@ -285,19 +291,18 @@ export NALI_DB_HOME=/home/nali
- [Cobra CLI库](https://github.com/spf13/cobra)
- [Nali-cli](https://github.com/SukkaW/nali-cli)

Thanks to JetBrains for the Open Source License
感谢 JetBrains 提供开源项目免费License

<a href="https://www.jetbrains.com/?from=nali">
<img src="assets/GoLand.svg">
</a>

## Author
## 作者

**Nali** © [zu1k](https://github.com/zu1k), Released under the [MIT](./LICENSE) License.<br>
**Nali** © [zu1k](https://github.com/zu1k), 遵循 [MIT](./LICENSE) 证书.<br>

> Blog [@zu1k](https://lgf.im) · GitHub [@zu1k](https://github.com/zu1k) · Twitter [@zu1k_lv](https://twitter.com/zu1k_lv) · Telegram Channel [@peekfun](https://t.me/peekfun)

## Stargazers over time
## Star统计

[![Stargazers over time](https://starchart.cc/zu1k/nali.svg)](https://starchart.cc/zu1k/nali)
Loading

0 comments on commit ed4d190

Please sign in to comment.