go-traceroute
is an implementation of the traditional, ancient
method of tracerouting, which uses probes as UDP datagram packets and
an unlikely destination port.
Install go-traceroute
by executing the command below:
$ go get -v gopkg.in/dnaeon/go-traceroute.v1/tracer
A simple example of using go-traceroute
is provided below.
package main
import (
"context"
"net"
"gopkg.in/dnaeon/go-traceroute.v1/tracer"
)
func main() {
dest := net.IPv4(142, 251, 140, 14)
ctx := context.Background()
opts := tracer.DefaultOptions
t := tracer.New(opts)
ch := t.Trace(ctx, dest)
for probe := range ch {
// Process probes ...
}
}
Also, make sure to check the examples directory from
this repository, which provides ready-to-run programs using the
go-traceroute
package.
Run a trace to a given host.
go run examples/traceroute/main.go google.com
Generate the Dot representation of a trace.
go run examples/traceroute-dot/main.go google.com
go-traceroute
is Open Source and licensed under the
BSD License