connchecker

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCheckInterval = time.Second

	ConnRe       = "Internet connectivity re-established"
	ConnLost     = "Internet connectivity lost"
	ConnFound    = "Internet connectivity found"
	ConnNotFound = "No internet connectivity"
)

DefaultCheckInterval is a const that defines the amount of time between checking if the connection is lost

Variables

View Source
var (
	DefaultDNSList    = []string{"8.8.8.8", "8.8.4.4", "1.1.1.1", "1.0.0.1"}
	DefaultDomainList = []string{"www.google.com", "www.cloudflare.com", "www.facebook.com"}
)

Default check lists

Functions

This section is empty.

Types

type Checker

type Checker struct {
	DNSList       []string
	DomainList    []string
	CheckInterval time.Duration
	// contains filtered or unexported fields
}

Checker defines a struct to determine connectivity to the interwebs

func New

func New(dnsList, domainList []string, checkInterval time.Duration) (*Checker, error)

New returns a new connection checker, if no values set it will default it out

func (*Checker) CheckDNS

func (c *Checker) CheckDNS(dns string) error

CheckDNS checks current dns for connectivity

func (*Checker) CheckHost

func (c *Checker) CheckHost(host string) error

CheckHost checks current host name for connectivity

func (*Checker) IsConnected

func (c *Checker) IsConnected() bool

IsConnected returns if there is internet connectivity

func (*Checker) Monitor

func (c *Checker) Monitor(wg *sync.WaitGroup)

Monitor determines internet connectivity via a DNS lookup

func (*Checker) Shutdown

func (c *Checker) Shutdown()

Shutdown cleanly shutsdown monitor routine

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL