procnettcp

package
v0.18.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: Apache-2.0 Imports: 9 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., "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 is expected to be used for /proc/net/{tcp,tcp6} entries on little endian machines. Not sure how those entries look like on big endian machines.

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}

type Kind

type Kind = string
const (
	TCP  Kind = "tcp"
	TCP6 Kind = "tcp6"
)

type State

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

Jump to

Keyboard shortcuts

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