network

package
v0.0.0-...-385f941 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoValidLocalAddr  = errors.New("no valid local address.")
	ErrDeviceNameInvalid = errors.New("device name invalid.")
)
View Source
var TCPStatuses = map[string]string{
	"01": "ESTABLISHED",
	"02": "SYN_SENT",
	"03": "SYN_RECV",
	"04": "FIN_WAIT1",
	"05": "FIN_WAIT2",
	"06": "TIME_WAIT",
	"07": "CLOSE",
	"08": "CLOSE_WAIT",
	"09": "LAST_ACK",
	"0A": "LISTEN",
	"0B": "CLOSING",
}

http://students.mimuw.edu.pl/lxr/source/include/net/tcp_states.h

Functions

func ConvertToIPInt

func ConvertToIPInt(ip string) uint32

func ConvertToIPStr

func ConvertToIPStr(ip uint32) string

func GetDefaultIP

func GetDefaultIP() string

func GrabSystemRandomIdlePort

func GrabSystemRandomIdlePort() (uint32, error)

GrabSystemRandomIdlePort is exported Get system random idle port, auto bind

func GrabSystemRangeIdlePort

func GrabSystemRangeIdlePort(kind string, minPort uint32, maxPort uint32) (uint32, error)

GrabSystemRangeIdlePort is exported

func IsIntranet

func IsIntranet(ipStr string) bool

func Pids

func Pids() ([]int32, error)

Pids retunres all pids. Note: this is a copy of process_linux.Pids() FIXME: Import process occures import cycle. move to common made other platform breaking. Need consider.

func Reverse

func Reverse(s []byte) []byte

Reverse reverses array of bytes.

Types

type Addr

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

Addr is implemented compatibility to psutil

func (Addr) String

func (a Addr) String() string

type AddrInfo

type AddrInfo struct {
	Name string `json:"name"`
	Mac  string `json:"mac"`
	IP   string `json:"ip"`
}

func GetLocalNetAddrs

func GetLocalNetAddrs() ([]*AddrInfo, error)

func GetLocalNetDeviceInfo

func GetLocalNetDeviceInfo(name string) (*AddrInfo, error)

type ConnectionStat

type ConnectionStat struct {
	Fd     uint32  `json:"fd"`
	Family uint32  `json:"family"`
	Type   uint32  `json:"type"`
	Laddr  Addr    `json:"localaddr"`
	Raddr  Addr    `json:"remoteaddr"`
	Status string  `json:"status"`
	Uids   []int32 `json:"uids"`
	Pid    int32   `json:"pid"`
}

func ConnectionStats

func ConnectionStats(kind string) ([]ConnectionStat, error)

Return a list of network connections opened.

func (ConnectionStat) String

func (n ConnectionStat) String() string

type InterfaceAddr

type InterfaceAddr struct {
	Addr string `json:"addr"`
}

NetInterfaceAddr is designed for represent interface addresses

func (InterfaceAddr) String

func (n InterfaceAddr) String() string

type InterfaceStat

type InterfaceStat struct {
	MTU          int             `json:"mtu"`          // maximum transmission unit
	Name         string          `json:"name"`         // e.g., "en0", "lo0", "eth0.100"
	HardwareAddr string          `json:"hardwareaddr"` // IEEE MAC-48, EUI-48 and EUI-64 form
	Flags        []string        `json:"flags"`        // e.g., FlagUp, FlagLoopback, FlagMulticast
	Addrs        []InterfaceAddr `json:"addrs"`
}

func Interfaces

func Interfaces() ([]InterfaceStat, error)

Interfaces is exported

func (InterfaceStat) String

func (n InterfaceStat) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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