Documentation
¶
Index ¶
Constants ¶
View Source
const ( DefaultSrcPort = 33777 DefaultDestPort = 33434 DefaultMaxHops = 64 DefaultFirstHop = 1 DefaultTimeoutMs = 500 DefaultRetries = 3 DefaultPacketSize = 512 DefaultPreferAddressFamily = trace_socket.AF_INET )
Variables ¶
This section is empty.
Functions ¶
func NewTracerouteOptions ¶
func NewTracerouteOptions() *tracerouteOptions
NewTracerouteOptions returns TracerouteOptions initialized with defaults.
Types ¶
type TracerouteHop ¶
type TracerouteHop struct {
Success bool // Whether the probe succeeded
Address net.IP // IP address of the node
Host string // Resolved hostname of the node (if available)
Bytes int // Number of bytes received (optional)
ElapsedTime time.Duration // Round-trip time for the probe
TTL int // Time-To-Live value for this hop
}
TracerouteHop represents a single hop in a traceroute operation.
func (*TracerouteHop) AddressString ¶
func (hop *TracerouteHop) AddressString() string
AddressString returns the string representation of the IP address or empty string if nil.
func (*TracerouteHop) HostOrAddressString ¶
func (hop *TracerouteHop) HostOrAddressString() string
HostOrAddressString returns the hostname if available, otherwise the IP address string.
type TracerouteResult ¶
type TracerouteResult struct {
DestinationAddress net.IP
Hops []TracerouteHop
}
func Traceroute ¶
func Traceroute(dest string, options *tracerouteOptions, chans ...chan TracerouteHop) (TracerouteResult, error)
Traceroute performs a traceroute to the destination using the given options. This is the default entry point without cancellation.
func TracerouteContext ¶
func TracerouteContext(ctx context.Context, dest string, options *tracerouteOptions, chans ...chan TracerouteHop) (TracerouteResult, error)
TracerouteContext performs a traceroute that can be cancelled via context. It works by sending UDP packets with increasing TTL/hop limit and listening for ICMP Time Exceeded or Destination Unreachable replies.
Click to show internal directories.
Click to hide internal directories.