mirror of
https://github.com/nxtrace/NTrace-core.git
synced 2025-08-12 06:26:39 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
326034b41e | ||
|
|
09a5b42443 | ||
|
|
b8542489b6 | ||
|
|
a73a306d0a | ||
|
|
801f42801a | ||
|
|
08c4a5ceae | ||
|
|
ce1c773996 |
20
README.md
20
README.md
@@ -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
|
||||
|
||||
@@ -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 数据库
|
||||
|
||||
11
cmd/cmd.go
11
cmd/cmd.go
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user