network

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 14 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

This section is empty.

Functions

This section is empty.

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"`
	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.

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. Zero values select 256 interfaces, 4096 routes, 256 addresses per interface, and five seconds.

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