Documentation ¶
Index ¶
- type Pinger
- func (p *Pinger) Default(src net.IP, dst net.IP, amt *int) error
- func (p Pinger) GetAmt() int
- func (p Pinger) GetConn() *icmp.PacketConn
- func (p Pinger) GetDst() net.IP
- func (p Pinger) GetSrc() net.IP
- func (p Pinger) NewConn() (*icmp.PacketConn, error)
- func (p *Pinger) Ping() error
- func (p Pinger) PingPong(args ...interface{}) ([]*icmp.Message, error)
- func (p Pinger) Pong(timeout int) (msgList []*icmp.Message, err error)
- func (p Pinger) RecvOnePong() (*icmp.Message, error)
- func (p Pinger) SendOnePing(seq int, conn *icmp.PacketConn) error
- func (p *Pinger) SetAmt(amt int) int
- func (p *Pinger) SetDst(dst net.IP) (net.IP, error)
- func (p *Pinger) SetSrc(src net.IP) (net.IP, error)
- func (p Pinger) String() string
- type TimeoutError
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 ¶
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) NewConn ¶
func (p Pinger) NewConn() (*icmp.PacketConn, error)
NewConn creates the icmp packet "connection"
func (Pinger) PingPong ¶
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 ¶
Pong receives a ping from the specified dst with amt packets asynchronously with timeout
func (Pinger) RecvOnePong ¶
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) SetDst ¶
SetDst is a setter function that does some required changes while setting dst,
including changing the src IP
type TimeoutError ¶
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