sjzar / ips

IP geolocation databases tool and library. IP 地理位置数据库工具。
Apache License 2.0
352 stars 23 forks source link

dump qqwry.ipdb 出错 #26

Closed mili-tan closed 1 month ago

mili-tan commented 1 month ago

我在 dump https://github.com/metowolf/qqwry.ipdbqqwry.ipdb 时遇到了错误

.\ips.exe dump -i .\qqwry.ipdb --loglevel debug

# Dump Time: 2024-05-16 21:41:09
# Fields: country_name,region_name,city_name,owner_domain,isp_domain
# IP Version: 1
# Meta: {"MetaVersion":1,"Format":"ipdb","IPVersion":1,"Fields":["country_name","region_name","city_name","owner_domain","isp_domain"],"FieldAlias":{"city":"city_name","country":"country_name","isp":"isp_domain","province":"region_name"}}
time="2024-05-16T21:41:09+08:00" level=debug msg="StandardDumper Dump2() failed data is not exists" file="dumper.go:121"
time="2024-05-16T21:41:09+08:00" level=debug msg="dumper.Dump error: data is not exists" file="pack.go:93"
time="2024-05-16T21:41:09+08:00" level=fatal msg="data is not exists" file="cmd_dump.go:72"

我也尝试了修改 dump 的 Fields,错误依旧相同。

另外非常感谢您开发出了这么惊艳的工具,感谢您的努力!

sjzar commented 1 month ago

Hi, @mili-tan 你好呀。

看了你的问题,应该是 @metowolf 大佬的 qqwry.ipdb 在 0.0.0.0/8 这个 CIDR 没有写入数据导致的。 可以通过以下命令简单复现:

$ wget https://unpkg.com/qqwry.raw.ipdb/qqwry.ipdb

$ ips -i qqwry.raw.ipdb 0.255.0.0
FATA[2024-05-21T21:40:52+08:00] data is not exists

$ ips -i qqwry.raw.ipdb 1.0.0.0
1.0.0.0 [美国]

对于这个问题,可以尝试将数据源更换为 @metowolf 大佬分享的 qqwry.dat 数据源。 如果需要 ipdb 格式的 IP 库文件,可以尝试使用 ips 工具进行重新打包:

$ wget https://github.com/metowolf/qqwry.dat/releases/latest/download/qqwry.dat

$ ips pack -i qqwry.dat -o qqwry_ips.ipdb

$ ips -i qqwry_ips.ipdb 0.0.0.0
0.0.0.0 [IANA 保留地址]

对于不完整的数据库文件进行转存,目前工具的做法是直接报错,考虑的是如果允许忽略错误继续执行,可能会在后续使用转存或重打包数据库文件时造成问题,不如提前处理。

希望对你有所帮助,瑞思拜!

PS. 这个 repo 的 ipdb 打包代码,还参考过 @metowolf 大佬的实现 :)

metowolf commented 1 month ago

感谢复现这个问题,稍晚些我会对上游纯真数据做一些严格校验逻辑。

metowolf commented 1 month ago

新版本 2024.5.26 已解决此问题,可以再次尝试 @mili-tan

https://cdn.jsdelivr.net/npm/qqwry.ipdb@2024.5.26/qqwry.ipdb