networkstate

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0 Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package networkstate freezes address and egress facts for a connectivity generation.

Index

Constants

View Source
const DefaultDebounce = 500 * time.Millisecond
View Source
const DefaultPollInterval = time.Second
View Source
const ResumeGap = 10 * time.Second

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	IP             netip.Addr
	InterfaceIndex int
	InterfaceName  string
	AdapterID      string
	Class          string
	Tentative      bool
	Deprecated     bool
	PreferredUntil time.Time
	ValidUntil     time.Time
}

type Monitor

type Monitor struct {
	// contains filtered or unexported fields
}

func NewMonitor

func NewMonitor(source Source, debounce time.Duration) *Monitor

func (*Monitor) Current

func (m *Monitor) Current() Snapshot

func (*Monitor) Poll

func (m *Monitor) Poll(ctx context.Context, now time.Time) (Snapshot, bool, error)

Poll detects resume by an unexpectedly long observation gap. Platform route and address facts are read together and never applied to an existing snapshot.

type Observer

type Observer struct {
	Debounce time.Duration
	// contains filtered or unexported fields
}

func (*Observer) Observe

func (o *Observer) Observe(state State, now time.Time) (Snapshot, bool)

type Route

type Route struct {
	InterfaceIndex int
	Gateway        netip.Addr
	Family         int
	Metric         uint32
}

type Snapshot

type Snapshot struct {
	// contains filtered or unexported fields
}

func (Snapshot) Addresses

func (s Snapshot) Addresses() []Address

func (Snapshot) GenerationID

func (s Snapshot) GenerationID() uint64

func (Snapshot) LocalAddresses

func (s Snapshot) LocalAddresses() []netip.Addr

func (Snapshot) Routes

func (s Snapshot) Routes() []Route

type Source

type Source interface {
	Snapshot(context.Context) (State, error)
}

type State

type State struct {
	Addresses      []Address
	Routes         []Route
	ResumeSequence uint64
}

type SystemSource

type SystemSource struct{}

func (SystemSource) Snapshot

func (SystemSource) Snapshot(ctx context.Context) (State, error)

Jump to

Keyboard shortcuts

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