Giter Club home page Giter Club logo

ips's Introduction

IPS

Go Report Card GoDoc GitHub release GitHub license

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

中文 | English

下载与安装

源码安装

go install github.com/sjzar/ips@latest

二进制安装

Windows Unix MacOS

GitHub Releases 下载最新版本的二进制文件。

Homebrew 安装

brew tap sjzar/tap
brew install ips

特性

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

数据库支持列表

数据库 查询 转存 打包 官方网站 说明
txt - 本项目转存时使用
ipdb Link
mmdb Link
awdb - Link
qqwry - Link IPv4 only
zxinc - Link IPv6 only
ip2region - Link IPv4 only

使用方法

更详细的使用说明请翻阅 usage.md

查询

# 基础查询
ips <ip或文本> [选项]

# 查询 IP
ips 61.144.235.160
# 输出:61.144.235.160 [** 广东 深圳 电信]

# 使用管道查询 IP
echo "61.144.235.160" | ips
# 输出:61.144.235.160 [** 广东 深圳 电信]

# 使用指定的数据库文件查询 IP
ips -d ./GeoLite2-City.mmdb 61.144.235.160
# 输出:61.144.235.160 [** 广州]

# 使用指定的数据库文件并设置查询字段
ips -d ./GeoLite2-City.mmdb --fields country 61.144.235.160
# 输出:61.144.235.160 [**]

# 使用指定的数据库文件,以 JSON 格式输出结果
ips -d ./GeoLite2-City.mmdb --fields '*' -j 61.144.235.160
# 输出:{"ip":"61.144.235.160","net":"61.144.192.0/18","data":{"city":"广州市","continent":"亚洲","country":"**","latitude":"23.1181","longitude":"113.2539","utcOffset":"Asia/Shanghai"}}

转存

# 基础转存命令,输出转存内容
ips dump -i ./qqwry.dat
# 输出:
#    # Dump Time: 2023-10-20 00:00:00
#    # Fields: country,area
#    ... <省略部分输出> ...

# 指定字段进行转存
ips dump -i ./qqwry.dat -f country
# 输出:
#    # Dump Time: 2023-10-20 00:00:00
#    # Fields: country
#    ... <省略部分输出> ...

# 转存内容并保存到文件
ips dump -i ./qqwry.dat -o 1.txt

打包

# 使用转存文件进行打包
ips pack -i qqwry.txt -o qqwry.ipdb

# 使用数据库文件进行打包
ips pack -i qqwry.dat -o qqwry.ipdb

# 使用数据库文件并指定字段进行打包
ips pack -i qqwry.dat -f country -o country.ipdb

许可

ips 是在 Apache-2.0 许可下的开源软件。

致谢

ips's People

Contributors

sjzar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ips's Issues

最新的版本转存退不出循环

最新的 0.2.3 版本在使用 ips dump -i zxipv6wry.db -o ipv6.txt 命令来转存 zxipv6wry.db 时,会一直循环转存,退不出来。从转存输出的txt中也可以看到,同一条IPv6段会重复非常多次。

并且,很多网段的输出有问题,随便列举一段:

2001:288:1300::/48      **    **省  台北市  士林区,,,兰雅国民小学
2001:288:1301::/120     **    **省  台北市  士林区,,,兰雅国民小学

很明显,2001:288:1301::/120属于2001:288:1300::/48,不应该把2001:288:1301::/120输出来才对啊。

平台:debian
使用的包:https://github.com/sjzar/ips/releases/download/v0.2.3/ips_v0.2.3_linux_amd64.tar.gz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.