pinger

package module
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: MPL-2.0 Imports: 18 Imported by: 1

README

pinger

A cross platform unprivileged Ping (ICMP Echo) library for Go.

Supported Platforms

  • Linux
  • MacOS
  • Windows

And other platforms with the ping command available.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Pinger)

Option is a configuration function for Pinger.

func WithLogger added in v0.3.0

func WithLogger(logger *slog.Logger) Option

WithLogger provides a logger to use for logging.

func WithMaxChildProcesses added in v0.3.0

func WithMaxChildProcesses(n int) Option

WithMaxChildProcesses sets the maximum number of ping commands that can be run concurrently. This helps avoid an easy DoS target.

func WithPacketConnFactory added in v0.4.0

func WithPacketConnFactory(factory PacketConnFactory) Option

WithPacketConnFactory allows the use of a custom PacketConnFactory.

func WithResolver added in v0.3.0

func WithResolver(r resolver.Resolver) Option

WithResolver provides a DNS Resolver to use for resolving hostnames.

type PacketConnFactory added in v0.4.0

type PacketConnFactory func(network string) (net.PacketConn, error)

PacketConnFactory is a factory function for creating ICMP PacketConns. Known networks are "ip", "ip4", and "ip6".

type Pinger

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

Pinger sends ICMP echo requests to hosts.

func New

func New(opts ...Option) *Pinger

New creates a new Pinger.

func (*Pinger) Ping

func (p *Pinger) Ping(ctx context.Context, network, host string) error

Ping sends an ICMP echo request to the specified host. Known networks are "ip", "ip4", and "ip6".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