Documentation
¶
Index ¶
- type DatapathUpdater
- type MockIPTablesManager
- func (m *MockIPTablesManager) GetProxyPorts() map[string]uint16
- func (m *MockIPTablesManager) InstallNoTrackRules(ip netip.Addr, port uint16)
- func (m *MockIPTablesManager) InstallProxyRules(proxyPort uint16, name string)
- func (m *MockIPTablesManager) RemoveNoTrackRules(ip netip.Addr, port uint16)
- func (m *MockIPTablesManager) SupportsOriginalSourceAddr() bool
- type ProxyPort
- type ProxyPorts
- func (p *ProxyPorts) AckProxyPort(ctx context.Context, name string, pp *ProxyPort) error
- func (p *ProxyPorts) AckProxyPortWithReference(ctx context.Context, name string) error
- func (p *ProxyPorts) AllocateCRDProxyPort(name string) (uint16, error)
- func (p *ProxyPorts) AllocatePort(pp *ProxyPort, retry bool) (err error)
- func (p *ProxyPorts) FindByTypeWithReference(l7Type types.ProxyType, listener string, ingress bool) (string, *ProxyPort)
- func (p *ProxyPorts) GetOpenLocalPorts() map[uint16]struct{}
- func (p *ProxyPorts) GetProxyPort(name string) (port uint16, isStatic bool, err error)
- func (p *ProxyPorts) GetRulesPort(pp *ProxyPort) uint16
- func (p *ProxyPorts) GetStatusInfo() (rangeMin, rangeMax, nPorts uint16)
- func (p *ProxyPorts) HasProxyType(pp *ProxyPort, proxyType types.ProxyType) bool
- func (p *ProxyPorts) ReleaseProxyPort(name string) error
- func (p *ProxyPorts) ResetUnacknowledged(pp *ProxyPort)
- func (p *ProxyPorts) Restore(pp *ProxyPort)
- func (p *ProxyPorts) RestoreProxyPorts()
- func (p *ProxyPorts) SetProxyPort(name string, proxyType types.ProxyType, port uint16, ingress bool) error
- func (p *ProxyPorts) StoreProxyPorts(ctx context.Context) error
- type ProxyPortsConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DatapathUpdater ¶
type MockIPTablesManager ¶
type MockIPTablesManager struct{}
func (*MockIPTablesManager) GetProxyPorts ¶
func (m *MockIPTablesManager) GetProxyPorts() map[string]uint16
func (*MockIPTablesManager) InstallNoTrackRules ¶
func (m *MockIPTablesManager) InstallNoTrackRules(ip netip.Addr, port uint16)
func (*MockIPTablesManager) InstallProxyRules ¶
func (m *MockIPTablesManager) InstallProxyRules(proxyPort uint16, name string)
func (*MockIPTablesManager) RemoveNoTrackRules ¶
func (m *MockIPTablesManager) RemoveNoTrackRules(ip netip.Addr, port uint16)
func (*MockIPTablesManager) SupportsOriginalSourceAddr ¶
func (m *MockIPTablesManager) SupportsOriginalSourceAddr() bool
type ProxyPort ¶
type ProxyPort struct { // proxy type this port applies to (immutable) ProxyType types.ProxyType `json:"type"` // 'true' for Ingress, 'false' for egress (immutable) // 'false' for CRD redirects, which are accessed by name only. Ingress bool `json:"ingress"` // ProxyPort is the desired proxy listening port number. ProxyPort uint16 `json:"port"` // contains filtered or unexported fields }
type ProxyPorts ¶
type ProxyPorts struct { // Trigger for storing proxy ports on to file Trigger *trigger.Trigger // contains filtered or unexported fields }
func NewProxyPorts ¶
func NewProxyPorts( logger *slog.Logger, config ProxyPortsConfig, datapathUpdater datapath.IptablesManager, ) *ProxyPorts
func (*ProxyPorts) AckProxyPort ¶
AckProxyPort() marks the proxy of the given type as successfully created and creates or updates the datapath rules accordingly. Does NOT take a reference on the proxy port.
func (*ProxyPorts) AckProxyPortWithReference ¶
func (p *ProxyPorts) AckProxyPortWithReference(ctx context.Context, name string) error
AckProxyPortWithReference() marks the proxy of the given type as successfully created and creates or updates the datapath rules accordingly. Takes a reference on the proxy port.
func (*ProxyPorts) AllocateCRDProxyPort ¶
func (p *ProxyPorts) AllocateCRDProxyPort(name string) (uint16, error)
AllocateCRDProxyPort() allocates a new port for listener 'name', or returns the current one if already allocated. Each call has to be paired with AckProxyPort(name) to update the datapath rules accordingly. Each allocated port must be eventually freed with ReleaseProxyPort().
func (*ProxyPorts) AllocatePort ¶
func (p *ProxyPorts) AllocatePort(pp *ProxyPort, retry bool) (err error)
func (*ProxyPorts) FindByTypeWithReference ¶
func (p *ProxyPorts) FindByTypeWithReference(l7Type types.ProxyType, listener string, ingress bool) (string, *ProxyPort)
FindByType returns a ProxyPort matching the given type, listener name, and direction, if found. Adds reference bound to the returned ProxyPort to prevent it being concurrently released. Reference must be released with ReleaseProxyPort. Must NOT be called with mutex held!
func (*ProxyPorts) GetOpenLocalPorts ¶
func (p *ProxyPorts) GetOpenLocalPorts() map[uint16]struct{}
GetOpenLocalPorts returns the set of L4 ports currently open locally.
func (*ProxyPorts) GetProxyPort ¶
func (p *ProxyPorts) GetProxyPort(name string) (port uint16, isStatic bool, err error)
GetProxyPort() returns the fixed listen port for a proxy, if any.
func (*ProxyPorts) GetRulesPort ¶
func (p *ProxyPorts) GetRulesPort(pp *ProxyPort) uint16
func (*ProxyPorts) GetStatusInfo ¶
func (p *ProxyPorts) GetStatusInfo() (rangeMin, rangeMax, nPorts uint16)
func (*ProxyPorts) HasProxyType ¶
func (p *ProxyPorts) HasProxyType(pp *ProxyPort, proxyType types.ProxyType) bool
HasProxyType returns 'true' if 'pp' is configured and has the given proxy type.
func (*ProxyPorts) ReleaseProxyPort ¶
func (p *ProxyPorts) ReleaseProxyPort(name string) error
func (*ProxyPorts) ResetUnacknowledged ¶
func (p *ProxyPorts) ResetUnacknowledged(pp *ProxyPort)
ResetUnacknowledged() frees the port if it has not been acknowledged yet A static port is not reset.
func (*ProxyPorts) Restore ¶
func (p *ProxyPorts) Restore(pp *ProxyPort)
reset() frees the port Must be called with mutex held!
func (*ProxyPorts) RestoreProxyPorts ¶
func (p *ProxyPorts) RestoreProxyPorts()
RestoreProxyPorts tries to find earlier port numbers from datapath and use them as defaults for proxy ports
func (*ProxyPorts) SetProxyPort ¶
func (p *ProxyPorts) SetProxyPort(name string, proxyType types.ProxyType, port uint16, ingress bool) error
SetProxyPort() marks the proxy 'name' as successfully created with proxy port 'port'. Another call to AckProxyPort(name) is needed to update the datapath rules accordingly. This should only be called for proxies that have a static listener that is already listening on 'port'. May only be called once per proxy.
func (*ProxyPorts) StoreProxyPorts ¶
func (p *ProxyPorts) StoreProxyPorts(ctx context.Context) error
must be called with mutex NOT held via p.proxyPortsTrigger
type ProxyPortsConfig ¶
type ProxyPortsConfig struct { ProxyPortrangeMin uint16 ProxyPortrangeMax uint16 RestoredProxyPortsAgeLimit uint }
func (ProxyPortsConfig) Flags ¶
func (r ProxyPortsConfig) Flags(flags *pflag.FlagSet)