trace

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(host string, ipv IPVersion, maxTTL int, timeout time.Duration, callback func(hop *Hop, err error)) error

Build makes the route to the target host. After every probe, it calls the callback function (so the caller don't have to wait when all probes are made to build an output).

Example
cb := func(hop *Hop, err error) {
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("%+v", hop)
}

if err := Build("google.com", IPv6, 64, time.Second, cb); err != nil {
	log.Fatal(err)
}

if err := Build("google.com", IPv4, 64, time.Second, cb); err != nil {
	log.Fatal(err)
}
Output:

Types

type Hop

type Hop struct {
	Seq     int
	Peer    Peer
	Latency time.Duration
	Message string
}

Hop represents a single hop info: sequence number, hostname and address, latency, received icmp message.

type IPVersion

type IPVersion string

IPVersion defines possible IP versions

const (
	IPv4 IPVersion = "ip4"
	IPv6 IPVersion = "ip6"
)

Possible versions of IPVersion

type Peer

type Peer struct {
	Name string
	Addr net.Addr
}

Peer is a host presented by a name and address.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL