Documentation ¶
Index ¶
- Constants
- Variables
- type Hop
- type Option
- func (opt *Option) DisableFixedDstPort()
- func (opt *Option) DisablePrivileged()
- func (opt *Option) DisableResolveHost()
- func (opt *Option) EnableFixedDstPort()
- func (opt *Option) EnablePrivileged()
- func (opt *Option) EnableResolveHost()
- func (opt *Option) FirstHop() int
- func (opt *Option) FixedDstPort() bool
- func (opt *Option) MaxHops() int
- func (opt *Option) NRequeries() int
- func (opt *Option) PacketSize() int
- func (opt *Option) Port() int
- func (opt *Option) Privileged() bool
- func (opt *Option) ResolveHost() bool
- func (opt *Option) SetFirstHop(firstHop int)
- func (opt *Option) SetMaxHops(maxHops int)
- func (opt *Option) SetNRequeries(nqueries int)
- func (opt *Option) SetPacketSize(packetSize int)
- func (opt *Option) SetPort(port int)
- func (opt *Option) SetTimeoutMs(timeoutMs int)
- func (opt *Option) TimeoutMs() int
- type TraceResult
Constants ¶
View Source
const ( DEFAULT_PORT = 33434 DEFAULT_MAX_HOPS = 64 DEFAULT_FIRST_HOP = 1 DEFAULT_TIMEOUT_MS = 500 DEFAULT_NQUERIES = 1 DEFAULT_PACKET_SIZE = 0 )
Variables ¶
View Source
var DefaultOption = &Option{ port: DEFAULT_PORT, maxHops: DEFAULT_MAX_HOPS, firstHop: DEFAULT_FIRST_HOP, timeoutMs: DEFAULT_TIMEOUT_MS, nqueries: DEFAULT_NQUERIES, packetSize: DEFAULT_PACKET_SIZE, privileged: true, fixedDstPort: false, }
DefaultOption provides a default opt.
Functions ¶
This section is empty.
Types ¶
type Hop ¶
type Hop struct { Success bool Address net.Addr Host string N int ElapsedTime time.Duration TTL int }
Hop type
func (*Hop) AddressString ¶
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
TracrouteOption type
func (*Option) DisableFixedDstPort ¶
func (opt *Option) DisableFixedDstPort()
func (*Option) DisablePrivileged ¶
func (opt *Option) DisablePrivileged()
func (*Option) DisableResolveHost ¶
func (opt *Option) DisableResolveHost()
func (*Option) EnableFixedDstPort ¶
func (opt *Option) EnableFixedDstPort()
func (*Option) EnablePrivileged ¶
func (opt *Option) EnablePrivileged()
func (*Option) EnableResolveHost ¶
func (opt *Option) EnableResolveHost()
func (*Option) FixedDstPort ¶
func (*Option) NRequeries ¶
func (*Option) PacketSize ¶
func (*Option) Privileged ¶
func (*Option) ResolveHost ¶
func (*Option) SetFirstHop ¶
func (*Option) SetMaxHops ¶
func (*Option) SetNRequeries ¶
func (*Option) SetPacketSize ¶
func (*Option) SetTimeoutMs ¶
type TraceResult ¶
TraceResult type
func Trace ¶
func Trace(dest string, opt *Option, c ...chan Hop) (result TraceResult, err error)
Trace uses the given dest (hostname) and option to execute a traceroute from your machine to the remote host by using golang.org/x/net/icmp.
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.
Click to show internal directories.
Click to hide internal directories.