core

package
v1.0.0-...-3a35940 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package core provides command line parsing & DNS lookup conveniences.

Package core provides utilities

Index

Constants

This section is empty.

Variables

View Source
var ErrBadCount = errors.New("bad number of packets to transmit")

ErrBadCount signifies that count packets must be greater than or equal to 1.

View Source
var ErrMissingPeer = errors.New("peer argument is nil")

ErrMissingPeer means the client provided nil as a peer argument.

View Source
var ErrNoTarget = errors.New("Missing target")

ErrNoTarget means the target was not supplied

View Source
var ErrPeerNotResolving = errors.New("peer not resolving")

ErrPeerNotResolving means no reverse IP for the peer was found.

View Source
var ErrUnknownHost = errors.New("Name or service not known")

ErrUnknownHost means we cannot parse the IP address or the FQDN that was provided.

View Source
var Usage = `` /* 325-byte string literal not displayed */

Usage is the help blurb

Functions

func GetCNAME

func GetCNAME(h string) string

GetCNAME returns an empty string or the actual CNAME

func NewEcho

func NewEcho(payload string, seq int) icmp.Message

NewEcho constructs an ICMP packet.

func ParseAddr

func ParseAddr(input string) *net.IPAddr

ParseAddr returns the IPv4 address. Potentially could be a nil return value.

func ParseOption

func ParseOption(options []string) (bool, bool, uint64, *net.IPAddr, string, string, error)

ParseOption parses command line arguments

func ScanInterfaces

func ScanInterfaces() (map[string]net.IP, error)

ScanInterfaces returns a map from the interface name to an IPv4 address

func TryConvertPunycode

func TryConvertPunycode(domain string) string

TryConvertPunycode attempts to convert the domain if it is punycode encoded

Types

type Arg

type Arg struct {
	Host      string
	Interface string
	Help      bool
	Extra     bool
	Count     uint64
}

Arg holds the command line arguments.

type Cache

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

Cache saves the last reverse ip lookup.

func NewCache

func NewCache() *Cache

NewCache returns a new Cache instance.

func (*Cache) Reverse

func (c *Cache) Reverse(peer net.Addr) (string, error)

Reverse caches reverse IP resolution

type Counter

type Counter struct {
	Sent   uint64
	Recvd  uint64
	Loss   uint32
	Err    bool
	Errors uint64
	// contains filtered or unexported fields
}

Counter keeps track of messages sent & received

func NewCounter

func NewCounter() *Counter

NewCounter constructs a new Counter

func (*Counter) NeedStatistics

func (c *Counter) NeedStatistics() bool

NeedStatistics informs the caller if more statistics can be printed.

func (*Counter) NoteAnError

func (c *Counter) NoteAnError()

func (*Counter) OnReception

func (c *Counter) OnReception()

OnReception remembers how many ICMP Echo Reply was received.

func (*Counter) OnSent

func (c *Counter) OnSent()

OnSent remembers how many ICMP Echo was sent.

func (*Counter) Render

func (c *Counter) Render(w io.Writer, header string)

Render calculates detailed packet loss percentages and writes them to the supplied Writer.

Jump to

Keyboard shortcuts

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