Documentation ¶
Overview ¶
Package connectivity a single, simple stream of booleans to answer the quesiton “are we connected?”.
It can potentially fire two falses in a row, if a disconnected state is followed by a dbus watch error. Other than that, it's edge triggered.
webchecker checks whether we're actually connected by doing an http GET to the Ubuntu connectivity check URL, http://start.ubuntu.com/connectivity-check.html
We could make it be https to make extra doubly sure, but it's expensive overkill for the majority of cases.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectedState ¶
func ConnectedState(endp bus.Endpoint, config ConnectivityConfig, log logger.Logger, out chan<- bool)
ConnectedState sends the initial NetworkManager state and changes to it over the "out" channel. Sends "false" as soon as it detects trouble, "true" after checking actual connectivity.
The endpoint need not be dialed; connectivity will Dial() and Close() it as it sees fit.
Types ¶
type ConnectivityConfig ¶
type ConnectivityConfig struct { // how long to wait after a state change to make sure it's "stable" // before acting on it StabilizingTimeout config.ConfigTimeDuration `json:"stabilizing_timeout"` // How long to wait between online connectivity checks. RecheckTimeout config.ConfigTimeDuration `json:"recheck_timeout"` // The URL against which to do the connectivity check. ConnectivityCheckURL string `json:"connectivity_check_url"` // The expected MD5 of the content at the ConnectivityCheckURL ConnectivityCheckMD5 string `json:"connectivity_check_md5"` }
the configuration for ConnectedState, with the idea that you'd populate it from a config file.
type Webchecker ¶
type Webchecker interface { // Webcheck checks whether retrieving the URL works, and if its // contents match the target. If so, then it sends true; if anything // fails, it sends false. Webcheck(chan<- bool) }
func NewWebchecker ¶
func NewWebchecker(url string, target string, log logger.Logger) Webchecker
Build a webchecker for the given URL, that should match the target MD5.