netinfo

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 6 Imported by: 0 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.

Documentation

Overview

Package netinfo wraps OS-specific network introspection (default gateway, Wi-Fi state) behind a small cross-platform interface.

Gateway detection is uniform across OSes via jackpal/gateway (which uses netlink on Linux and PF_ROUTE on macOS/BSD/Windows internally), so it lives in this single file with no build tags.

Wi-Fi state varies wildly per platform — see wifi_*.go for the build-tagged implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectDefaultGateway

func DetectDefaultGateway() (string, bool)

DetectDefaultGateway returns the IP address of the system's default route, or ("", false) if it can't be determined.

Used by the monitor to dynamically add a `router_icmp` probe at startup — the legacy Python tool inserted this probe so users always have direct "is my router reachable?" data alongside the public-internet probes.

Types

type WifiSample

type WifiSample struct {
	Timestamp     time.Time
	SSID          *string
	BSSID         *string
	SignalPercent *int     // Windows-only
	RSSIDbm       *int     // best-effort cross-platform
	RxRateMbps    *float64 // Windows-only
	TxRateMbps    *float64 // Windows-only
	Channel       *string
}

WifiSample captures network attachment state at a point in time. Most fields are platform-dependent and may be nil; SignalPercent and Rx/Tx rates are Windows-only.

func SampleWifi

func SampleWifi(_ context.Context) WifiSample

SampleWifi reads Wi-Fi state from netlink via mdlayher/wifi. Pure Go, no shell-out. Returns a near-empty sample on failure rather than erroring.

Jump to

Keyboard shortcuts

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