Documentation ¶
Index ¶
- Constants
- func Gateways() []*net.IP
- func GetApproximateInternetLocation() (net.IP, error)
- func GetAssignedAddresses() (ipv4 []net.IP, ipv6 []net.IP, err error)
- func GetAssignedGlobalAddresses() (ipv4 []net.IP, ipv6 []net.IP, err error)
- func GetCaptivePortalURL() string
- func GetResolverTestingRequestData() (fqdn string, rrType uint16, expectedResponse string)
- func IsOnlineStatusTestDomain(domain string) bool
- func Online() bool
- func ReportFailedConnection()
- func ReportSuccessfulConnection()
- func SetLocalAddrFactory(laf func(network string) net.Addr)
- type Nameserver
- type OnlineStatus
Constants ¶
const ( NetworkChangedEvent = "network changed" OnlineStatusChangedEvent = "online status changed" )
Event Names
const ( HTTPTestURL = "http://detectportal.firefox.com/success.txt" HTTPExpectedContent = "success" HTTPSTestURL = "https://one.one.one.one/" ResolverTestFqdn = "one.one.one.one." ResolverTestRRType = dns.TypeA ResolverTestExpectedResponse = "1.1.1.1" )
Online Status and Resolver
Variables ¶
This section is empty.
Functions ¶
func GetApproximateInternetLocation ¶
GetApproximateInternetLocation returns the IP-address of the nearest ping-answering internet node
func GetAssignedAddresses ¶
GetAssignedAddresses returns the assigned IPv4 and IPv6 addresses of the host.
func GetAssignedGlobalAddresses ¶
GetAssignedGlobalAddresses returns the assigned global IPv4 and IPv6 addresses of the host.
func GetCaptivePortalURL ¶
func GetCaptivePortalURL() string
GetCaptivePortalURL returns the current captive portal url as a string.
func GetResolverTestingRequestData ¶
GetResolverTestingRequestData returns request information that should be used to test DNS resolvers for availability and basic correct behaviour.
func IsOnlineStatusTestDomain ¶
IsOnlineStatusTestDomain checks whether the given fqdn is used for testing online status.
func Online ¶
func Online() bool
Online returns true if online status is either SemiOnline or Online.
func ReportFailedConnection ¶
func ReportFailedConnection()
ReportFailedConnection hints the online status monitoring system that a connection attempt has failed. This function has extremely low overhead and may be called as much as wanted.
func ReportSuccessfulConnection ¶
func ReportSuccessfulConnection()
ReportSuccessfulConnection hints the online status monitoring system that a connection attempt was successful.
func SetLocalAddrFactory ¶
SetLocalAddrFactory supplies the environment package with a function to get permitted local addresses for connections.
Types ¶
type Nameserver ¶
Nameserver describes a system assigned namserver.
func Nameservers ¶
func Nameservers() []Nameserver
type OnlineStatus ¶
type OnlineStatus uint8
OnlineStatus represent a state of connectivity to the Internet.
const ( StatusUnknown OnlineStatus = 0 StatusOffline OnlineStatus = 1 StatusLimited OnlineStatus = 2 // local network only StatusPortal OnlineStatus = 3 // there seems to be an internet connection, but we are being intercepted, possibly by a captive portal StatusSemiOnline OnlineStatus = 4 // we seem to online, but without full connectivity StatusOnline OnlineStatus = 5 )
Online Status Values
func CheckAndGetOnlineStatus ¶
func CheckAndGetOnlineStatus() OnlineStatus
CheckAndGetOnlineStatus triggers a new online status check and returns the result
func GetOnlineStatus ¶
func GetOnlineStatus() OnlineStatus
GetOnlineStatus returns the current online stats.
func (OnlineStatus) String ¶
func (os OnlineStatus) String() string