From 110bdc27fffc7cb4a1eb193cdd2f7e476d8e1aec Mon Sep 17 00:00:00 2001 From: tsosunchia <59512455+tsosunchia@users.noreply.github.com> Date: Wed, 1 Mar 2023 18:01:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E4=BA=9B=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E6=96=B9API=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update README_zh_CN.md Update README.md Update ipinsight.go Update ipgeo.go --- README.md | 40 +++++++++++++++++--------------- README_zh_CN.md | 57 +++++++++++++++++++++++++++------------------- cmd/cmd.go | 4 ++-- ipgeo/ipgeo.go | 2 ++ ipgeo/ipinsight.go | 2 +- 5 files changed, 61 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 1c03507..c3e896a 100644 --- a/README.md +++ b/README.md @@ -122,15 +122,15 @@ nexttrace --no-rdns www.bbix.net nexttrace --route-path www.time.com.my ``` -`NextTrace` supports users to select their own IP API (currently supports: `LeoMoeAPI`, `IP.SB`, `IPInfo`, `IPInsight`, `IPAPI.com`) +`NextTrace` supports users to select their own IP API (currently supports: `LeoMoeAPI`, `IP.SB`, `IPInfo`, `IPInsight`, `IP-API.com`, `Ip2region`) ```bash -# You can specify the IP database by yourself [IP.SB here], if not specified, LeoMoeAPI will be used -nexttrace --data-provider IP.SB -## Note that the ipinfo API needs users to purchase services from ipinfo. If necessary, you can clone this project, add the token provided by ipinfo and compile it yourself +# You can specify the IP database by yourself [IP-API.com here], if not specified, LeoMoeAPI will be used +nexttrace --data-provider ip-api.com +## Note that the `ipinfo` and `IPInsight` API needs users to purchase services from them. If necessary, you can clone this project, add the token provided by `ipinfo` or `IPInsight` and compile it yourself ## Fill the token to: ipgeo/tokens.go ## Please be aware: Due to the serious abuse of IP.SB, you will often be not able to query IP data from this source -## IPAPI.com has a stricter restiction on API calls, if you can't query IP data from this source, please try again in a few minutes. +## IP-API.com has a stricter restiction on API calls, if you can't query IP data from this source, please try again in a few minutes. ``` `NextTrace` supports mixed parameters and shortened parameters @@ -161,15 +161,15 @@ All NextTrace IP geolocation `API DEMO` can refer to [here](https://github.com/x usage: nexttrace [-h|--help] [-T|--tcp] [-U|--udp] [-F|--fast-trace] [-p|--port ] [-q|--queries ] [--parallel-requests ] [-m|--max-hops ] [-d|--data-provider - (IP.SB|IPInfo|IPInsight|IPAPI.com)] [-n|--no-rdns] - [-a|--always-rdns] [-P|--route-path] [-r|--report] - [-o|--output] [-t|--table] [-c|--classic] [-f|--first - ] [-M|--map] [-v|--version] [-s|--source ""] - [-D|--dev ""] [-R|--route] [-z|--send-time ] - [-i|--ttl-time ] [-g|--language (en|cn)] [IP Address - or Domain] - - An open source visual route tracking CLI tool + (Ip2region|ip2region|IP.SB|ip.sb|IPInfo|ipinfo|IPInsight|ipinsight|IPAPI.com|ip-api.com)] + [-n|--no-rdns] [-a|--always-rdns] [-P|--route-path] + [-r|--report] [--dn42] [-o|--output] [-t|--table] + [-c|--classic] [-f|--first ] [-M|--map] + [-v|--version] [-s|--source ""] [-D|--dev ""] + [-R|--route] [-z|--send-time ] [-i|--ttl-time + ] [_positionalArg_nexttrace_25 ""] + [--dot-server (dnssb|aliyun|dnspod|google|cloudflare)] + [-g|--language (en|cn)] Arguments: @@ -194,9 +194,9 @@ Arguments: 18 -m --max-hops Set the max number of hops (max TTL to be reached). Default: 30 - -d --data-provider Choose IP Geograph Data Provider - [LeoMoeAPI,IP.SB, IPInfo, IPInsight, - IPAPI.com]. Default: LeoMoeAPI + -d --data-provider Choose IP Geograph Data Provider [IP.SB, + IPInfo, IPInsight, IP-API.com, Ip2region]. + Default: LeoMoeAPI -n --no-rdns Do not resolve IP addresses to their domain names -a --always-rdns Always resolve IP addresses to their @@ -204,6 +204,7 @@ Arguments: -P --route-path Print traceroute hop path by ASN and location -r --report output using report mode + --dn42 DN42 Mode -o --output Write trace result to file (RealTimePrinter ONLY) -t --table Output trace results as table @@ -211,7 +212,7 @@ Arguments: BestTrace -f --first Start from the first_ttl hop (instead from 1). Default: 1 - -M --map Disable Print Trace Map Function + -M --map Disable Print Trace Map -v --version Print version info and exit -s --source Use source src_addr for outgoing packets -D --dev Use the following Network Devices as the @@ -224,6 +225,9 @@ Arguments: groups by TTL. Useful when some routers use rate-limit for ICMP messages. Default: 500 + --_positionalArg_nexttrace_25 IP Address or domain name + --dot-server Use DoT Server for DNS Parse [dnssb, + aliyun, dnspod, google, cloudflare] -g --language Choose the language for displaying [en, cn]. Default: cn ``` diff --git a/README_zh_CN.md b/README_zh_CN.md index b3ce6b5..df63c13 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -141,42 +141,46 @@ nexttrace --no-rdns www.bbix.net nexttrace --route-path www.time.com.my ``` -`NextTrace`支持用户自主选择 IP 数据库(目前支持:`LeoMoeAPI`, `IP.SB`, `IPInfo`, `IPInsight`, `IPAPI.com`) +`NextTrace`支持用户自主选择 IP 数据库(目前支持:`LeoMoeAPI`, `IP.SB`, `IPInfo`, `IPInsight`, `IP-API.com`, `Ip2region`) ```bash -# 可以自行指定IP数据库[此处为IP.SB],不指定则默认为LeoMoeAPI -nexttrace --data-provider IP.SB -## 特别的:其中 ipinfo API 需要从 ipinfo 自行购买服务,如有需要可以 clone 本项目添加其提供的 token 自行编译 +# 可以自行指定IP数据库[此处为IP-API.com],不指定则默认为LeoMoeAPI +nexttrace --data-provider ip-api.com +## 特别的:其中 `ipinfo` 和 `IPInsight` API 需要从这些服务商自行购买服务,如有需要可以 clone 本项目添加其提供的 token 自行编译 ## TOKEN填写路径:ipgeo/tokens.go ## 另外:由于IP.SB被滥用比较严重,会经常出现无法查询的问题,请知悉。 -## IPAPI.com限制调用较为严格,如有查询不到的情况,请几分钟后再试。 +## IP-API.com限制调用较为严格,如有查询不到的情况,请几分钟后再试。 ``` `NextTrace`支持使用混合参数和简略参数 ```bash Example: -nexttrace --data-provider IPAPI.com --max-hops 20 --tcp --port 443 --queries 5 --no-rdns 1.1.1.1 +nexttrace --data-provider ip-api.com --max-hops 20 --tcp --port 443 --queries 5 --no-rdns 1.1.1.1 nexttrace -tcp --queries 2 --parallel-requests 1 --table --route-path 2001:4860:4860::8888 Equivalent to: -nexttrace -d IPAPI.com -m 20 -T -p 443 -q 5 -n 1.1.1.1 +nexttrace -d ip-api.com -m 20 -T -p 443 -q 5 -n 1.1.1.1 nexttrace -T -q 2 --parallel-requests 1 -t -R 2001:4860:4860::8888 ``` ### 全部用法详见 Usage 菜单 ```shell -Usage: nexttrace [-h|--help] [-T|--tcp] [-U|--udp] [-F|--fast-trace] [-p|--port +usage: nexttrace [-h|--help] [-T|--tcp] [-U|--udp] [-F|--fast-trace] [-p|--port ] [-q|--queries ] [--parallel-requests ] [-m|--max-hops ] [-d|--data-provider - (IP.SB|IPInfo|IPInsight|IPAPI.com)] [-n|--no-rdns] - [-r|--route-path] [-o|--output] [-t|--table] [-c|--classic] - [-f|--first ] [-M|--map] [-v|--version] [-s|--source - ""] [-D|--dev ""] [-R|--route] [-z|--send-time - ] [-i|--ttl-time ] - [IP Address or Domain name] + (Ip2region|ip2region|IP.SB|ip.sb|IPInfo|ipinfo|IPInsight|ipinsight|IPAPI.com|ip-api.com)] + [-n|--no-rdns] [-a|--always-rdns] [-P|--route-path] + [-r|--report] [--dn42] [-o|--output] [-t|--table] + [-c|--classic] [-f|--first ] [-M|--map] + [-v|--version] [-s|--source ""] [-D|--dev ""] + [-R|--route] [-z|--send-time ] [-i|--ttl-time + ] [_positionalArg_nexttrace_25 ""] + [--dot-server (dnssb|aliyun|dnspod|google|cloudflare)] + [-g|--language (en|cn)] + Arguments: -h --help Print help information @@ -200,13 +204,17 @@ Arguments: 18 -m --max-hops Set the max number of hops (max TTL to be reached). Default: 30 - -d --data-provider Choose IP Geograph Data Provider - [LeoMoeAPI,IP.SB, IPInfo, IPInsight, - IPAPI.com]. Default: LeoMoeAPI - -n --no-rdns Do not resolve IP addresses to their + -d --data-provider Choose IP Geograph Data Provider [IP.SB, + IPInfo, IPInsight, IP-API.com, Ip2region]. + Default: LeoMoeAPI + -n --no-rdns Do not resolve IP addresses to their domain names - -r --route-path Print traceroute hop path by ASN and + -a --always-rdns Always resolve IP addresses to their + domain names + -P --route-path Print traceroute hop path by ASN and location + -r --report output using report mode + --dn42 DN42 Mode -o --output Write trace result to file (RealTimePrinter ONLY) -t --table Output trace results as table @@ -214,7 +222,7 @@ Arguments: BestTrace -f --first Start from the first_ttl hop (instead from 1). Default: 1 - -M --map Disable Print Trace Map Function + -M --map Disable Print Trace Map -v --version Print version info and exit -s --source Use source src_addr for outgoing packets -D --dev Use the following Network Devices as the @@ -222,11 +230,14 @@ Arguments: -R --route Show Routing Table [Provided By BGP.Tools] -z --send-time Set the time interval for sending every packet. Useful when some routers use - rate-limit for ICMP messages.. Default: 0 + rate-limit for ICMP messages. Default: 100 -i --ttl-time Set the time interval for sending packets groups by TTL. Useful when some routers - use rate-limit for ICMP messages.. - Default: 500 + use rate-limit for ICMP messages. Default: + 500 + --_positionalArg_nexttrace_25 IP Address or domain name + --dot-server Use DoT Server for DNS Parse [dnssb, + aliyun, dnspod, google, cloudflare] -g --language Choose the language for displaying [en, cn]. Default: cn ``` diff --git a/cmd/cmd.go b/cmd/cmd.go index 02ef472..57253c3 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -37,8 +37,8 @@ func Excute() { numMeasurements := parser.Int("q", "queries", &argparse.Options{Default: 3, Help: "Set the number of probes per each hop"}) parallelRequests := parser.Int("", "parallel-requests", &argparse.Options{Default: 18, Help: "Set ParallelRequests number. It should be 1 when there is a multi-routing"}) maxHops := parser.Int("m", "max-hops", &argparse.Options{Default: 30, Help: "Set the max number of hops (max TTL to be reached)"}) - dataOrigin := parser.Selector("d", "data-provider", []string{"IP.SB", "IPInfo", "IPInsight", "IPAPI.com"}, &argparse.Options{Default: "LeoMoeAPI", - Help: "Choose IP Geograph Data Provider [LeoMoeAPI,IP.SB, IPInfo, IPInsight, IPAPI.com]"}) + dataOrigin := parser.Selector("d", "data-provider", []string{"Ip2region", "ip2region", "IP.SB", "ip.sb", "IPInfo", "ipinfo", "IPInsight", "ipinsight", "IPAPI.com", "ip-api.com"}, &argparse.Options{Default: "LeoMoeAPI", + Help: "Choose IP Geograph Data Provider [IP.SB, IPInfo, IPInsight, IP-API.com, Ip2region]"}) noRdns := parser.Flag("n", "no-rdns", &argparse.Options{Help: "Do not resolve IP addresses to their domain names"}) alwaysRdns := parser.Flag("a", "always-rdns", &argparse.Options{Help: "Always resolve IP addresses to their domain names"}) routePath := parser.Flag("P", "route-path", &argparse.Options{Help: "Print traceroute hop path by ASN and location"}) diff --git a/ipgeo/ipgeo.go b/ipgeo/ipgeo.go index 0b5e1dc..532c86d 100644 --- a/ipgeo/ipgeo.go +++ b/ipgeo/ipgeo.go @@ -39,6 +39,8 @@ func GetSource(s string) Source { return IPInSight case "IPAPI.COM": return IPApiCom + case "IP-API.COM": + return IPApiCom case "IPINFO": return IPInfo case "IP2REGION": diff --git a/ipgeo/ipinsight.go b/ipgeo/ipinsight.go index df0c233..d43b4f5 100644 --- a/ipgeo/ipinsight.go +++ b/ipgeo/ipinsight.go @@ -8,7 +8,7 @@ import ( ) func IPInSight(ip string) (*IPGeoData, error) { - resp, err := http.Get("https://ipinsight.io/query?ip=" + ip) + resp, err := http.Get("https://api.ipinsight.io/ip/" + ip + "?token=" + token.ipinsight) if err != nil { return nil, err }