Compare commits

...

7 Commits

Author SHA1 Message Date
Leo
326034b41e fix: panic on IPv6 2023-01-18 13:44:47 +08:00
Leo
09a5b42443 fix: 在 Table 模式下,无法自动退出的问题 2023-01-18 13:26:48 +08:00
Leo
b8542489b6 fix: 修复使用 -f 导致打印卡住的问题 2023-01-18 13:19:27 +08:00
Leo
a73a306d0a chore: sync document 2023-01-17 20:30:49 +08:00
Leo
801f42801a fix: Fast Trace 无法使用 2023-01-17 20:10:35 +08:00
Leo
08c4a5ceae fix: Fast Trace 无法使用 2023-01-17 20:09:53 +08:00
Leo
ce1c773996 improve: rDNS 解析等待时间过长 2023-01-17 20:08:57 +08:00
6 changed files with 65 additions and 46 deletions

View File

@@ -81,13 +81,13 @@ Windows users please go to [Release Page](https://github.com/sjlleo/nexttrace/re
nexttrace 1.0.0.1
# Form printing (output all hops at one time, wait 20-40 seconds)
nexttrace -table 1.0.0.1
nexttrace --table 1.0.0.1
# IPv6 ICMP Trace
nexttrace 2606:4700:4700::1111
# Path Visualization With the -M parameter, a map URL is returned
nexttrace -M koreacentral.blob.core.windows.net
nexttrace --map koreacentral.blob.core.windows.net
# MapTrace URL: https://api.leo.moe/tracemap/html/c14e439e-3250-5310-8965-42a1e3545266.html
```
@@ -101,21 +101,21 @@ The routing visualization function requires the geographical coordinates of each
```bash
# IPv4 ICMP Fast Test (Beijing + Shanghai + Guangzhou + Hangzhou) in China Telecom / Unicom / Mobile / Education Network
nexttrace -f
nexttrace -F
# You can also use TCP SYN for testing
nexttrace -f -T
nexttrace -F -T
```
`NextTrace` already supports route tracing for specified Network Devices
```bash
# Use eth0 network interface
nexttrace -D eth0 2606:4700:4700::1111
nexttrace --dev eth0 2606:4700:4700::1111
# Use eth0 network interface's IP
# When using the network interface's IP for route tracing, note that the IP type to be traced should be the same as network interface's IP type (e.g. both IPv4)
nexttrace -S 204.98.134.56 9.9.9.9
nexttrace --source 204.98.134.56 9.9.9.9
```
`NextTrace` can also use `TCP` and `UDP` protocols to perform `Traceroute` requests, but these protocols only supports `IPv4` now
@@ -143,7 +143,7 @@ nexttrace -q 2 www.hkix.net
nexttrace -r 1 www.hkix.net
# Start Trace with TTL of 5, end at TTL of 10
nexttrace -b 5 -m 10 www.decix.net
nexttrace -f 5 -m 10 www.decix.net
# Turn off the IP reverse parsing function
nexttrace -n www.bbix.net
@@ -157,7 +157,7 @@ nexttrace -n www.bbix.net
# ╰AS36776 Five9 Inc.「Philippines『Metro Manila』」
# ╭╯
# ╰AS37963 Aliyun「ALIDNS.COM『ALIDNS.COM』」
nexttrace -report www.time.com.my
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`)
@@ -175,8 +175,8 @@ nexttrace -d IP.SB
```bash
Example:
nexttrace -d IPInsight -m 20 -p 443 -q 5 -r 20 -rdns 1.1.1.1
nexttrace -T -q 2 -r 1 -table -report 2001:4860:4860::8888
nexttrace --data-provider LeoMoeAPI -m 20 -p 443 -q 5 -n 1.1.1.1
nexttrace -T -q 2 -r 1 --table --route-path 2001:4860:4860::8888
```
### IP Database

View File

