Documentation
¶
Overview ¶
This file code is based on https://github.com/go-ping/ping
Index ¶
- Constants
- Variables
- type IcmpStats
- type Packet
- type Pinger
- func (p *Pinger) ParsePacket(recv *Packet) IcmpStats
- func (p *Pinger) PrepareICMP(addr netip.Addr, seq uint16) (*Packet, error)
- func (p *Pinger) Privileged() bool
- func (p *Pinger) RecvICMP(proto ProtocolVersion) IcmpStats
- func (p *Pinger) RecvPacket(proto ProtocolVersion) (*Packet, error)
- func (p *Pinger) SendICMP(addr netip.Addr, sequence uint16) error
- func (p *Pinger) SendPacket(pkt *Packet) error
- func (p *Pinger) SetConns(c4 *icmp.PacketConn, c6 *icmp.PacketConn)
- func (p *Pinger) SetPrivileged(privileged bool)
- type ProtocolVersion
Constants ¶
View Source
const ( ProtocolICMP = 1 ProtocolIPv6ICMP = 58 )
View Source
const ( ProtocolIpv4 = ProtocolVersion(4) ProtocolIpv6 = ProtocolVersion(6) )
Variables ¶
View Source
var ( ErrInvalidConn = errors.New("invalid connection") ErrInvalidAddr = errors.New("invalid address") )
Functions ¶
This section is empty.
Types ¶
type Pinger ¶
type Pinger struct { // Size of packet being sent Size int // Tracker: Used to uniquely identify packet when non-priviledged Tracker int64 // contains filtered or unexported fields }
Pinger represents a packet sender.
func (*Pinger) ParsePacket ¶
func (*Pinger) PrepareICMP ¶
func (*Pinger) Privileged ¶
Privileged returns whether pinger is running in privileged mode.
func (*Pinger) RecvICMP ¶
func (p *Pinger) RecvICMP(proto ProtocolVersion) IcmpStats
func (*Pinger) RecvPacket ¶
func (p *Pinger) RecvPacket(proto ProtocolVersion) (*Packet, error)
func (*Pinger) SendPacket ¶
func (*Pinger) SetConns ¶
func (p *Pinger) SetConns(c4 *icmp.PacketConn, c6 *icmp.PacketConn)
SetConns setups IPv4 and IPv6 connections to pinger
func (*Pinger) SetPrivileged ¶
SetPrivileged sets the type of ping pinger will send. false means pinger will send an "unprivileged" UDP ping. true means pinger will send a "privileged" raw ICMP ping. NOTE: setting to true requires that it be run with super-user privileges.
type ProtocolVersion ¶
type ProtocolVersion int
Click to show internal directories.
Click to hide internal directories.