netutil

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterByLocalListeningPorts

func FilterByLocalListeningPorts(conns []*ConnectionStat) ([]string, error)

FilterByLocalListeningPorts filters ConnectionStat slice by the local listening ports.

func IsPrivateIP

func IsPrivateIP(ip net.IP) bool

IsPrivateIP returns whether 'ip' is in private network space.

func LocalIPAddrs

func LocalIPAddrs() ([]string, error)

LocalIPAddrs gets the string slice of localhost IPaddrs.

func LocalListeningPorts

func LocalListeningPorts() ([]string, error)

LocalListeningPorts returns the local listening ports.

func NetlinkConnections

func NetlinkConnections() ([]*linux.InetDiagMsg, error)

NetlinkConnections returns connection stats.

func NetlinkFilterByLocalListeningPorts

func NetlinkFilterByLocalListeningPorts(conns []*linux.InetDiagMsg) ([]*linux.InetDiagMsg, error)

NetlinkFilterByLocalListeningPorts filters ConnectionStat slice by the local listening ports.

func NetlinkLocalListeningPorts

func NetlinkLocalListeningPorts() ([]string, error)

NetlinkLocalListeningPorts returns the local listening ports.

func ResolveAddr

func ResolveAddr(addr string) string

ResolveAddr lookup first hostname from IP Address.

Types

type Addr

type Addr struct {
	IP   string `json:"ip"`
	Port uint32 `json:"port"`
}

Addr is <addr>:<port>.

type ConnectionStat

type ConnectionStat struct {
	Laddr  Addr
	Raddr  Addr
	Status linux.TCPState
}

ConnectionStat represents staticstics for a connection.

type NetlinkError

type NetlinkError struct {
	// contains filtered or unexported fields
}

NetlinkError represents netlink error.

func (*NetlinkError) Error

func (e *NetlinkError) Error() string

type UserEnt

type UserEnt struct {
	// contains filtered or unexported fields
}

UserEnt represents a detail of network socket. see https://github.com/shemminger/iproute2/blob/afa588490b7e87c5adfb05d5163074e20b6ff14a/misc/ss.c#L509.

func (*UserEnt) Fd

func (u *UserEnt) Fd() int

Fd returns file descriptor.

func (*UserEnt) Inode

func (u *UserEnt) Inode() uint32

Inode returns inode.

func (*UserEnt) Pgrp

func (u *UserEnt) Pgrp() int

Pgrp returns process group id.

func (*UserEnt) Pid

func (u *UserEnt) Pid() int

Pid returns process id.

func (*UserEnt) Pname

func (u *UserEnt) Pname() string

Pname returns process name.

func (*UserEnt) Ppid

func (u *UserEnt) Ppid() int

Ppid returns process id.

func (*UserEnt) SetInode

func (u *UserEnt) SetInode(inode uint32)

SetInode set the inode.

type UserEntByLport

type UserEntByLport map[string]*UserEnt

UserEntByLport is a map that key is listening port, value is UserEnt structure.

type UserEnts

type UserEnts map[uint32]*UserEnt

UserEnts represents a hashmap of UserEnt as key is the inode.

func BuildUserEntries

func BuildUserEntries() (UserEnts, error)

BuildUserEntries scans under /proc/%pid/fd/.

Jump to

Keyboard shortcuts

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