Documentation
¶
Overview ¶
Package ping sends and receives icmp echo request/reply packets over a UDP socket. Both IPv4 and IPv6 are supported.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrTimeout = errors.New("timeout waiting for response")
)
Functions ¶
This section is empty.
Types ¶
type Response ¶
type Response struct {
From net.IP
Request Request
ResponseType ResponseType
Latency time.Duration
}
Response represents an icmp packet received by the Socket.
type ResponseType ¶
type ResponseType int
const ( ResponseEchoReply ResponseType = iota ResponseTimeExceeded ResponseTimeout )
func (ResponseType) String ¶
func (rt ResponseType) String() string
type SequenceNumber ¶
type SequenceNumber uint16
SequenceNumber represents the sequence number of an icmp packet.
type Socket ¶
func (*Socket) Read ¶
Read reads the next icmp packet from the socket. It blocks until a packet is received or the context is canceled.
func (*Socket) Resolve ¶
Resolve resolves the provided host to an IP address and returns it. Resolve returns an error if the host does not have a valid IP address of a type supported by the socket (e.g., if the socket only supports IPv6, but the host doesn't have an IPv4 address).
type SocketOption ¶
func WithIPv4 ¶
func WithIPv4() SocketOption
func WithIPv6 ¶
func WithIPv6() SocketOption
func WithLogger ¶
func WithLogger(l *slog.Logger) SocketOption
func WithTimeout ¶
func WithTimeout(d time.Duration) SocketOption
func WithoutCheckID ¶
func WithoutCheckID() SocketOption
Click to show internal directories.
Click to hide internal directories.