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

可以支持查询国内和国外ip时分别指派不同的ip库吗 #24

Open
darvenking opened this issue Feb 6, 2024 · 1 comment
Open

Comments

@darvenking
Copy link

今天看到这个项目非常惊艳,感谢作者的开源付出

可以支持查询国内和国外ip时分别指派不同的ip库吗,比如国内的走纯真,国外的走GEO2lite

@sjzar
Copy link
Owner

sjzar commented Feb 7, 2024

很高兴这个项目能够帮助到你 :)

关于你提到的海内外使用不同 IP 库的需求,由于 “国家” 字段同样是 IP 数据库内容的一部分,不同数据库的信息会存在差异,所以基于任一 IP 数据库做海内外判断都可能有误差。

我的建议是尝试用 hybrid-mode 同时查询两个数据库的信息,并自行实现业务逻辑判断。
请参考相关文档:https://github.com/sjzar/ips/blob/main/docs/config.md#hybrid_mode

示例:
1. 下载 qqwry.dat & GeoLite2 数据库
    ips download qqwry.dat
    ips download GeoLite2-City.mmdb

2. 使用 hybrid-mode 查询 2 个数据库
    ips -i .ips/qqwry.dat -i .ips/GeoLite2-City.mmdb 12.12.12.12 -f '*' -j
    {"items":[{"ip":"12.12.12.12","net":"12.11.140.0/22","data":{"0_country":"美国","0_isp":"AT","1_accuracy_radius":"1000","1_city":"","1_continent":"北美洲","1_country":"美国","1_latitude":"37.751000","1_longitude":"-97.822000","1_province":"","1_registered_country":"美国","1_utcOffset":"America/Chicago"}}]}

    ips -i .ips/qqwry.dat -i .ips/GeoLite2-City.mmdb -f '*'  123.123.123.123 -j
    {"items":[{"ip":"123.123.123.123","net":"123.123.123.0/24","data":{"0_country":"中国","0_isp":"联通","1_accuracy_radius":"1000","1_city":"北京","1_continent":"亚洲","1_country":"中国","1_latitude":"39.911000","1_longitude":"116.395000","1_province":"北京","1_registered_country":"中国","1_utcOffset":"Asia/Shanghai"}}]}

命令中的多个 -i 参数会同时生效,使用 -f '*' 检查所有的数据库字段,第一个数据库的字段以 0_ 作为前缀,第二个数据库的字段以 1_ 作为前缀。

希望可以帮助到你~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants