Documentation
¶
Overview ¶
Package ping allows sending ICMP echo requests to a host in order to determine network latency.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ListenPacketer ¶ added in v1.42.0
type ListenPacketer interface {
ListenPacket(ctx context.Context, typ string, addr string) (net.PacketConn, error)
}
PacketListener defines the interface required to listen to packages on an address.
type Pinger ¶
type Pinger struct {
// Unprivileged, when set, makes the Pinger use non-privileged
// datagram-oriented ICMP sockets ("udp4"/"udp6") opened via
// golang.org/x/net/icmp.ListenPacket instead of raw ICMP sockets
// ("ip4:icmp"/"ip6:icmp") opened via the configured ListenPacketer.
//
// Unprivileged mode is supported on macOS, iOS, and Linux (subject to
// the /proc/sys/net/ipv4/ping_group_range sysctl). When set, the
// ListenPacketer passed to New is ignored and the kernel rewrites the
// outgoing ICMP echo ID to match the socket; replies are matched by
// sequence number and echo data only.
//
// Must be set before the first call to Send.
Unprivileged bool
Verbose bool // verbose logging
Logf logger.Logf // optional logging function; if nil, logs to the standard logger
// contains filtered or unexported fields
}
Pinger represents a set of ICMP echo requests to be sent at a single time.
A new instance should be created for each concurrent set of ping requests; this type should not be reused.
func New ¶
New creates a new Pinger. The Context provided will be used to create network listeners, and to set an absolute deadline (if any) on the net.Conn
Click to show internal directories.
Click to hide internal directories.