iptables

package
v0.0.0-...-2247dbc Latest Latest
Warning

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

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

Documentation

Overview

Package iptables handles forwarding ports found in iptables DNAT

Package iptables handles forwarding ports found in iptables DNAT

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iptables

type Iptables struct {
	// contains filtered or unexported fields
}

Iptables manages port forwarding for ports identified in iptables DNAT rules. It is primarily responsible for handling port mappings in Kubernetes environments that are not exposed via the Kubernetes API. The package scans iptables for these port and uses the k8sServiceListenerAddr setting for the hostIP property to create a port mapping and forwards them to both the API tracker and the WSL Proxy for proper routing and handling.

func New

func New(ctx context.Context, tracker tracker.Tracker, iptablesScanner Scanner, listenerIP net.IP, updateInterval time.Duration) *Iptables

func (*Iptables) ForwardPorts

func (i *Iptables) ForwardPorts() error

ForwardPorts forwards ports found in iptables DNAT. In some environments, like WSL, ports defined using the CNI portmap plugin happen through iptables. These ports are not sent to places like /proc/net/tcp and are not picked up as part of the normal forwarding system. This function detects those ports and binds them to k8sServiceListenerAddr so that they are picked up.

type IptablesScanner

type IptablesScanner struct{}

func NewIptablesScanner

func NewIptablesScanner() *IptablesScanner

func (*IptablesScanner) GetPorts

func (i *IptablesScanner) GetPorts() ([]iptables.Entry, error)

type Scanner

type Scanner interface {
	GetPorts() ([]iptables.Entry, error)
}

Scanner is the interface that wraps the GetPorts method which is used to scan the iptables.

Jump to

Keyboard shortcuts

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