wsy182 6df8136e1b feat(core): 添加IP地址检测服务核心功能
- 实现配置文件加载和解析功能,支持服务器、MMDB数据库和日志配置
- 集成GeoLite2城市数据库查询,提供IP地理位置信息查询服务
- 添加私有IP地址检测逻辑,过滤本地网络地址段
- 构建HTTP路由处理器,返回JSON格式的IP位置信息
- 配置默认启动参数和错误处理机制
- 集成日志系统,记录请求处理过程和错误信息
2026-02-02 17:20:51 +08:00
2024-08-28 16:55:15 +08:00

CheckIP

相关命令

构建Linux二进制文件

GOOS=linux GOARCH=amd64 go build main.go

docker配置反向代理

docker run --name nginx -p 8888:8888 -d nginx

数据库文件下载地址

https://www.maxmind.com/en/account/login

数据库使用

https://github.com/IncSW/geoip2

构建项目Windows二进制文件

GOOS=windows GOARCH=amd64 go build

数据库文件转换网址

https://dev.maxmind.com/geoip/docs/databases/city-and-country

官方转换工具

转换工具地址

https://github.com/maxmind/geoip2-csv-converter

Windows转换命令

.\geoip2-csv-converter.exe -block-file GeoLite2-City-Blocks-IPv4.csv -include-range -output-file GeoLite2-City-Blocks-IPv4-string.csv

转换为16进制

.\geoip2-csv-converter.exe -block-file GeoLite2-City-Blocks-IPv4.csv -include-hex-range -output-file GeoLite2-City-Blocks-IPv4-hex.csv

Linux转换命令

./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字段没有值

Description
No description provided
Readme 191 MiB
Languages
Go 100%