socktable

package
v3.0.0-rc77 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 14 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 socktable reads the socket tables of the kernel, in /proc/net, to tell the users owning the sockets of the node.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Owners

func Owners(network string, client, server netip.AddrPort) ([]uint32, error)

Owners returns the uids owning the sockets of the node a client at client queries server from, over network, "tcp" or "udp": the one of an established tcp connection, the one of the udp socket a reply to client reaches. It returns none for a client not on the node, in another network namespace, or a tcp connection not established. It asks the kernel the one socket by sock_diag, and reads the socket tables where it can not.

func TCPOwners

func TCPOwners(entries []Entry, client, server netip.AddrPort) []uint32

TCPOwners returns the uid of the established tcp connection from client to server in entries. A connection closing, as one its process closed after sending a query, is shown owned by root by the kernel, and is not taken.

func UDPOwners

func UDPOwners(entries []Entry, client, server netip.AddrPort) []uint32

UDPOwners returns the uids of the udp sockets of entries a datagram from client to server may come from: bound to the port of client, on its address or on any, and connected to server or to none.

Types

type Entry

type Entry struct {
	Local  netip.AddrPort
	Remote netip.AddrPort
	State  uint8
	UID    uint32
}

Entry is a socket of a table: its local and remote addresses, its state, and the uid owning it.

func Parse

func Parse(r io.Reader) ([]Entry, error)

Parse reads a table of /proc/net, tcp, tcp6, udp or udp6.

Jump to

Keyboard shortcuts

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