pinger

package module
v0.0.0-...-2c8f56e Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pinger

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

Pinger structure has the following properties - src (source) IP address (most likely 127.0.0.1) - dst (destination) IP address (set by the user) - amt (amount) of pings to the dst IP address.

func NewPinger

func NewPinger() Pinger

NewPinger creates a default Pinger by calling p.Default() and returns p

func (*Pinger) Default

func (p *Pinger) Default(src net.IP, dst net.IP, amt *int) error

Default values for ping if the user is lazy and does not want to specify details if nil, do default value.

Default values for each field: - src: Default Gateway Interface (192.168.2.*) - dst: Default Gateway Interface (192.168.2.*) - amt: 32

func (Pinger) GetAmt

func (p Pinger) GetAmt() int

GetAmt is a getter for p.amt

func (Pinger) GetConn

func (p Pinger) GetConn() *icmp.PacketConn

GetConn returns a conn

func (Pinger) GetDst

func (p Pinger) GetDst() net.IP

GetDst is a getter for p.dst

func (Pinger) GetSrc

func (p Pinger) GetSrc() net.IP

GetSrc is a getter for p.src

func (Pinger) NewConn

func (p Pinger) NewConn() (*icmp.PacketConn, error)

NewConn creates the icmp packet "connection"

func (*Pinger) Ping

func (p *Pinger) Ping() error

Ping sends a ping to the specified dst with amt packets

func (Pinger) PingPong

func (p Pinger) PingPong(args ...interface{}) ([]*icmp.Message, error)

PingPong sends an echo request with Ping and receives a result with Pong. usage: p.PingPong() // uses default timeout time of 1000ms p.PingPong(500) // set the timeout to 500ms

func (Pinger) Pong

func (p Pinger) Pong(timeout int) (msgList []*icmp.Message, err error)

Pong receives a ping from the specified dst with amt packets asynchronously with timeout

func (Pinger) RecvOnePong

func (p Pinger) RecvOnePong() (*icmp.Message, error)

RecvOnePong receives the result of a SendPing message. Must include packet connection.

func (Pinger) SendOnePing

func (p Pinger) SendOnePing(seq int, conn *icmp.PacketConn) error

SendOnePing pings a server with one packet. Can also pass a connection as parameter.

func (*Pinger) SetAmt

func (p *Pinger) SetAmt(amt int) int

SetAmt to set private value amt

func (*Pinger) SetDst

func (p *Pinger) SetDst(dst net.IP) (net.IP, error)

SetDst is a setter function that does some required changes while setting dst,

including changing the src IP

func (*Pinger) SetSrc

func (p *Pinger) SetSrc(src net.IP) (net.IP, error)

SetSrc to set private value src

func (Pinger) String

func (p Pinger) String() string

type TimeoutError

type TimeoutError struct {
	Pinger  Pinger
	Timeout int
}

TimeoutError is for Ping when it times out. It returns a pinger object, and timeout interval (in milliseconds).

func (*TimeoutError) Error

func (e *TimeoutError) Error() string

Jump to

Keyboard shortcuts

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