edgeagent

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package edgeagent is the Edge relay's Sidecar agent, which relays TCP connections to an ingress in the emulator with a PROXY v2 header, and the LAN relay containers that run it in LAN mode on the host network: lb-lan for --lb-bind and gfe-lan, the LAN front-end relay, for --gfe-bind.

Index

Constants

View Source
const (
	// EdgeAgentName runs the lb-edge container's agent.
	EdgeAgentName = "lb-edge"
	// LANAgentName runs the agent in LAN mode, in a LANRelay container.
	LANAgentName = "lb-lan"
	// ControlPort and RelayPort are the lb-edge agent's ports.
	ControlPort = 15080
	RelayPort   = 15081
	// TokenHeader carries the control port's token.
	TokenHeader = "X-Gcpemu-Lb-Token"
)
View Source
const Image = "rancher/k3s:v1.36.5-k3s1"

Image is the image lb-edge and the LAN relay containers run the Sidecar agent in.

Variables

This section is empty.

Functions

func AcceptProxied

func AcceptProxied(c net.Conn) (*proxiedConn, error)

AcceptProxied reads the PROXY header of a new connection.

func ProxiedListener

func ProxiedListener(ln net.Listener) net.Listener

ProxiedListener accepts from ln only connections that start with a PROXY v2 header, which each reads in its own goroutine, and closes every other; the connections it returns have the header's addresses.

func ReadProxyV2

func ReadProxyV2(r *bufio.Reader) (src, dst *net.TCPAddr, err error)

ReadProxyV2 parses a PROXY v2 header from r, ignoring its TLVs.

func WriteProxyV2

func WriteProxyV2(w io.Writer, src, dst *net.TCPAddr, tlvs ...TLV) error

WriteProxyV2 writes a PROXY v2 header for a TCP connection src → dst, with tlvs after the addresses.

Types

type Config

type Config struct {
	Ingress   string     `json:"ingress"`
	Listeners []Listener `json:"listeners"`
	Routes    []Route    `json:"routes"`
	// Public are external forwarding rule addresses and ports (#187).
	Public []Listener `json:"public,omitempty"`
}

Config is the desired state the emulator posts to the agent.

type LANRelay

type LANRelay struct {
	// Runtime returns the container runtime.
	Runtime func(context.Context) (*runtime.Manager, error)
	// Name names the container (gcpemu-<id>-<Name>) and its log lines.
	Name string
	// Service, Resource and Role label the container.
	Service, Resource, Role string
	// Offline: the image is not pulled.
	Offline bool
	Log     *slog.Logger
	// contains filtered or unexported fields
}

LANRelay manages a LAN relay container: on the host network, with NET_BIND_SERVICE, it runs the agent in LAN mode, listens on host addresses on ports the emulator cannot bind (privileged ports) and relays each connection, with a PROXY v2 header, to an ingress on the host's loopback. It forwards plain TCP. The lb Service's lb-lan, the LAN load balancing relay (--lb-bind), and the Google front end's gfe-lan, the LAN front-end relay (--gfe-bind), are two.

func (*LANRelay) Close

func (r *LANRelay) Close(ctx context.Context)

Close removes the container.

func (*LANRelay) Set

func (r *LANRelay) Set(ctx context.Context, ingress string, addrs []string) error

Set makes the relay listen on exactly addrs (host:port) and relay to ingress, starting the container on demand and removing it when addrs is empty.

type Listener

type Listener struct {
	IP   string `json:"ip"`
	Port int    `json:"port"`
}

Listener is an address and port the agent listens on.

type Route

type Route struct {
	CIDR string `json:"cidr"`
	Via  string `json:"via"`
}

Route is a route the Sidecar agent installs.

type TLV added in v0.12.0

type TLV struct {
	Type  byte
	Value []byte
}

TLV is a PROXY v2 type-length-value field, following the addresses.

func ReadProxyV2TLVs added in v0.12.0

func ReadProxyV2TLVs(r *bufio.Reader) (src, dst *net.TCPAddr, tlvs []TLV, err error)

ReadProxyV2TLVs parses a PROXY v2 header from r, with the TLVs that follow its addresses.

Jump to

Keyboard shortcuts

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