package socktest
import "net/internal/socktest"
Package socktest provides utilities for socket testing.
Index ¶
- type AfterFilter
- type Cookie
- type Filter
- type FilterType
- type Sockets
- type Stat
- type Status
- type Switch
- func (sw *Switch) AcceptEx(ls syscall.Handle, as syscall.Handle, b *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, rcvd *uint32, overlapped *syscall.Overlapped) error
- func (sw *Switch) Closesocket(s syscall.Handle) (err error)
- func (sw *Switch) Connect(s syscall.Handle, sa syscall.Sockaddr) (err error)
- func (sw *Switch) ConnectEx(s syscall.Handle, sa syscall.Sockaddr, b *byte, n uint32, nwr *uint32, o *syscall.Overlapped) (err error)
- func (sw *Switch) Listen(s syscall.Handle, backlog int) (err error)
- func (sw *Switch) Set(t FilterType, f Filter)
- func (sw *Switch) Sockets() Sockets
- func (sw *Switch) Stats() []Stat
- func (sw *Switch) WSASocket(family, sotype, proto int32, protinfo *syscall.WSAProtocolInfo, group uint32, flags uint32) (s syscall.Handle, err error)
Types ¶
type AfterFilter ¶
An 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 Cookie ¶
type Cookie uint64
A Cookie represents a 3-tuple of a socket; address family, socket type and protocol number.
func (Cookie) Family ¶
Family returns an address family.
func (Cookie) Protocol ¶
Protocol returns a protocol number.
func (Cookie) Type ¶
Type returns a socket type.
type Filter ¶
type Filter func(*Status) (AfterFilter, error)
A 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 FilterType ¶
type FilterType int
A FilterType represents a filter type.
const ( FilterSocket FilterType = iota // for Socket FilterConnect // for Connect or ConnectEx FilterListen // for Listen FilterAccept // for Accept, Accept4 or AcceptEx FilterGetsockoptInt // for GetsockoptInt FilterClose // for Close or Closesocket )
type Sockets ¶
Sockets maps a socket descriptor to the status of socket.
type Stat ¶
type Stat struct { Family int // address family Type int // socket type Protocol int // protocol number Opened uint64 // number of sockets opened Connected uint64 // number of sockets connected Listened uint64 // number of sockets listened Accepted uint64 // number of sockets accepted Closed uint64 // number of sockets closed OpenFailed uint64 // number of sockets open failed ConnectFailed uint64 // number of sockets connect failed ListenFailed uint64 // number of sockets listen failed AcceptFailed uint64 // number of sockets accept failed CloseFailed uint64 // number of sockets close failed }
A Stat represents a per-cookie socket statistics.
func (Stat) String ¶
type Status ¶
type Status struct { Cookie Cookie Err error // error status of socket system call SocketErr error // error status of socket by SO_ERROR }
A Status represents the status of a socket.
func (Status) String ¶
type Switch ¶
type Switch struct {
// contains filtered or unexported fields
}
A Switch represents a callpath point switch for socket system calls.
func (*Switch) AcceptEx ¶
func (sw *Switch) AcceptEx(ls syscall.Handle, as syscall.Handle, b *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, rcvd *uint32, overlapped *syscall.Overlapped) error
AcceptEx wraps syscall.AcceptEx.
func (*Switch) Closesocket ¶
Closesocket wraps syscall.Closesocket.
func (*Switch) Connect ¶
Connect wraps syscall.Connect.
func (*Switch) ConnectEx ¶
func (sw *Switch) ConnectEx(s syscall.Handle, sa syscall.Sockaddr, b *byte, n uint32, nwr *uint32, o *syscall.Overlapped) (err error)
ConnectEx wraps syscall.ConnectEx.
func (*Switch) Listen ¶
Listen wraps syscall.Listen.
func (*Switch) Set ¶
func (sw *Switch) Set(t FilterType, f Filter)
Set deploys the socket system call filter f for the filter type t.
func (*Switch) Sockets ¶
Sockets returns mappings of socket descriptor to socket status.
func (*Switch) Stats ¶
Stats returns a list of per-cookie socket statistics.
func (*Switch) WSASocket ¶
func (sw *Switch) WSASocket(family, sotype, proto int32, protinfo *syscall.WSAProtocolInfo, group uint32, flags uint32) (s syscall.Handle, err error)
WSASocket wraps syscall.WSASocket.
Source Files ¶
switch.go switch_posix.go switch_windows.go sys_windows.go
- Version
- v1.23.5
- Published
- Jan 10, 2025
- Platform
- windows/amd64
- Imports
- 4 packages
- Last checked
- 17 seconds ago –
Tools for package owners.