@@ -43,7 +43,7 @@ func randomPort() int {
43
43
44
44
// tcpHop attempts to connect to the target host using TCP with the specified TTL and timeout.
45
45
// It returns a [net.Conn], the port used for the connection, and an error if the connection failed.
46
- func tcpHop (ctx context.Context , addr net.Addr , ttl int , timeout time.Duration ) (conn net.Conn , port int , err error ) {
46
+ func tcpHop (ctx context.Context , addr net.Addr , ttl int , timeout time.Duration ) (net.Conn , int , error ) {
47
47
span := trace .SpanFromContext (ctx )
48
48
49
49
for {
@@ -86,10 +86,10 @@ func tcpHop(ctx context.Context, addr net.Addr, ttl int, timeout time.Duration)
86
86
case errors .Is (err , unix .EADDRINUSE ):
87
87
// Address in use, retry by continuing the loop
88
88
continue
89
- case errors .Is (err , syscall .EHOSTUNREACH ):
90
- // No route to host is no error because of how tcp traceroute works
89
+ case errors .Is (err , unix .EHOSTUNREACH ):
90
+ // No route to host is a special error because of how tcp traceroute works
91
91
// we are expecting the connection to fail because of TTL expiry
92
- span .SetStatus (codes .Unset , "No route to host" )
92
+ span .SetStatus (codes .Error , "No route to host" )
93
93
span .AddEvent ("No route to host" , trace .WithAttributes (
94
94
attribute .String ("error" , err .Error ()),
95
95
))
@@ -198,7 +198,7 @@ func TraceRoute(ctx context.Context, cfg tracerouteConfig) (map[int][]Hop, error
198
198
attribute .Int ("retry" , retry ),
199
199
))
200
200
201
- hop , hErr := hop (ctx , addr , ttl , cfg .Timeout )
201
+ hop , hErr := doHop (ctx , addr , ttl , cfg .Timeout )
202
202
if hop != nil {
203
203
results <- * hop
204
204
}
@@ -243,9 +243,9 @@ func TraceRoute(ctx context.Context, cfg tracerouteConfig) (map[int][]Hop, error
243
243
return hops , nil
244
244
}
245
245
246
- // hop performs a hop to the given address with the specified TTL and timeout.
246
+ // doHop performs a hop to the given address with the specified TTL and timeout.
247
247
// It returns a Hop struct containing the latency, TTL, address, and other details of the hop.
248
- func hop (ctx context.Context , addr net.Addr , ttl int , timeout time.Duration ) (* Hop , error ) {
248
+ func doHop (ctx context.Context , addr net.Addr , ttl int , timeout time.Duration ) (* Hop , error ) {
249
249
span := trace .SpanFromContext (ctx )
250
250
log := logger .FromContext (ctx )
251
251
canIcmp , icmpListener , err := newIcmpListener ()
0 commit comments