Documentation ¶
Overview ¶
Package tracker implements a tracking mechanism to keep track of the ports during various container event types e.g start, stop
Package tracker implements a tracking mechanism to keep track of the ports during various container event types e.g start, stop
Package tracker implements a tracking mechanism to keep track of the ports during various container event types e.g start, stop
Index ¶
Constants ¶
const ( // The Gateway IP address that is statically reserved // by DHCP and will not change. It is used to initialize // the NewAPITracker. GatewayBaseURL = "http://192.168.127.1:80" )
Variables ¶
var ( ErrAPI = errors.New("error from API") ErrExposeAPI = fmt.Errorf("error from %s API", exposeAPI) ErrUnexposeAPI = fmt.Errorf("error from %s API", unexposeAPI) ErrInvalidIPv4 = errors.New("not an IPv4 address") ErrWSLProxy = errors.New("error from Rancher Desktop WSL Proxy") )
var ErrRemoveAll = errors.New("failed to remove all portMappings")
Functions ¶
This section is empty.
Types ¶
type APITracker ¶ added in v0.3.12
type APITracker struct { *ListenerTracker // contains filtered or unexported fields }
APITracker keeps track of the port mappings and calls the corresponding API endpoints that is responsible for exposing and unexposing the ports on the host. This should only be used when the Rancher Desktop networking is enabled and the privileged service is disabled.
func NewAPITracker ¶ added in v0.3.12
func NewAPITracker(forwarder forwarder.Forwarder, baseURL string, isAdmin bool) *APITracker
NewAPITracker creates a new instace of a API Tracker.
func (*APITracker) Add ¶ added in v0.3.12
func (a *APITracker) Add(containerID string, portMap nat.PortMap) error
Add a container ID and port mapping to the tracker and calls the /services/forwarder/expose endpoint to forward the port mappings.
func (*APITracker) Get ¶ added in v0.3.12
func (a *APITracker) Get(containerID string) nat.PortMap
Get looks up the port mapping by containerID and returns the result.
func (*APITracker) Remove ¶ added in v0.3.12
func (a *APITracker) Remove(containerID string) error
Remove a single entry from the port storage and calls the /services/forwarder/unexpose endpoint to remove the forwarded the port mappings.
func (*APITracker) RemoveAll ¶ added in v0.3.12
func (a *APITracker) RemoveAll() error
RemoveAll calls the /services/forwarder/unexpose and removes all the port bindings from the tracker.
type ListenerTracker ¶ added in v0.3.12
type ListenerTracker struct {
// contains filtered or unexported fields
}
ListenerTracker manages listeners.
func NewListenerTracker ¶ added in v0.3.12
func NewListenerTracker() *ListenerTracker
NewListenerTracker creates a new listener tracker.
func (*ListenerTracker) AddListener ¶ added in v0.3.12
AddListener adds an IP / port combination into the listener tracker. If this combination is already being tracked, this is a no-op.
func (*ListenerTracker) RemoveListener ¶ added in v0.3.12
RemoveListener removes an IP / port combination from the listener tracker. If this combination was not being tracked, this is a no-op.
type NetTracker ¶ added in v0.3.12
type NetTracker interface { // AddListener creates a TCP listener for a given IP and Port. AddListener(ctx context.Context, ip net.IP, port int) error // RemoveListener removes a TCP listener for a given IP and Port. RemoveListener(ctx context.Context, ip net.IP, port int) error }
NetTracker is the interface that wraps the methods that are used to manage Add/Remove tcp listeners.
type Tracker ¶ added in v0.3.12
type Tracker interface { // Get returns a portMap using the containerID as a lookup Key. Get(containerID string) nat.PortMap // Add adds a portMap to the storage using the containerID as a Key. // It replaces all existing portMappings, without attempting to unbind listeners, // so the caller is responsible for calling Remove first if necessary. Add(containerID string, portMapping nat.PortMap) error // Remove removes a portMap using the containerID as a key. Remove(containerID string) error // RemoveAll removes all the available portMappings in the storage. RemoveAll() error NetTracker }
Tracker is the interface that includes all the functions that are used to keep track of the port mappings plus NetTracker methods that are used to keep track of the network listener creation and removal.
type VTunnelTracker ¶ added in v0.3.12
type VTunnelTracker struct { *ListenerTracker // contains filtered or unexported fields }
VTunnelTracker keeps track of port mappings and forwards them to the privileged service on the host over AF_VSOCK tunnel (vtunnel).
func NewVTunnelTracker ¶ added in v0.3.12
func NewVTunnelTracker(vtunnelForwarder forwarder.Forwarder, wslAddrs []types.ConnectAddrs) *VTunnelTracker
NewVTunnelTracker creates a new Port Tracker.
func (*VTunnelTracker) Add ¶ added in v0.3.12
func (p *VTunnelTracker) Add(containerID string, portMap nat.PortMap) error
Add a container ID and port mapping to the tracker and calls the vtunnel forwarder to send the port mappings to privileged service.
func (*VTunnelTracker) Get ¶ added in v0.3.12
func (p *VTunnelTracker) Get(containerID string) nat.PortMap
Get gets a port mapping by container ID from the tracker.
func (*VTunnelTracker) Remove ¶ added in v0.3.12
func (p *VTunnelTracker) Remove(containerID string) error
Remove deletes a container ID and port mapping from the tracker and calls the vtunnel forwarder to send the port mappings to privileged service.
func (*VTunnelTracker) RemoveAll ¶ added in v0.3.12
func (p *VTunnelTracker) RemoveAll() error
RemoveAll removes all the port bindings from the tracker.