Documentation ¶
Overview ¶
Package connectivity implements a single, simple stream of booleans to answer the question "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 ¶
This section is empty.
Types ¶
type ConnectedState ¶
type ConnectedState struct {
// contains filtered or unexported fields
}
ConnectedState helps tracking connectivity.
func New ¶
func New(endp bus.Endpoint, config ConnectivityConfig, log logger.Logger) *ConnectedState
New makes a ConnectedState for connectivity tracking.
The endpoint need not be dialed; Track() will Dial() and Close() it as it sees fit.
func (*ConnectedState) Cancel ¶
func (cs *ConnectedState) Cancel()
Cancel stops the ConnectedState machinary.
func (*ConnectedState) Track ¶
func (cs *ConnectedState) Track(out chan<- bool)
Track 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.
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, intended to be populated 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) // Close idle connections. Close() }
func NewWebchecker ¶
Build a webchecker for the given URL, that should match the target MD5.