traceroute

package module
v0.0.0-...-ad1bfb1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: MIT Imports: 9 Imported by: 0

README

traceroute

A general purpose traceroute library for golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLocalIP

func GetLocalIP() (net.IP, error)

Types

type Hop

type Hop struct {
	Responses []ProbeResponse
}

type ProbeResponse

type ProbeResponse struct {
	Success      bool
	Error        error
	Address      net.IP
	Duration     time.Duration
	TTL          int
	ResponseSize int
}

type ProbeType

type ProbeType uint8
const (
	UdpProbe ProbeType = iota
	TcpProbe
	IcmpProbe
)

type SockExtendedErr

type SockExtendedErr struct {
	Errno  uint32
	Origin uint8
	Type   uint8
	Code   uint8
	Pad    uint8
	Info   uint32
	Data   uint32
}

TODO: pull from some library? taken from http://lxr.free-electrons.com/source/include/linux/errqueue.h?v=2.6.32#L6

type TracerouteOptions

type TracerouteOptions struct {
	SourceAddr net.IP
	SourcePort int

	DestinationAddr net.IP
	DestinationPort int

	// enumerated value of tcp/udp/icmp
	ProbeType ProbeType // TODO: make the enum

	// TTL options
	StartingTTL int // default to 1
	MaxTTL      int // default to 30

	// Probe options
	ProbeTimeout time.Duration // timeout for a probe -- default 5
	ProbeCount   int           // Number of probes per hop-- default to 3
	ProbeWait    time.Duration // time to wait between probes -- default 0

	ResultChan chan *ProbeResponse
	// contains filtered or unexported fields
}

TODO: size of packet to send

type TracerouteResult

type TracerouteResult struct {
	Opts *TracerouteOptions
	Hops []Hop
}

TracerouteResult type

func Traceroute

func Traceroute(opts *TracerouteOptions) (TracerouteResult, error)

Main traceroute method, we take in a set of options, and do a traceroute

Jump to

Keyboard shortcuts

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