Skip to content

Commit ea2a6b5

Browse files
authored
Merge pull request #249 from nxtrace/main
chore: SYNC
2 parents c1cd802 + 2e9428c commit ea2a6b5

14 files changed

+57
-39
lines changed

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ Please note, there are exceptions to this synchronization. If a version of NTrac
6767
```shell
6868
yay -S nexttrace-bin
6969
```
70-
* The AUR builds are maintained by ouuan
70+
* Build from source (only supports amd64)
71+
72+
```shell
73+
yay -S nexttrace
74+
```
75+
* The AUR builds are maintained by ouuan, huyz
7176
* Linuxbrew's installation command
7277
7378
Same as the macOS Homebrew's installation method (homebrew-core version only supports amd64)

README_zh_CN.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ Document Language: [English](README.md) | 简体中文
6060

6161
使用 NextTrace 之前,我们建议您先阅读 [#IP 数据以及精准度说明](https://github.com/nxtrace/NTrace-core/blob/main/README_zh_CN.md#ip-%E6%95%B0%E6%8D%AE%E4%BB%A5%E5%8F%8A%E7%B2%BE%E5%87%86%E5%BA%A6%E8%AF%B4%E6%98%8E),在了解您自己的对数据精准度需求以后再进行抉择。
6262

63-
[NextTrace 的Telegram频道](https://t.me/nexttrace)由项目成员负责,会传递一部分通知,也会发布一些成员自己分享的小工具。项目成员的意见可作为未来项目发展的可能方向,随着开发进度变化可能会有所改动,不代表未来一定会实装,正式定稿公告会发布于 Issue 中。
64-
6563
### Automated Install
6664

6765
* Linux
@@ -75,9 +73,14 @@ Document Language: [English](README.md) | 简体中文
7573
* 直接下载bin包(仅支持amd64)
7674

7775
```shell
78-
yay -S nexttrace-bin`
76+
yay -S nexttrace-bin
77+
```
78+
* 从源码构建(仅支持amd64)
79+
80+
```shell
81+
yay -S nexttrace
7982
```
80-
* AUR 的构建分别由 ouuan 维护
83+
* AUR 的构建分别由 ouuan, huyz 维护
8184
* Linuxbrew 安装命令
8285

8386
同macOS Homebrew安装方法(homebrew-core版仅支持amd64)

fast_trace/fast_trace ipv6.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package fastTrace
22

33
import (
44
"fmt"
5+
"github.com/fatih/color"
56
"github.com/nxtrace/NTrace-core/ipgeo"
67
"github.com/nxtrace/NTrace-core/printer"
78
"github.com/nxtrace/NTrace-core/trace"
@@ -16,7 +17,7 @@ import (
1617
//var pFastTracer ParamsFastTrace
1718

1819
func (f *FastTracer) tracert_v6(location string, ispCollection ISPCollection) {
19-
fmt.Printf("%s『%s %s 』%s\n", printer.YELLOW_PREFIX, location, ispCollection.ISPName, printer.RESET_PREFIX)
20+
fmt.Fprintf(color.Output, "%s\n", color.New(color.FgYellow, color.Bold).Sprintf("『%s %s 』", location, ispCollection.ISPName))
2021
fmt.Printf("traceroute to %s, %d hops max, %d byte packets\n", ispCollection.IPv6, f.ParamsFastTrace.MaxHops, f.ParamsFastTrace.PktSize)
2122

2223
ip, err := util.DomainLookUp(ispCollection.IPv6, "6", "", true)

go.mod

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ go 1.22.3
55
require (
66
github.com/akamensky/argparse v1.4.0
77
github.com/google/gopacket v1.1.19
8-
github.com/oschwald/maxminddb-golang v1.12.0
9-
github.com/spf13/viper v1.18.2
8+
github.com/oschwald/maxminddb-golang v1.13.1
9+
github.com/spf13/viper v1.19.0
1010
github.com/stretchr/testify v1.9.0
1111
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
1212
github.com/tsosunchia/powclient v0.1.5
13-
golang.org/x/net v0.25.0
13+
golang.org/x/net v0.27.0
1414
golang.org/x/sync v0.7.0
1515
)
1616

@@ -24,27 +24,27 @@ require (
2424
github.com/mitchellh/mapstructure v1.5.0 // indirect
2525
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
2626
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
27-
github.com/sagikazarmark/locafero v0.4.0 // indirect
27+
github.com/sagikazarmark/locafero v0.6.0 // indirect
2828
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
2929
github.com/sourcegraph/conc v0.3.0 // indirect
3030
github.com/spf13/afero v1.11.0 // indirect
3131
github.com/spf13/cast v1.6.0 // indirect
3232
github.com/spf13/pflag v1.0.5 // indirect
3333
github.com/subosito/gotenv v1.6.0 // indirect
3434
go.uber.org/multierr v1.11.0 // indirect
35-
golang.org/x/exp v0.0.0-20240529005216-23cca8864a10 // indirect
36-
golang.org/x/text v0.15.0 // indirect
35+
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 // indirect
36+
golang.org/x/text v0.16.0 // indirect
3737
gopkg.in/ini.v1 v1.67.0 // indirect
3838
)
3939

4040
require (
4141
github.com/fatih/color v1.17.0
42-
github.com/gorilla/websocket v1.5.1
42+
github.com/gorilla/websocket v1.5.2
4343
github.com/lionsoul2014/ip2region v2.11.2+incompatible
4444
github.com/rodaine/table v1.2.0
4545
github.com/tidwall/gjson v1.17.1
4646
github.com/tidwall/match v1.1.1 // indirect
4747
github.com/tidwall/pretty v1.2.1 // indirect
48-
golang.org/x/sys v0.20.0 // indirect
48+
golang.org/x/sys v0.22.0 // indirect
4949
gopkg.in/yaml.v3 v3.0.1 // indirect
5050
)

go.sum

+16-16
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
1414
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
1515
github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8=
1616
github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo=
17-
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
18-
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
17+
github.com/gorilla/websocket v1.5.2 h1:qoW6V1GT3aZxybsbC6oLnailWnB+qTMVwMreOso9XUw=
18+
github.com/gorilla/websocket v1.5.2/go.mod h1:0n9H61RBAcf5/38py2MCYbxzPIY9rOkpvvMT24Rqs30=
1919
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
2020
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
2121
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
@@ -35,8 +35,8 @@ github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZ
3535
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
3636
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
3737
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
38-
github.com/oschwald/maxminddb-golang v1.12.0 h1:9FnTOD0YOhP7DGxGsq4glzpGy5+w7pq50AS6wALUMYs=
39-
github.com/oschwald/maxminddb-golang v1.12.0/go.mod h1:q0Nob5lTCqyQ8WT6FYgS1L7PXKVVbgiymefNwIjPzgY=
38+
github.com/oschwald/maxminddb-golang v1.13.1 h1:G3wwjdN9JmIK2o/ermkHM+98oX5fS+k5MbwsmL4MRQE=
39+
github.com/oschwald/maxminddb-golang v1.13.1/go.mod h1:K4pgV9N/GcK694KSTmVSDTODk4IsCNThNdTmnaBZ/F8=
4040
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
4141
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
4242
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@@ -48,8 +48,8 @@ github.com/rodaine/table v1.2.0 h1:38HEnwK4mKSHQJIkavVj+bst1TEY7j9zhLMWu4QJrMA=
4848
github.com/rodaine/table v1.2.0/go.mod h1:wejb/q/Yd4T/SVmBSRMr7GCq3KlcZp3gyNYdLSBhkaE=
4949
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
5050
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
51-
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
52-
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
51+
github.com/sagikazarmark/locafero v0.6.0 h1:ON7AQg37yzcRPU69mt7gwhFEBwxI6P9T4Qu3N51bwOk=
52+
github.com/sagikazarmark/locafero v0.6.0/go.mod h1:77OmuIc6VTraTXKXIs/uvUxKGUXjE1GbemJYHqdNjX0=
5353
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
5454
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
5555
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
@@ -60,8 +60,8 @@ github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
6060
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
6161
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
6262
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
63-
github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ=
64-
github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk=
63+
github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
64+
github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg=
6565
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
6666
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
6767
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
@@ -88,26 +88,26 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
8888
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
8989
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
9090
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
91-
golang.org/x/exp v0.0.0-20240529005216-23cca8864a10 h1:vpzMC/iZhYFAjJzHU0Cfuq+w1vLLsF2vLkDrPjzKYck=
92-
golang.org/x/exp v0.0.0-20240529005216-23cca8864a10/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
91+
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 h1:LoYXNGAShUG3m/ehNk4iFctuhGX/+R1ZpfJ4/ia80JM=
92+
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
9393
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
9494
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
9595
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
9696
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
97-
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
98-
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
97+
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
98+
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
9999
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
100100
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
101101
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
102102
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
103103
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
104104
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
105105
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
106-
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
107-
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
106+
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
107+
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
108108
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
109-
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
110-
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
109+
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
110+
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
111111
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
112112
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
113113
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

ipgeo/ipapicom.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
func IPApiCom(ip string, timeout time.Duration, _ string, _ bool) (*IPGeoData, error) {
17-
url := "http://ip-api.com/json/" + ip + "?fields=status,message,country,regionName,city,isp,district,as,lat,lon"
17+
url := token.BaseOrDefault("http://ip-api.com/json/") + ip + "?fields=status,message,country,regionName,city,isp,district,as,lat,lon"
1818
client := &http.Client{
1919
// 2 秒超时
2020
Timeout: timeout,

ipgeo/ipinfo.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
func IPInfo(ip string, timeout time.Duration, _ string, _ bool) (*IPGeoData, error) {
15-
url := "http://ipinfo.io/" + ip + "?token=" + token.ipinfo
15+
url := token.BaseOrDefault("http://ipinfo.io/") + ip + "?token=" + token.ipinfo
1616
client := &http.Client{
1717
// 2 秒超时
1818
Timeout: timeout,

ipgeo/ipinsight.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func IPInSight(ip string, timeout time.Duration, _ string, _ bool) (*IPGeoData,
1313
// 2 秒超时
1414
Timeout: timeout,
1515
}
16-
resp, err := client.Get("https://api.ipinsight.io/ip/" + ip + "?token=" + token.ipinsight)
16+
resp, err := client.Get(token.BaseOrDefault("https://api.ipinsight.io/ip/") + ip + "?token=" + token.ipinsight)
1717
if err != nil {
1818
return nil, err
1919
}

ipgeo/ipsb.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
func IPSB(ip string, timeout time.Duration, _ string, _ bool) (*IPGeoData, error) {
14-
url := "https://api.ip.sb/geoip/" + ip
14+
url := token.BaseOrDefault("https://api.ip.sb/geoip/") + ip
1515
client := &http.Client{
1616
// 2 秒超时
1717
Timeout: timeout,

ipgeo/tokens.go

+9
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,19 @@ type tokenData struct {
66
ipinsight string
77
ipinfo string
88
ipleo string
9+
baseUrl string
10+
}
11+
12+
func (t *tokenData) BaseOrDefault(def string) string {
13+
if t.baseUrl == "" {
14+
return def
15+
}
16+
return t.baseUrl
917
}
1018

1119
var token = tokenData{
1220
ipinsight: util.GetenvDefault("NEXTTRACE_IPINSIGHT_TOKEN", ""),
1321
ipinfo: util.GetenvDefault("NEXTTRACE_IPINFO_TOKEN", ""),
22+
baseUrl: util.GetenvDefault("NEXTTRACE_IPAPI_BASE", ""),
1423
ipleo: "NextTraceDemo",
1524
}

trace/tcp_ipv4.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ func (t *TCPTracer) send(ttl int) error {
264264
return err
265265
}
266266
t.inflightRequestLock.Lock()
267-
hopCh := make(chan Hop)
267+
hopCh := make(chan Hop, 1)
268268
t.inflightRequest[int(sequenceNumber)] = hopCh
269269
t.inflightRequestLock.Unlock()
270270
/*

trace/tcp_ipv6.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ func (t *TCPTracerv6) send(ttl int) error {
251251
}
252252
// log.Println(ttl, sequenceNumber)
253253
t.inflightRequestLock.Lock()
254-
hopCh := make(chan Hop)
254+
hopCh := make(chan Hop, 1)
255255
t.inflightRequest[int(sequenceNumber)] = hopCh
256256
t.inflightRequestLock.Unlock()
257257

trace/trace.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type Config struct {
4242
AsyncPrinter func(res *Result)
4343
PktSize int
4444
Maptrace bool
45-
DontFragment bool
45+
DontFragment bool
4646
}
4747

4848
type Method string

trace/udp.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (t *UDPTracer) Execute() (*Result, error) {
5454
go t.listenICMP()
5555

5656
t.sem = semaphore.NewWeighted(int64(t.ParallelRequests))
57-
for ttl := 1; ttl <= t.MaxHops; ttl++ {
57+
for ttl := t.BeginHop; ttl <= t.MaxHops; ttl++ {
5858
// 如果到达最终跳,则退出
5959
if t.final != -1 && ttl > t.final {
6060
break
@@ -225,7 +225,7 @@ func (t *UDPTracer) send(ttl int) error {
225225

226226
// 在对inflightRequest进行写操作的时候应该加锁保护,以免多个goroutine协程试图同时写入造成panic
227227
t.inflightRequestLock.Lock()
228-
hopCh := make(chan Hop)
228+
hopCh := make(chan Hop, 1)
229229
t.inflightRequest[srcPort] = hopCh
230230
t.inflightRequestLock.Unlock()
231231
defer func() {

0 commit comments

Comments
 (0)