Documentation ¶
Index ¶
- func CanDial(tb testing.TB, netns ns.NetNS, network, address string) (ok bool)
- func CanDialName(tb testing.TB, netns ns.NetNS, network, address, name string)
- func ChangeEffectiveCaps(caps ...cap.Value) error
- func ConnectSocket(tb testing.TB, conn syscall.Conn)
- func CurrentNetNS(tb testing.TB) ns.NetNS
- func Dial(tb testing.TB, netns ns.NetNS, network, address string) (conn syscall.Conn)
- func DropIncomingTraffic(tb testing.TB, conn syscall.Conn)
- func EnterUnprivilegedMode()
- func FileStatusFlags(tb testing.TB, conn syscall.Conn) int
- func FlattenMetrics(tb testing.TB, g prometheus.Gatherer) map[string]float64
- func IPPrefixComparer() cmp.Option
- func JoinNetNS(tb testing.TB, netns ns.NetNS, fn func() error, caps ...cap.Value)
- func Listen(tb testing.TB, netns ns.NetNS, network, address string) (sys syscall.Conn)
- func ListenAndEcho(tb testing.TB, netns ns.NetNS, network, address string) (sys syscall.Conn)
- func ListenAndEchoWithName(tb testing.TB, netns ns.NetNS, network, address, name string) (sys syscall.Conn)
- func NewNetNS(tb testing.TB, networks ...string) ns.NetNS
- func OpenFiles(tb testing.TB, n int) []*os.File
- func ReuseportGroup(tb testing.TB, netns ns.NetNS, network string, n int) (conns []syscall.Conn)
- func ReuseportSockets(tb testing.TB, network string) (a, b *os.File, ip net.IP, port int)
- func SetupLoopback() error
- func SpawnChildWithFiles(tb testing.TB, files ...*os.File) (pid int)
- func WithCapabilities(fn func() error, caps ...cap.Value) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanDialName ¶
CanDialName checks that a ListenWithName is reachable at the given network and address.
func ChangeEffectiveCaps ¶
ChangeEffectiveCaps modifies the effective capabilities to the given list
The effective set will be empty if called without arguments.
This function changes its behaviour based on whether it is run inside a WithCapabilities closure. In that case it sets the capabilities only for the current thread. Otherwise it changes the process' set.
func ConnectSocket ¶
ConnectSocket connects a UDP socket to localhost.
func CurrentNetNS ¶
CurrentNetNS returns the current thread's network namespace.
func EnterUnprivilegedMode ¶
func EnterUnprivilegedMode()
EnterUnprivilegedMode drops all effective capabilities and enters a capabilities only environment.
This means that privileged operations need to either change the effective capabilities of the current process, or execute a child process with a modified ambient capability set.
func FileStatusFlags ¶
FileStatusFlags returns flags for the open file description onderlying conn.
func FlattenMetrics ¶
func IPPrefixComparer ¶
func JoinNetNS ¶
JoinNetNS executes a function in a different network namespace.
Any goroutines invoked from the function will still execute in the parent network namespace.
func Listen ¶
Listen listens on a given address in a specific network namespace.
Uses a local address if address is empty.
func ListenAndEcho ¶
ListenAndEcho calls Listen and then starts an echo server on the returned connection.
func ListenAndEchoWithName ¶
func ListenAndEchoWithName(tb testing.TB, netns ns.NetNS, network, address, name string) (sys syscall.Conn)
ListenAndEchoWithName is like ListenAndEcho, except that you can distinguish multiple listeners by using CanDialName.
func OpenFiles ¶
OpenFiles returns the specified number of files.
The files are a random mixture of pipes, TCP and UDP sockets.
func ReuseportGroup ¶
ReuseportGroup creates sockets that listen on the same port on either 127.0.0.1 or ::1, depending on the network.
func ReuseportSockets ¶
ReuseportSockets creates two sockets that listen on the same port on either 127.0.0.1 or ::1, depending on the network.
func SetupLoopback ¶
func SetupLoopback() error
func SpawnChildWithFiles ¶
SpawnChildWithFiles creates a process that holds onto a bunch of files.
func WithCapabilities ¶
WithCapabilities raises the effective capabilities.
Goroutines spawned from the passed function do not inherit the raised capabilities. Blocking in the passed function is allowed, but will block changes to the process' capability set.
Passing an empty list of capabilities will invoke fn without any privileges.
Types ¶
This section is empty.