client

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoRoute = errors.New("client: no route configured")

ErrNoRoute is returned by connect handlers to indicate that the request should fall back to the default configuration-based routing.

Functions

This section is empty.

Types

type BackendConfig

type BackendConfig struct {
	Name           string              `yaml:"name"`
	Hostname       string              `yaml:"hostname"`
	Hostnames      []string            `yaml:"hostnames"`
	NexusAddresses []string            `yaml:"nexusAddresses"`
	AuthToken      string              `yaml:"authToken"`
	PortMappings   map[int]PortMapping `yaml:"portMappings"`
	HealthChecks   HealthCheckConfig   `yaml:"healthChecks"`
}

type Client

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

Client manages the full lifecycle for one configured backend service.

func New

func New(cfg ClientBackendConfig, opts ...Option) *Client

New creates a new Client instance for a specific backend configuration.

func (*Client) Start

func (c *Client) Start(ctx context.Context)

Start initiates the client's connection loop.

func (*Client) Stop

func (c *Client) Stop()

Stop gracefully shuts down the client and its connections.

type ClientBackendConfig

type ClientBackendConfig struct {
	Name         string
	Hostnames    []string
	NexusAddress string
	AuthToken    string
	PortMappings map[int]PortMapping
	HealthChecks HealthCheckConfig
}

type Config

type Config struct {
	Backends []BackendConfig `yaml:"backends"`
}

func LoadConfig

func LoadConfig(path string) (*Config, error)

type ConnectHandler

type ConnectHandler func(ctx context.Context, req ConnectRequest) (net.Conn, error)

ConnectHandler is invoked whenever the proxy asks us to establish a new local connection. Returning ErrNoRoute will defer to the default port-mapping behaviour. Any other error is treated as fatal for that request.

type ConnectRequest

type ConnectRequest struct {
	BackendName      string
	ClientID         uuid.UUID
	Hostname         string
	OriginalHostname string
	Port             int
	ClientIP         string
}

ConnectRequest provides context about a client connection request coming from the Nexus proxy.

type HealthCheckConfig

type HealthCheckConfig struct {
	Enabled           bool `yaml:"enabled"`
	InactivityTimeout int  `yaml:"inactivityTimeout"`
	PongTimeout       int  `yaml:"pongTimeout"`
}

type Option

type Option func(*Client)

Option mutates a Client during construction.

func WithConnectHandler

func WithConnectHandler(handler ConnectHandler) Option

WithConnectHandler registers a custom connect handler. The handler is invoked before the default port-mapping logic. Returning ErrNoRoute (or a nil connection) will fall back to the default handler.

type PortMapping

type PortMapping struct {
	Default string            `yaml:"default"`
	Hosts   map[string]string `yaml:"hosts"`
	// contains filtered or unexported fields
}

func (PortMapping) Resolve

func (pm PortMapping) Resolve(hostname string) (string, bool)

Jump to

Keyboard shortcuts

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