my fork/clone of BishopFox/sliver's fork of https://github.com/cakturk/go-netstat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
forest 73fdb805ec its a module, init? 1 month ago
LICENSE lifted the modified go-netstat from BishopFox/sliver 1 month ago
README.md add specific link to readme 1 month ago
go.mod its a module, init? 1 month ago
go.sum its a module, init? 1 month ago
netstat.go lifted the modified go-netstat from BishopFox/sliver 1 month ago
netstat_darwin.go lifted the modified go-netstat from BishopFox/sliver 1 month ago
netstat_linux.go lifted the modified go-netstat from BishopFox/sliver 1 month ago
netstat_types_darwin.go lifted the modified go-netstat from BishopFox/sliver 1 month ago
netstat_windows.go lifted the modified go-netstat from BishopFox/sliver 1 month ago
types_darwin.go lifted the modified go-netstat from BishopFox/sliver 1 month ago

README.md

go-netstat / Sliver

A modified version of https://github.com/cakturk/go-netstat, modifications have been made for interoperability with the rest of Silver:

  • Added Darwin support
  • Data structures have been ported to protobuf

Using as a library

Godoc

Getting the package

$ go get github.com/cakturk/go-netstat/netstat
import (
	"fmt"

	"github.com/cakturk/go-netstat/netstat"
)

func displaySocks() error {
	// UDP sockets
	socks, err := netstat.UDPSocks(netstat.NoopFilter)
	if err != nil {
		return err
	}
	for _, e := range socks {
		fmt.Printf("%v\n", e)
	}

	// TCP sockets
	socks, err = netstat.TCPSocks(netstat.NoopFilter)
	if err != nil {
		return err
	}
	for _, e := range socks {
		fmt.Printf("%v\n", e)
	}

	// get only listening TCP sockets
	tabs, err = netstat.TCPSocks(func(s *netstat.SockTabEntry) bool {
		return s.State == netstat.Listen
	})
	if err != nil {
		return err
	}
	for _, e := range socks {
		fmt.Printf("%v\n", e)
	}

	// list all the TCP sockets in state FIN_WAIT_1 for your HTTP server
	tabs, err = netstat.TCPSocks(func(s *netstat.SockTabEntry) bool {
		return s.State == netstat.FinWait1 && s.LocalAddr.Port == 80
	})
	// error handling, etc.

	return nil
}