Documentation
¶
Overview ¶
Package netevents owns the OS network event handling shared by the mobile bindings: availability changes park or wake the reconnection loops and drive the NoNetwork listener state, and both losing the last network and switching networks sweep the stale connections so their owners redial immediately.
Index ¶
- type Manager
- func (m *Manager) Changed() <-chan struct{}
- func (m *Manager) IsOnline() bool
- func (m *Manager) NotifyNetworkChange()
- func (m *Manager) QuickRetryBackoff(ctx context.Context, bo backoff.BackOff) backoff.BackOff
- func (m *Manager) SetNetworkAvailable(available bool)
- func (m *Manager) StartDial(ctx context.Context) *sweep.Dial
- func (m *Manager) Wait(ctx context.Context) (bool, error)
- func (m *Manager) WaitSettled(ctx context.Context, budget, settleWindow time.Duration) bool
- type Recorder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager ties the network availability state, the connection sweeper and the status recorder together; it outlives engine restarts. A nil *Manager is the valid no-events value for consumers: the read methods report always-online and never sweep. Only the event sources hold a real Manager, so the write methods do not tolerate a nil receiver.
func NewManager ¶
NewManager creates a Manager reporting into recorder, starting online.
func (*Manager) Changed ¶
func (m *Manager) Changed() <-chan struct{}
Changed returns a channel closed on the next availability transition.
func (*Manager) NotifyNetworkChange ¶
func (m *Manager) NotifyNetworkChange()
NotifyNetworkChange marks the management, signal and relay connections stale after the OS switched networks and schedules a sweep that cuts whatever has not redialed on the new network by then. The engine and the TUN device stay untouched.
Panics on a nil receiver: only the mobile bindings that own a Manager report network changes.
func (*Manager) QuickRetryBackoff ¶
QuickRetryBackoff wraps bo for a quick retry after a network change; see sweep.Sweeper.QuickRetryBackoff.
func (*Manager) SetNetworkAvailable ¶
SetNetworkAvailable records OS-reported network availability. While unavailable, the reconnection loops suspend their attempts and the connection listener reports NoNetwork instead of Connecting; when availability returns, the loops resume immediately with a fresh backoff. Losing the last network also sweeps the registered connections: nothing can redial while offline, so the stale sockets would otherwise stay silently "connected" until their own timeouts and the client would keep reporting Connected with no network at all.
Panics on a nil receiver: only the mobile bindings that own a Manager report availability.
func (*Manager) StartDial ¶
StartDial registers an in-flight dial with the sweeper; see sweep.Sweeper.StartDial.
func (*Manager) WaitSettled ¶
WaitSettled waits until an online verdict holds for a full settleWindow, or while offline until the budget runs out. Returns false when ctx is cancelled. The settle window exists because a disconnect often precedes the OS offline flag by a few milliseconds, so a fresh online verdict cannot be trusted immediately. A nil Manager has no events to watch: it degrades to a fixed budget-long sleep.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package netstate tracks OS-reported network availability for the client.
|
Package netstate tracks OS-reported network availability for the client. |
|
Package sweep cuts network-bound activity when the OS switches networks: a sweep closes the registered connections and aborts the in-flight dials, so their owners redial immediately instead of waiting for the old sockets to time out.
|
Package sweep cuts network-bound activity when the OS switches networks: a sweep closes the registered connections and aborts the in-flight dials, so their owners redial immediately instead of waiting for the old sockets to time out. |