Back to godoc.org
github.com/pgollangi/netselect

Package netselect

v1.1.0
Latest Go to latest

The latest major version is .

Published: Sep 1, 2020 | License: MIT | Module: github.com/pgollangi/netselect

Index

type Host

type Host struct {
	// Unique ID
	ID string
	// Address of the Host. If URL provided, Host name will be extracted.
	Address string
}

Host represents a input address to NetSelector

func NewHost

func NewHost(id string, address string) (host *Host, err error)

NewHost creates and returns new Host instance

type HostStats

type HostStats struct {
	Host *Host

	Success bool

	Error error
	// PacketsRecv is the number of packets received.
	PacketsRecv int

	// PacketsSent is the number of packets sent.
	PacketsSent int

	// PacketLoss is the percentage of packets lost.
	PacketLoss float64

	// IPAddr is the address of the host being pinged.
	IPAddr *net.IPAddr

	// Addr is the string address of the host being pinged.
	Addr string

	// Rtts is all of the round-trip times sent via this pinger.
	Rtts []time.Duration

	// MinRtt is the minimum round-trip time sent via this pinger.
	MinRtt time.Duration

	// MaxRtt is the maximum round-trip time sent via this pinger.
	MaxRtt time.Duration

	// AvgRtt is the average round-trip time sent via this pinger.
	AvgRtt time.Duration

	// StdDevRtt is the standard deviation of the round-trip times sent via
	// this pinger.
	StdDevRtt time.Duration
}

HostStats represents the results of one particular host

type NetSelector

type NetSelector struct {
	Hosts      []*Host
	Debug      bool
	Attempts   int
	Timeout    time.Duration
	Privileged bool
	Threads    int
}

NetSelector represents the instance of a NetSelector

func NewNetSelector

func NewNetSelector(hosts []*Host) (*NetSelector, error)

NewNetSelector instantiate new instance of NetSelector

func (*NetSelector) Select

func (s *NetSelector) Select() ([]*HostStats, error)

Select finds the faster hosts among the provided inputs, and sort the resulted host in ASC order

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier