check_ip/README.md

99 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# CheckIP
## 相关命令
### scp上传到服务器
上传到 J425
```bash
scp -P 8332 /Users/wangsiyuan/Documents/Project/GoProject/checkIP/* root@52.221.48.219:/data/check_ip
```
上传到AWS
```bash
scp -r /Users/wangsiyuan/Documents/Project/GoProject/checkIP/* root@52.221.48.219:/data/check_ip
```
### 构建Linux二进制文件
```
GOOS=linux GOARCH=amd64 go build main.go
```
### docker配置反向代理
```shell
docker run --name nginx -p 8888:8888 -d nginx
```
### 数据库文件下载地址
```bash
https://www.maxmind.com/en/account/login
```
### 数据库使用
```
https://github.com/IncSW/geoip2
```
### 构建项目Windows二进制文件
```bash
GOOS=windows GOARCH=amd64 go build
```
### 数据库文件转换网址
```http
https://dev.maxmind.com/geoip/docs/databases/city-and-country
```
### 官方转换工具
转换工具地址
```bash
https://github.com/maxmind/geoip2-csv-converter
```
Windows转换命令
```bash
.\geoip2-csv-converter.exe -block-file GeoLite2-City-Blocks-IPv4.csv -include-range -output-file GeoLite2-City-Blocks-IPv4-string.csv
```
转换为16进制
```bash
.\geoip2-csv-converter.exe -block-file GeoLite2-City-Blocks-IPv4.csv -include-hex-range -output-file GeoLite2-City-Blocks-IPv4-hex.csv
```
Linux转换命令
```bash
./geoip2-csv-converter -block-file GeoLite2-City-Blocks-IPv4.csv -include-hex-range -output-file GeoIP2-City-Blocks-IPv4-Hex.csv
```
## 文件结构
db----------数据库文件
cmd---------主程序入口
web---------web静态资源
tests-------测试单元
## 注意
英文数据库较完善中文数据库部分city字段没有值