@@ -41,7 +41,7 @@ Windows 用户请直接前往 [Release](https://github.com/sjlleo/nexttrace/rele
nexttrace 1.0.0.1
# 表格打印一次性输出全部跳数需等待20-40秒
nexttrace -table 1.0.0.1
nexttrace --table 1.0.0.1
# IPv6 ICMP Trace
nexttrace 2606:4700:4700::1111
@@ -61,10 +61,10 @@ PS: 路由可视化的绘制模块由 [@tsosunchia](https://github.com/tsosunchi
```bash
# 北上广(电信+联通+移动+教育网IPv4 ICMP 快速测试
nexttrace -f
nexttrace -F
# 也可以使用 TCP SYN 而非 ICMP 进行测试
nexttrace -f -T
nexttrace -F -T
```
`NextTrace` 已支持指定网卡进行路由跟踪
@@ -119,7 +119,7 @@ nexttrace -n www.bbix.net
# ╰AS36776 Five9 Inc.「Philippines『Metro Manila』」
# ╭╯
# ╰AS37963 阿里云「ALIDNS.COM『ALIDNS.COM』」
nexttrace -report www.time.com.my
nexttrace --route-path www.time.com.my
```
`NextTrace`支持用户自主选择 IP 数据库(目前支持:`LeoMoeAPI`, `IP.SB`, `IPInfo`, `IPInsight`, `IPAPI.com`
@@ -137,8 +137,8 @@ nexttrace -d IP.SB
```bash
Example:
nexttrace -d IPInsight -m 20 -p 443 -q 5 -r 20 -rdns 1.1.1.1
nexttrace -T -q 2 -r 1 -table -report 2001:4860:4860::8888
nexttrace --data-provider LeoMoeAPI -m 20 -p 443 -q 5 --parallel-requests 20 -n 1.1.1.1
nexttrace -T -q 2 --table --route-path 2001:4860:4860::8888
```
### IP 数据库

View File

@@ -56,6 +56,7 @@ func Excute() {
// In case of error print error and print usage
// This can also be done by passing -h or --help flags
fmt.Print(parser.Usage(err))
return
}
if *ver {
@@ -65,11 +66,6 @@ func Excute() {
domain := *str
if domain == "" {
fmt.Print(parser.Usage(err))
return
}
if *fast_trace {
fastTrace.FastTest(*tcp, *output)
if *output {
@@ -79,6 +75,11 @@ func Excute() {
os.Exit(0)
}
if domain == "" {
fmt.Print(parser.Usage(err))
return
}
capabilities_check()
// return

View File

@@ -30,21 +30,20 @@ type ICMPTracer struct {
func (t *ICMPTracer) PrintFunc() {
defer t.wg.Done()
var ttl = 0
var ttl = t.Config.BeginHop - 1
for {
if t.AsyncPrinter != nil {
t.AsyncPrinter(&t.res)
}
if t.RealtimePrinter != nil {
// 接收的时候检查一下是不是 3 跳都齐了
if len(t.res.Hops)-1 > ttl {
if len(t.res.Hops[ttl]) == t.NumMeasurements {
if len(t.res.Hops)-1 > ttl {
if len(t.res.Hops[ttl]) == t.NumMeasurements {
if t.RealtimePrinter != nil {
t.RealtimePrinter(&t.res, ttl)
ttl++
}
ttl++
if ttl == t.final-1 || ttl >= t.MaxHops-1 {
return
}
if ttl == t.final-1 || ttl >= t.MaxHops-1 {
return
}
}
}

View File

@@ -29,20 +29,25 @@ type ICMPTracerv6 struct {
func (t *ICMPTracerv6) PrintFunc() {
// defer t.wg.Done()
var ttl = 0
var ttl = t.Config.BeginHop - 1
for {
if t.RealtimePrinter != nil {
// 接收的时候检查一下是不是 3 跳都齐了
if len(t.res.Hops)-1 > ttl {
if len(t.res.Hops[ttl]) == t.NumMeasurements {
if t.AsyncPrinter != nil {
t.AsyncPrinter(&t.res)
}
// 接收的时候检查一下是不是 3 跳都齐了
if len(t.res.Hops)-1 > ttl {
if len(t.res.Hops[ttl]) == t.NumMeasurements {
if t.RealtimePrinter != nil {
t.RealtimePrinter(&t.res, ttl)
ttl++
if ttl == t.final {
return
}
}
ttl++
if ttl == t.final {
return
}
}
}
<-time.After(100 * time.Millisecond)
}
}
@@ -82,9 +87,6 @@ func (t *ICMPTracerv6) Execute() (*Result, error) {
go t.send(ttl)
}
<-time.After(time.Millisecond * 100)
if t.AsyncPrinter != nil {
t.AsyncPrinter(&t.res)
}
}
// for ttl := t.BeginHop; ttl <= t.MaxHops; ttl++ {
// if t.final != -1 && ttl > t.final {
@@ -118,7 +120,9 @@ func (t *ICMPTracerv6) Execute() (*Result, error) {
Error: ErrHopLimitTimeout,
})
}
t.RealtimePrinter(&t.res, t.MaxHops-1)
if t.RealtimePrinter != nil {
t.RealtimePrinter(&t.res, t.MaxHops-1)
}
}
return &t.res, nil

View File

@@ -116,10 +116,25 @@ type Hop struct {
}
func (h *Hop) fetchIPData(c Config) (err error) {
timeout := time.Millisecond * 800
if c.RDns && h.Hostname == "" {
ptr, err := net.LookupAddr(h.Address.String())
if err == nil && len(ptr) > 0 {
h.Hostname = ptr[0]
result := make(chan []string)
go func() {
r, err := net.LookupAddr(h.Address.String())
if err != nil {
result <- nil
} else {
result <- r
}
}()
select {
case ptr := <-result:
// process result
if err == nil && len(ptr) > 0 {
h.Hostname = ptr[0]
}
case <-time.After(timeout):
// handle timeout
}
}
if c.IPGeoSource != nil && h.Geo == nil {