mirror of
https://github.com/zu1k/nali.git
synced 2025-02-02 18:32:43 +08:00
parent
1e116c8e70
commit
4e22a5cf2b
10
README.md
10
README.md
@ -45,10 +45,10 @@ However the C version has too few functions, and the js version is too big and t
|
|||||||
|
|
||||||
### Install from source
|
### Install from source
|
||||||
|
|
||||||
Nali Requires Go >= 1.14. You can build it from source:
|
Nali Requires Go >= 1.18. You can build it from source:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ go get -u -v github.com/zu1k/nali
|
$ go install github.com/zu1k/nali
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install pre-build binariy
|
### Install pre-build binariy
|
||||||
@ -57,12 +57,6 @@ Pre-built binaries are available here: [release](https://github.com/zu1k/nali/re
|
|||||||
|
|
||||||
Download the binary compatible with your platform, unpack and copy to the directory in path
|
Download the binary compatible with your platform, unpack and copy to the directory in path
|
||||||
|
|
||||||
### Install from docker
|
|
||||||
|
|
||||||
```
|
|
||||||
docker pull docker.pkg.github.com//zu1k/nali/nali:latest
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Query a simple IP address
|
### Query a simple IP address
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
Nali 需要预先安装 Go. 安装后可以从源码安装软件:
|
Nali 需要预先安装 Go. 安装后可以从源码安装软件:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ go get -u -v github.com/zu1k/nali
|
$ go install github.com/zu1k/nali
|
||||||
```
|
```
|
||||||
|
|
||||||
### 下载预编译的可执行程序
|
### 下载预编译的可执行程序
|
||||||
@ -56,12 +56,6 @@ $ go get -u -v github.com/zu1k/nali
|
|||||||
|
|
||||||
你需要选择适合你系统和硬件架构的版本下载,解压后可直接运行
|
你需要选择适合你系统和硬件架构的版本下载,解压后可直接运行
|
||||||
|
|
||||||
### 使用 Docker 版本
|
|
||||||
|
|
||||||
```
|
|
||||||
docker pull docker.pkg.github.com//zu1k/nali/nali:latest
|
|
||||||
```
|
|
||||||
|
|
||||||
## 使用说明
|
## 使用说明
|
||||||
|
|
||||||
### 查询一个IP的地理信息
|
### 查询一个IP的地理信息
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package entity
|
package entity
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/netip"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/zu1k/nali/internal/db"
|
"github.com/zu1k/nali/internal/db"
|
||||||
@ -23,12 +24,21 @@ func ParseLine(line string) Entities {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
for _, e := range ip6sLoc {
|
for _, e := range ip6sLoc {
|
||||||
|
text := line[e[0]:e[1]]
|
||||||
|
if ip, _ := netip.ParseAddr(text); ip.Is4In6() {
|
||||||
|
tmp = append(tmp, &Entity{
|
||||||
|
Loc: e,
|
||||||
|
Type: TypeIPv4,
|
||||||
|
Text: ip.Unmap().String(),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
tmp = append(tmp, &Entity{
|
tmp = append(tmp, &Entity{
|
||||||
Loc: e,
|
Loc: e,
|
||||||
Type: TypeIPv6,
|
Type: TypeIPv6,
|
||||||
Text: line[e[0]:e[1]],
|
Text: text,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for _, e := range domainsLoc {
|
for _, e := range domainsLoc {
|
||||||
tmp = append(tmp, &Entity{
|
tmp = append(tmp, &Entity{
|
||||||
Loc: e,
|
Loc: e,
|
||||||
|
@ -6,5 +6,5 @@ var (
|
|||||||
DomainRe = regexp.MustCompile(`([a-zA-Z0-9][-a-zA-Z0-9]{0,62}\.)+([a-zA-Z][-a-zA-Z]{0,62})`)
|
DomainRe = regexp.MustCompile(`([a-zA-Z0-9][-a-zA-Z0-9]{0,62}\.)+([a-zA-Z][-a-zA-Z]{0,62})`)
|
||||||
|
|
||||||
IPv4Re = regexp.MustCompile(`(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}`)
|
IPv4Re = regexp.MustCompile(`(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}`)
|
||||||
IPv6Re = regexp.MustCompile(`fe80:(:[0-9a-fA-F]{1,4}){0,4}(%\w+)?|([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|(([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4})?::(([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4})?`)
|
IPv6Re = regexp.MustCompile(`fe80:(:[0-9a-fA-F]{1,4}){0,4}(%\w+)?|([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::[fF]{4}:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}|(([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4})?::(([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4})?`)
|
||||||
)
|
)
|
||||||
|
@ -21,3 +21,17 @@ func TestDomainRe(t *testing.T) {
|
|||||||
fmt.Println(DomainRe.FindAllString(domain, -1))
|
fmt.Println(DomainRe.FindAllString(domain, -1))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var validIPv6List = []string{
|
||||||
|
"::ffff:104.26.11.119",
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestIPv6Re(t *testing.T) {
|
||||||
|
for _, ip := range validIPv6List {
|
||||||
|
if !IPv6Re.MatchString(ip) {
|
||||||
|
t.Error(ip)
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
fmt.Println(IPv6Re.FindAllString(ip, -1))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user