traceroute

package
v0.0.0-...-f673fef Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPort       = 33434
	DefaultMaxHops    = 64
	DefaultFirstHop   = 1
	DefaultTimeoutMs  = 500
	DefaultRetries    = 3
	DefaultPacketSize = 52
)

Constants are exported as of now, however, their values should ideally be configurable Preferably from a constants.go file or from a toml file or flags

Variables

This section is empty.

Functions

This section is empty.

Types

type TracerouteHop

type TracerouteHop struct {
	Success     bool
	Address     [4]byte
	Host        string
	N           int
	ElapsedTime time.Duration
	TTL         int
}

TracerouteHop represents a structure used for processing of trace requests

func (*TracerouteHop) AddressString

func (hop *TracerouteHop) AddressString() string

AddressString return the printable computed string

func (*TracerouteHop) HostOrAddressString

func (hop *TracerouteHop) HostOrAddressString() string

HostOrAddressString return the printable computed string for address or host

type TracerouteOptions

type TracerouteOptions struct {
	// contains filtered or unexported fields
}

TracerouteOptions represents the configurable options methods for which are exposed in this package.

func (*TracerouteOptions) FirstHop

func (options *TracerouteOptions) FirstHop() int

FirstHop returns the first hop set in the options or default if those aren't set

func (*TracerouteOptions) MaxHops

func (options *TracerouteOptions) MaxHops() int

MaxHops returns the maximum hops set in the options or default if those aren't set

func (*TracerouteOptions) PacketSize

func (options *TracerouteOptions) PacketSize() int

PacketSize returns the packet size set in the options or default if those aren't set

func (*TracerouteOptions) Port

func (options *TracerouteOptions) Port() int

Port returns the port set in the options or default if those aren't set

func (*TracerouteOptions) Retries

func (options *TracerouteOptions) Retries() int

Retries returns the number of retries set in the options or default if those aren't set

func (*TracerouteOptions) SetFirstHop

func (options *TracerouteOptions) SetFirstHop(firstHop int)

SetFirstHop sets the value of port in the traceroute options

func (*TracerouteOptions) SetMaxHops

func (options *TracerouteOptions) SetMaxHops(maxHops int)

SetMaxHops sets the value of port in the traceroute options

func (*TracerouteOptions) SetPacketSize

func (options *TracerouteOptions) SetPacketSize(packetSize int)

func (*TracerouteOptions) SetPort

func (options *TracerouteOptions) SetPort(port int)

SetPort sets the value of port in the traceroute options

func (*TracerouteOptions) SetRetries

func (options *TracerouteOptions) SetRetries(retries int)

SetRetries sets the value of port in the traceroute options

func (*TracerouteOptions) SetTimeoutMs

func (options *TracerouteOptions) SetTimeoutMs(timeoutMs int)

SetTimeoutMs sets the value of port in the traceroute options

func (*TracerouteOptions) TimeoutMs

func (options *TracerouteOptions) TimeoutMs() int

TimeoutMs returns the timeout in miliseconds set in the options or default if those aren't set

type TracerouteResult

type TracerouteResult struct {
	DestinationAddress [4]byte
	Hops               []TracerouteHop
}

TracerouteResult type

func Traceroute

func Traceroute(dest string, options *TracerouteOptions, c ...chan TracerouteHop) (result TracerouteResult, err error)

Traceroute uses the given dest (hostname) and options to execute a traceroute from your machine to the remote host.

Outbound packets are UDP packets and inbound packets are ICMP.

Returns a TracerouteResult which contains an array of hops. Each hop includes the elapsed time and its IP address.

Jump to

Keyboard shortcuts

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