procnettcp

package
v2.0.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: Apache-2.0 Imports: 10 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.

Little endian hosts: "0100007F:0050" (127.0.0.1:80) "000080FE00000000FF57A6705DC771FE:0050" ([fe80::70a6:57ff:fe71:c75d]:80) "00000000000000000000000000000000:0050" (0.0.0.0:80)

Big endian hosts: "7F000001:0050" (127.0.0.1:80) "FE8000000000000070A657FFFE71C75D: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

func ParseAddressWithEndian

func ParseAddressWithEndian(s string, isBE bool) (net.IP, uint16, error)

Types

type Entry

type Entry struct {
	Kind  Kind   `json:"kind"`
	IP    net.IP `json:"ip"`
	Port  uint16 `json:"port"`
	State State  `json:"state"`
}

func Parse

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

func ParseFiles

func ParseFiles() ([]Entry, error)

ParseFiles parses /proc/net/{tcp, tcp6}.

func ParseWithEndian

func ParseWithEndian(r io.Reader, kind Kind, isBE bool) ([]Entry, error)

type Kind

type Kind = string
const (
	TCP  Kind = "tcp"
	TCP6 Kind = "tcp6"
	UDP  Kind = "udp"
	UDP6 Kind = "udp6"
)

type State

type State = int
const (
	TCPEstablished State = 0x1
	TCPListen      State = 0xA
	UDPUnconnected State = 0x7
)

Jump to

Keyboard shortcuts

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