common

package
v0.0.0-...-15ba433 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package common contains common functionality for both TCP and UDP traceroute implementations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LocalAddrForHost

func LocalAddrForHost(destIP net.IP, destPort uint16) (*net.UDPAddr, net.Conn, error)

LocalAddrForHost takes in a destionation IP and port and returns the local address that should be used to connect to the destination. The returned connection should be closed by the caller when the the local UDP port is no longer needed

Types

type CanceledError

type CanceledError string

CanceledError is sent when a listener is canceled

func (CanceledError) Error

func (c CanceledError) Error() string

Error implements the error interface for CanceledError

type Hop

type Hop struct {
	IP       net.IP
	Port     uint16
	ICMPType layers.ICMPv4TypeCode
	RTT      time.Duration
	IsDest   bool
}

Hop encapsulates information about a single hop in a traceroute

type MatcherFunc

type MatcherFunc func(*ipv4.Header, []byte, net.IP, uint16, net.IP, uint16, uint32) (net.IP, error)

MatcherFunc defines functions for matching a packet from the wire to a traceroute based on the source/destination addresses and an identifier

type MismatchError

type MismatchError string

MismatchError is an error type that indicates a MatcherFunc failed due to one or more fields from the packet not matching the expected information

func (MismatchError) Error

func (m MismatchError) Error() string

Error implements the error interface for MismatchError

type Results

type Results struct {
	Source     net.IP
	SourcePort uint16
	Target     net.IP
	DstPort    uint16
	Hops       []*Hop
}

Results encapsulates a response from the traceroute

Jump to

Keyboard shortcuts

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