GOnetstat

package module
v0.0.0-...-0847f49 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2020 License: MIT Imports: 8 Imported by: 0

README

Making GOnetstat faster

I needed a netstat library for some program in go. Problem is the only one that exists is very slow. So I challenged myself to make it as fast as I can.

I'm adding a branch for each faster version. In the readme of each version you can find its execution time.

Execution time

Original execution time:

PASS
ok      GOnetstat       0.955s

Current version execution time:

PASS
ok      GOnetstat       0.079s

Improvement graph

graph

Documentation

Index

Constants

View Source
const (
	PROC_TCP  = "/proc/net/tcp"
	PROC_UDP  = "/proc/net/udp"
	PROC_TCP6 = "/proc/net/tcp6"
	PROC_UDP6 = "/proc/net/udp6"
)

Variables

View Source
var STATE = 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",
}

Functions

This section is empty.

Types

type Process

type Process struct {
	User        string
	Name        string
	Pid         string
	Exe         string
	State       string
	Ip          string
	Port        int64
	ForeignIp   string
	ForeignPort int64
}

func Tcp

func Tcp() []Process

func Tcp6

func Tcp6() []Process

func Udp

func Udp() []Process

func Udp6

func Udp6() []Process

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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