netinfo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 5 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 reports what is listening on this machine and how far each listener can be reached. It reads /proc/net/tcp and tcp6, so it needs no privileges and no tools like ss.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LANAddrs

func LANAddrs() []string

LANAddrs returns this computer's non-loopback IPv4 addresses, the ones other computers would use.

Types

type Listener

type Listener struct {
	IP   net.IP
	Port int
}

Listener is a TCP socket in the listening state.

func Find

func Find(ls []Listener, port int) (Listener, bool)

Find returns the widest-reaching listener on a port: if a port is open on all interfaces and on loopback, what matters is that it can be reached from the network.

func Listeners

func Listeners(root string) []Listener

Listeners returns every listening TCP socket under root ("/" for the real system).

func Parse

func Parse(text string) []Listener

Parse reads the text of /proc/net/tcp or /proc/net/tcp6 and returns the listening sockets.

func (Listener) Scope

func (l Listener) Scope() Scope

Scope classifies the listener's address.

type Scope

type Scope int

Scope is how far a listening socket can be reached from.

const (
	Local   Scope = iota // loopback only: this computer
	Network              // all interfaces: anyone who can reach this computer
	Address              // one specific address
)

Jump to

Keyboard shortcuts

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