Imports #
"syscall"
"internal/syscall/windows"
"syscall"
"fmt"
"sync"
"fmt"
"syscall"
"syscall"
"syscall"
"syscall"
"internal/syscall/windows"
"syscall"
"fmt"
"sync"
"fmt"
"syscall"
"syscall"
"syscall"
const FilterAcceptconst FilterCloseconst FilterConnectconst FilterGetsockoptIntconst FilterListenconst FilterSocket FilterType = iotaAn AfterFilter represents a socket system call filter after an execution of a system call. It will only be executed after a system call for a socket that has an entry in internal table. If the filter returns a non-nil error, the system call function returns the non-nil error.
type AfterFilter func(*Status) errorA Cookie represents a 3-tuple of a socket; address family, socket type and protocol number.
type Cookie uint64A Filter represents a socket system call filter. It will only be executed before a system call for a socket that has an entry in internal table. If the filter returns a non-nil error, the execution of system call will be canceled and the system call function returns the non-nil error. It can return a non-nil [AfterFilter] for filtering after the execution of the system call.
type Filter func(*Status) (AfterFilter, error)A FilterType represents a filter type.
type FilterType intSockets maps a socket descriptor to the status of socket.
type Sockets map[int]StatusSockets maps a socket descriptor to the status of socket.
type Sockets map[int]StatusSockets maps a socket descriptor to the status of socket.
type Sockets map[syscall.Handle]Statustype stats map[Cookie]*StatA Stat represents a per-cookie socket statistics.
type Stat struct {
Family int
Type int
Protocol int
Opened uint64
Connected uint64
Listened uint64
Accepted uint64
Closed uint64
OpenFailed uint64
ConnectFailed uint64
ListenFailed uint64
AcceptFailed uint64
CloseFailed uint64
}A Status represents the status of a socket.
type Status struct {
Cookie Cookie
Err error
SocketErr error
}A Switch represents a callpath point switch for socket system calls.
type Switch struct {
once sync.Once
fmu sync.RWMutex
fltab map[FilterType]Filter
smu sync.RWMutex
sotab Sockets
stats stats
}Accept wraps syscall.Accept.
func (sw *Switch) Accept(s int) (ns int, sa syscall.Sockaddr, err error)Accept4 wraps syscall.Accept4.
func (sw *Switch) Accept4(s int, flags int) (ns int, sa syscall.Sockaddr, err error)AcceptEx wraps [syscall.AcceptEx].
func (sw *Switch) AcceptEx(ls syscall.Handle, as syscall.Handle, b *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, rcvd *uint32, overlapped *syscall.Overlapped) errorClose wraps syscall.Close.
func (sw *Switch) Close(s int) (err error)Closesocket wraps [syscall.Closesocket].
func (sw *Switch) Closesocket(s syscall.Handle) (err error)Connect wraps syscall.Connect.
func (sw *Switch) Connect(s int, sa syscall.Sockaddr) (err error)Connect wraps [syscall.Connect].
func (sw *Switch) Connect(s syscall.Handle, sa syscall.Sockaddr) (err error)ConnectEx wraps [syscall.ConnectEx].
func (sw *Switch) ConnectEx(s syscall.Handle, sa syscall.Sockaddr, b *byte, n uint32, nwr *uint32, o *syscall.Overlapped) (err error)Family returns an address family.
func (c Cookie) Family() intGetsockoptInt wraps syscall.GetsockoptInt.
func (sw *Switch) GetsockoptInt(s int, level int, opt int) (soerr int, err error)Listen wraps syscall.Listen.
func (sw *Switch) Listen(s int, backlog int) (err error)Listen wraps [syscall.Listen].
func (sw *Switch) Listen(s syscall.Handle, backlog int) (err error)Protocol returns a protocol number.
func (c Cookie) Protocol() intSet deploys the socket system call filter f for the filter type t.
func (sw *Switch) Set(t FilterType, f Filter)Socket wraps [syscall.Socket].
func (sw *Switch) Socket(family int, sotype int, proto int) (s int, err error)Sockets returns mappings of socket descriptor to socket status.
func (sw *Switch) Sockets() SocketsStats returns a list of per-cookie socket statistics.
func (sw *Switch) Stats() []Statfunc (so Status) String() stringfunc (st Stat) String() stringType returns a socket type.
func (c Cookie) Type() intWSASocket wraps [syscall.WSASocket].
func (sw *Switch) WSASocket(family int32, sotype int32, proto int32, protinfo *syscall.WSAProtocolInfo, group uint32, flags uint32) (s syscall.Handle, err error)addLocked returns a new Status without locking. sw.smu must be held before call.
func (sw *Switch) addLocked(s int, family int, sotype int, proto int) *StatusaddLocked returns a new Status without locking. sw.smu must be held before call.
func (sw *Switch) addLocked(s syscall.Handle, family int, sotype int, proto int) *Statusfunc (f Filter) apply(st *Status) (AfterFilter, error)func (f AfterFilter) apply(st *Status) errorfunc cookie(family int, sotype int, proto int) Cookiefunc familyString(family int) stringfunc familyString(family int) stringfunc (st stats) getLocked(c Cookie) *Statfunc (sw *Switch) init()func protocolString(proto int) stringfunc protocolString(proto int) stringfunc (sw *Switch) sockso(s int) *Statusfunc (sw *Switch) sockso(s syscall.Handle) *Statusfunc typeString(sotype int) stringfunc typeString(sotype int) stringGenerated with Arrow