procnet

package
v2.4.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseAddress

func ParseAddress(s string) (net.IP, uint16, error)

ParseAddress parses a string, e.g.,Akihiro Suda, 10 months ago: • initial commit "0100007F:0050" (127.0.0.1:80) "000080FE00000000FF57A6705DC771FE:0050" ([fe80::70a6:57ff:fe71:c75d]:80) "00000000000000000000000000000000:0050" (0.0.0.0:80)

See https://serverfault.com/questions/592574/why-does-proc-net-tcp6-represents-1-as-1000

ParseAddress parses the entry using the current host's native byte order. Use ParseAddressWithByteOrder to parse an entry whose byte order is known. The parsing logic is derived from the lima project in https://github.com/lima-vm/lima/blob/v0.8.3/pkg/guestagent/procnettcp/procnettcp.go#L95-L137 and is licensed under the Apache License, Version 2.0

func ParseAddressWithByteOrder

func ParseAddressWithByteOrder(s string, order binary.ByteOrder) (net.IP, uint16, error)

ParseAddressWithByteOrder is like ParseAddress but takes the byte order of the /proc data explicitly. The kernel writes each 4-byte group of the address in the host's native byte order (little-endian on x86/arm64, big-endian on s390x), so each group is read with that order and rewritten in network order to build the net.IP.

func ReadStatsFileData

func ReadStatsFileData(protocol string) ([]string, error)

Types

type NetworkDetail

type NetworkDetail struct {
	LocalIP   net.IP
	LocalPort uint64
	State     int
}

func Parse

func Parse(data []string) (results []NetworkDetail)

Jump to

Keyboard shortcuts

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