hostnetwork

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 4 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 hostnetwork inspects Linux network interfaces for future role plans. It does not apply or authorize network changes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Link struct {
	Name        string   `json:"name"`
	State       string   `json:"state"`
	MTU         int      `json:"mtu"`
	MAC         string   `json:"mac,omitempty"`
	Addresses   []string `json:"addresses,omitempty"`
	Inspectable bool     `json:"inspectable"`
}

Link describes one interface for choosing an interface to inspect. Only an interface marked Inspectable may be passed to Inspect.

func List

func List(ctx context.Context, r Runner) ([]Link, error)

List reports every interface on the host and its addresses. It changes nothing.

func ParseList

func ParseList(b []byte) ([]Link, error)

ParseList validates iproute2's address listing. Unsupported output is an error, never an empty list.

type Observation

type Observation struct {
	Interface  string          `json:"interface"`
	Addresses  json.RawMessage `json:"addresses"`
	IPv4Routes json.RawMessage `json:"ipv4Routes"`
	IPv6Routes json.RawMessage `json:"ipv6Routes"`
}

Observation is a read-only snapshot of an interface and its IPv4 and IPv6 routes. Resolver configuration and persistent network-manager profiles are not included, so it must not be used to authorize configuration changes.

func Inspect

func Inspect(ctx context.Context, r Runner, name string) (Observation, error)

Inspect reads the interface and route state using iproute2. It never writes host configuration. Missing utilities, inaccessible hosts and unsupported output are reported instead of being treated as an empty configuration.

type Runner

type Runner interface {
	Run(context.Context, string) ([]byte, error)
}

Runner executes a command on the host. The caller controls SSH and privileges.

Jump to

Keyboard shortcuts

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