network

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 15 Imported by: ? modules, 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.

README

system/network

github.com/webong/ext/res/system/service/network observes networking supplied by the local operating system: interfaces, assigned addresses, route tables, and resolver configuration. It opens no sockets, performs no lookup, sends no traffic, and does not mutate network configuration.

Each collection has its own status so an empty result is distinguishable from an unsupported, inaccessible, partial, or unavailable OS source. Linux route tables are read from procfs. Interface observation is portable; platforms that do not yet expose route or resolver configuration report that explicitly.

On macOS the Go and Swift bindings read the kernel routing MIB and public SystemConfiguration DNS state directly, without subprocesses. Resolver status is partial because this state omits supplemental resolver policy; Go builds with cgo disabled explicitly report DNS observation as unsupported. iOS route and resolver observation remains unsupported.

The Apple and Android bindings live under ios/ and android/ and ship as the ExtNetwork and io.github.webong.ext.network products in the native SDKs. They remain local observers. Connection clients, tunnels, remote discovery, service routing, credentials, and authorization belong to their consumers.

Documentation

Overview

Package network observes the local network stack. It does not dial, listen, resolve names, change routes, configure interfaces, or contact remote hosts.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalid = errors.New("invalid network value")

ErrInvalid reports a malformed option, status or address.

Functions

func Code added in v0.4.0

func Code(err error) string

Code is the stable error code of err for another language to match: invalid. It is empty for an error this package does not define.

Types

type Address

type Address struct {
	IP           string `json:"ip"`
	PrefixLength int    `json:"prefix_length"`
	Family       string `json:"family"`
	Scope        string `json:"scope"`
}

Address is an address assigned to a local interface.

type CollectionStatus

type CollectionStatus struct {
	State      string     `json:"state"`
	Reason     string     `json:"reason,omitempty"`
	Detail     string     `json:"detail,omitempty"`
	ObservedAt *time.Time `json:"observed_at,omitempty"`
}

CollectionStatus distinguishes empty OS data from unavailable or unsupported collection. State is complete, partial, permission-denied, unsupported, or unavailable. Reason says why something is missing, from the same set in every package (testdata/capability/v1): unsupported on this platform, permission, no_device or tool_missing.

func (CollectionStatus) Validate added in v0.4.0

func (s CollectionStatus) Validate() error

Validate checks that the state is known and the reason fits it: none for complete and partial, permission or none for permission-denied, unsupported or tool_missing for unsupported, and none, permission, no_device or tool_missing for unavailable (a failed native read has no reason).

type Interface

type Interface struct {
	Index           int       `json:"index"`
	Name            string    `json:"name"`
	MTU             int       `json:"mtu"`
	HardwareAddress string    `json:"hardware_address,omitempty"`
	Flags           []string  `json:"flags"`
	Addresses       []Address `json:"addresses"`
}

Interface is an OS network interface visible to the current process.

type Options

type Options struct {
	MaxInterfaces int
	MaxAddresses  int
	MaxRoutes     int
	Timeout       time.Duration
}

Options bounds records and collection time. Every field is explicit and a zero is invalid, as in the other bindings (testdata/network/v1); start from DefaultOptions (256 interfaces, 4096 routes, 256 addresses per interface, five seconds) and change what differs.

func DefaultOptions added in v0.5.0

func DefaultOptions() Options

DefaultOptions returns the default of every limit and the default timeout.

func (Options) Validate added in v0.5.0

func (o Options) Validate() error

Validate checks that every limit is between 1 and 65536 and that the timeout is positive.

type Resolver

type Resolver struct {
	Servers []string `json:"servers"`
	Search  []string `json:"search"`
	Options []string `json:"options"`
}

Resolver describes the local resolver configuration without performing a lookup. Servers never include credentials.

type Route

type Route struct {
	Destination string `json:"destination"`
	Gateway     string `json:"gateway,omitempty"`
	Interface   string `json:"interface,omitempty"`
	Metric      int    `json:"metric,omitempty"`
	Default     bool   `json:"default"`
}

Route is an entry in the local route table. Destination is CIDR. An empty gateway means an on-link route. Interface names are local OS identities.

type Snapshot

type Snapshot struct {
	Platform        string           `json:"platform"`
	ObservedAt      time.Time        `json:"observed_at"`
	Interfaces      []Interface      `json:"interfaces"`
	Routes          []Route          `json:"routes"`
	Resolver        Resolver         `json:"resolver"`
	InterfaceStatus CollectionStatus `json:"interface_status"`
	RouteStatus     CollectionStatus `json:"route_status"`
	ResolverStatus  CollectionStatus `json:"resolver_status"`
}

Snapshot is a bounded, non-atomic observation of local network state.

func Discover

func Discover(ctx context.Context, options Options) (Snapshot, error)

Discover observes local network interfaces, routes, and resolver settings. It performs no DNS lookup and opens no network connection.

Directories

Path Synopsis
linux
guest module

Jump to

Keyboard shortcuts

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