slirp4netns

package
v0.59.1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: Apache-2.0 Imports: 21 Imported by: 6

Documentation

Index

Constants

View Source
const (
	BinaryName = "slirp4netns"
)

Variables

This section is empty.

Functions

func GetDNS

func GetDNS(subnet *net.IPNet) (*net.IP, error)

Get expected slirp DNS ipv4 address based on subnet Reference: https://github.com/rootless-containers/slirp4netns/blob/master/slirp4netns.1.md#description

func GetGateway

func GetGateway(subnet *net.IPNet) (*net.IP, error)

Get expected slirp Gateway ipv4 address based on subnet Reference: https://github.com/rootless-containers/slirp4netns/blob/master/slirp4netns.1.md#description

func GetIP

func GetIP(subnet *net.IPNet) (*net.IP, error)

Get expected slirp ipv4 address based on subnet. If subnet is null use default subnet Reference: https://github.com/rootless-containers/slirp4netns/blob/master/slirp4netns.1.md#description

func GetRootlessPortChildIP

func GetRootlessPortChildIP(slirpSubnet *net.IPNet, netStatus map[string]types.StatusBlock) string

func SetupRootlessPortMappingViaRLK

func SetupRootlessPortMappingViaRLK(opts *SetupOptions, slirpSubnet *net.IPNet, netStatus map[string]types.StatusBlock) error

Types

type SetupOptions

type SetupOptions struct {
	// Config used to get slip4netns path and other default options
	Config *config.Config
	// ContainerID is the ID of the container
	ContainerID string
	// Netns path to the netns
	Netns string
	// Ports the should be forwarded
	Ports []types.PortMapping
	// ExtraOptions for slirp4netns that were set on the cli
	ExtraOptions []string
	// Slirp4netnsExitPipeR pipe used to exit the slirp4netns process.
	// This is must be the reading end, the writer must be kept open until you want the
	// process to exit. For podman, conmon will hold the pipe open.
	// It can be set to nil in which case we do not use the pipe exit and the caller
	// must use the returned pid to kill the process after it is done.
	Slirp4netnsExitPipeR *os.File
	// RootlessPortSyncPipe pipe used to exit the rootlessport process.
	// Same as Slirp4netnsExitPipeR, except this is only used when ports are given.
	RootlessPortExitPipeR *os.File
	// Pdeathsig is the signal which is send to slirp4netns process if the calling thread
	// exits. The caller is responsible for locking the thread with runtime.LockOSThread().
	Pdeathsig syscall.Signal
}

type SetupResult

type SetupResult struct {
	// Pid of the created slirp4netns process
	Pid int
	// Subnet which is used by slirp4netns
	Subnet *net.IPNet
	// IPv6 whenever Ipv6 is enabled in slirp4netns
	IPv6 bool
}

SetupResult return type from Setup()

func Setup

func Setup(opts *SetupOptions) (*SetupResult, error)

Setup can be called in rootful as well as in rootless. Spawns the slirp4netns process and setup port forwarding if ports are given.

Jump to

Keyboard shortcuts

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