Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【开源自荐】ips - IP 地理位置数据库工具 #3631

Closed
sjzar opened this issue Nov 15, 2023 · 0 comments
Closed

【开源自荐】ips - IP 地理位置数据库工具 #3631

sjzar opened this issue Nov 15, 2023 · 0 comments
Labels

Comments

@sjzar
Copy link

sjzar commented Nov 15, 2023

IPS

简介

ips 是一个命令行工具与库,可以轻松完成 IP 地理位置数据库的查询、转存与打包。

特性

  • 一键查询、转存和打包 IP 地理位置数据库
  • 兼容多种数据库格式
  • 通过命令行参数或管道进行查询
  • 输出支持文本和 JSON 格式
  • 可自定义查询字段并持久化配置
  • 灵活的数据库字段改写:按需增减字段和内容修改

项目地址

https://github.com/sjzar/ips

使用文档

https://github.com/sjzar/ips/blob/main/docs/usage.md

使用案例

压缩数据库体积

目前商业 IP 数据库通常包含大量详细信息,例如某家数据库文件大小超过 600MB,在分发和使用时造成不便;

可以通过 ips 选取字段后 重新打包 IP 数据库,在保留国内城市运营商、海外国家粒度信息的情况下,减少 98% 的体积。

具体命令请参考这篇文档

制作自定义数据库

各类分流工具依赖 IP 归属地做分流策略,可以使用 ips 轻松重新打包 mmdb 文件 ,例如:

$ ips pack -i GeoLite2-City.mmdb -f 'country|country=!中国:country=' -o geoip2-cn.mmdb --output-option "select_languages=-"

$ ll
-rw-r--r--  1 sarv  staff    68M 10 20 12:43 GeoLite2-City.mmdb
-rw-r--r--  1 sarv  staff   323K 11 15 14:20 geoip2-cn.mmdb
@ruanyf ruanyf added the weekly label Nov 15, 2023
@sjzar sjzar closed this as completed Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants
-