portmapper

package
v0.0.0-...-a3c1927 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver interface {
	MapPorts(MapPortsRequest) (MapPortsResponse, error)
	UnmapPorts(UnmapPortsRequest) error
}

type ErrorResponse

type ErrorResponse struct {
	Err string
}

ErrorResponse is a formatted error message that libnetwork can understand

func NewErrorResponse

func NewErrorResponse(msg string) *ErrorResponse

NewErrorResponse creates an ErrorResponse with the provided message

type Handler

type Handler struct {
	*sdk.Handler
	// contains filtered or unexported fields
}

Handler forwards requests and responses between the docker daemon and the plugin.

func NewHandler

func NewHandler(driver Driver) *Handler

NewHandler initializes the request handler with a driver implementation.

type MapPortsRequest

type MapPortsRequest struct {
	// Reqs is a group of port bindings that should get the same port assigned
	// when an ephemeral port, or a port range is requested. Each Reqs should
	// yield an independent PortBinding.
	Reqs []PortBindingReq

	// Labels is a set of opaque, user-specified freeform labels that can be
	// used to tweak how the port-mapper behaves.
	Labels map[string]string
}

MapPortsRequest is the API request sent to the PortMapper plugin to map a port.

type MapPortsResponse

type MapPortsResponse struct {
	PortBindings []PortBinding
	Err          string
}

type NATRule

type NATRule struct {
	FromAddr netip.Addr // FromAddr is the address to NAT from.
	FromPort uint16     // FromPort is the port to NAT from.
}

type PortBinding

type PortBinding struct {
	Proto Protocol

	BackendIP   netip.Addr
	BackendPort uint16

	FrontendIP netip.Addr
	// FrontendPort is the frontend port picked by the PortMapper when an
	// ephemeral port, or a port range was specified in the request.
	FrontendPort uint16

	// DiscardReq is returned when the PortBindingReq can't be fulfilled, but
	// the driver deems it's not a fatal error.
	DiscardReq bool

	// AllowForwarding indicates whether forwarding to BackendIP:BackendPort
	// should be configured by the Engine.
	AllowForwarding bool
	// NAT is returned by the portmapper when it needs the Engine to configure
	// the host firewall to NAT a port to BackendIP:BackendPort.
	NAT *NATRule

	// Error indicates the reason why this port binding was discarded. This
	// error is logged.
	Error *string
}

PortBinding is returned by the PortMapper when a request has been processed.

type PortBindingReq

type PortBindingReq struct {
	Proto Protocol

	BackendIP   netip.Addr
	BackendPort uint16

	FrontendIP netip.Addr
	// FrontendPort is either an exact port, an ephemeral port (= 0), or the start
	// of a port range.
	FrontendPort uint16
	// FrontendPortEnd should be the same as HostPort when an exact or ephemeral
	// port is requested. Otherwise, it should be the end of the port range.
	FrontendPortEnd uint16
}

type Protocol

type Protocol int
const (
	ProtocolTCP  Protocol = 0x6
	ProtocolUDP  Protocol = 0x11
	ProtocolSCTP Protocol = 0x84
)

func (Protocol) String

func (p Protocol) String() string

type UnmapPortsRequest

type UnmapPortsRequest struct {
	PortBindings []PortBinding
	Labels       map[string]string
}

Jump to

Keyboard shortcuts

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