netenv

package
v0.4.17 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2020 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NetworkChangedEvent      = "network changed"
	OnlineStatusChangedEvent = "online status changed"
)

Event Names

Variables

View Source
var (
	PortalTestIP  = net.IPv4(255, 255, 255, 254)
	PortalTestURL = fmt.Sprintf("http://%s/", PortalTestIP)

	DNSTestDomain     = "one.one.one.one."
	DNSTestExpectedIP = net.IPv4(1, 1, 1, 1)

	SpecialCaptivePortalDomain = "captiveportal.local."
)

Online Status and Resolver

Functions

func Gateways

func Gateways() []net.IP

Gateways returns the currently active gateways.

func GetApproximateInternetLocation

func GetApproximateInternetLocation() (net.IP, error)

GetApproximateInternetLocation returns the IP-address of the nearest ping-answering internet node

func GetAssignedAddresses

func GetAssignedAddresses() (ipv4 []net.IP, ipv6 []net.IP, err error)

GetAssignedAddresses returns the assigned IPv4 and IPv6 addresses of the host.

func GetAssignedGlobalAddresses

func GetAssignedGlobalAddresses() (ipv4 []net.IP, ipv6 []net.IP, err error)

GetAssignedGlobalAddresses returns the assigned global IPv4 and IPv6 addresses of the host.

func IsConnectivityDomain added in v0.4.12

func IsConnectivityDomain(domain string) bool

IsConnectivityDomain checks whether the given domain (fqdn) is used for any connectivity related network connections and should always be resolved using the network assigned DNS server.

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

func SetLocalAddrFactory(laf func(network string) net.Addr)

SetLocalAddrFactory supplies the environment package with a function to get permitted local addresses for connections.

Types

type CaptivePortal added in v0.4.12

type CaptivePortal struct {
	URL    string
	Domain string
	IP     net.IP
}

CaptivePortal holds information about a detected captive portal.

func GetCaptivePortal added in v0.4.12

func GetCaptivePortal() *CaptivePortal

GetCaptivePortal returns the current captive portal. The returned struct must not be edited.

type Nameserver

type Nameserver struct {
	IP     net.IP
	Search []string
}

Nameserver describes a system assigned namserver.

func Nameservers

func Nameservers() []Nameserver

Nameservers returns the currently active nameservers.

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

Jump to

Keyboard shortcuts

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