networker

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: AGPL-3.0 Imports: 29 Imported by: 2 modules, 2 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 networker manages resource and static port-forward sessions. Resource forwards preserve caller cancellation through readiness and retain their admitted connection-generation lease for the accepted session lifetime.

Index

Constants

View Source
const (
	// PluginID is the capability name used to register and discover networker plugins.
	PluginID = "networker"
)

Variables

View Source
var (
	ErrNetSessionNotFound        = &NetworkerError{Code: ErrCodeSessionNotFound}
	ErrNetNoHandlerFound         = &NetworkerError{Code: ErrCodeNoHandlerFound}
	ErrNetPortUnavailable        = &NetworkerError{Code: ErrCodePortUnavailable}
	ErrNetForwarderFailed        = &NetworkerError{Code: ErrCodeForwarderFailed}
	ErrNetManagerShuttingDown    = &NetworkerError{Code: ErrCodeManagerShuttingDown}
	ErrNetInvalidStateTransition = &NetworkerError{Code: ErrCodeInvalidStateTransition}
	ErrNetInvalidConnectionType  = &NetworkerError{Code: ErrCodeInvalidConnectionType}
)

Sentinel errors support code-based matching with errors.Is.

View Source
var (
	ErrSessionClosed  = errors.New("session closed")
	ErrManagerStopped = errors.New("manager stopped")
)

Sentinel causes for context cancellation — forwarders can inspect these via context.Cause to distinguish intentional stops from failures.

Functions

func CanTransition

func CanTransition(from, to SessionState) bool

CanTransition reports whether a nonterminal state permits the requested change.

func FindFreeTCPPort

func FindFreeTCPPort() (int32, error)

FindFreeTCPPort finds an available port by letting the OS pick a free port. The port is not reserved after this function returns.

func IsPortUnavailable

func IsPortUnavailable(port int32) bool

IsPortUnavailable reports whether a TCP connection to the local port succeeds. A failed probe returns false but does not guarantee that a listener can bind.

func RegisterNetworkerPluginServer added in v0.9.0

func RegisterNetworkerPluginServer(registrar grpc.ServiceRegistrar, server networkerpb.NetworkerPluginServer)

RegisterNetworkerPluginServer admits resource requests before generated decoding.

func RegisterPlugin

func RegisterPlugin(
	p *sdk.Plugin,
	opts PluginOpts,
) error

RegisterPlugin constructs a manager and registers the networker capability.

Types

type Connection

type Connection interface {
	// contains filtered or unexported methods
}

Connection is implemented by PortForwardResourceConnection and PortForwardStaticConnection. The unexported method seals the interface.

type FindPortForwardSessionRequest

type FindPortForwardSessionRequest struct {
	ResourceID   string `json:"resource_id"`
	ConnectionID string `json:"connection_id"`
}

FindPortForwardSessionRequest filters sessions by opaque resource and connection selectors. Empty selectors do not restrict that dimension.

func NewFindPortForwardSessionRequestFromProto

func NewFindPortForwardSessionRequestFromProto(
	p *networkerpb.FindPortForwardSessionRequest,
) FindPortForwardSessionRequest

NewFindPortForwardSessionRequestFromProto copies selectors; nil matches all sessions.

func (FindPortForwardSessionRequest) ToProto

ToProto copies the filter selectors into a wire request.

type ForwarderResult

type ForwarderResult struct {
	SessionID string
	Ready     <-chan struct{} // closed when tunnel established
	ErrCh     <-chan error    // receives fatal error; closed on clean exit
}

ForwarderResult carries the outcome of starting a port forward. The Ready channel is closed once the tunnel is established. The ErrCh channel receives a fatal error or is closed on clean exit. The manager monitors ErrCh to detect post-start failures.

type Manager

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

Manager manages the lifecycle of networker actions, such as port forwarding sessions.

func NewManager

func NewManager(cfg ManagerConfig, opts PluginOpts) *Manager

NewManager creates a new Manager with the given config and plugin opts.

func (*Manager) BindConnectionContextProvider added in v0.9.0

func (m *Manager) BindConnectionContextProvider(provider resourcev2.ConnectionContextProvider)

BindConnectionContextProvider binds resource forwarding to the active registry.

func (*Manager) ClosePortForwardSession

func (m *Manager) ClosePortForwardSession(
	_ *types.PluginContext,
	sessionID string,
) (*PortForwardSession, error)

ClosePortForwardSession cancels a tunnel and waits for its monitor up to the configured close timeout. Unknown IDs return a session-not-found error.

func (*Manager) FindPortForwardSessions

func (m *Manager) FindPortForwardSessions(
	_ *types.PluginContext,
	req FindPortForwardSessionRequest,
) ([]*PortForwardSession, error)

FindPortForwardSessions returns owned snapshots matching both nonempty selectors.

func (*Manager) GetPortForwardSession

func (m *Manager) GetPortForwardSession(
	_ *types.PluginContext,
	sessionID string,
) (*PortForwardSession, error)

GetPortForwardSession returns an owned snapshot or a session-not-found error.

func (*Manager) GetSupportedPortForwardTargets

func (m *Manager) GetSupportedPortForwardTargets(_ *types.PluginContext) ([]string, error)

GetSupportedPortForwardTargets returns registered opaque resource keys.

func (*Manager) ListPortForwardSessions

func (m *Manager) ListPortForwardSessions(_ *types.PluginContext) ([]*PortForwardSession, error)

ListPortForwardSessions returns owned snapshots, including terminal sessions.

func (*Manager) StartPortForwardSession

func (m *Manager) StartPortForwardSession(
	pluginctx *types.PluginContext,
	opts PortForwardSessionOptions,
) (*PortForwardSession, error)

StartPortForwardSession creates a static tunnel. Creation observes request cancellation; accepted tunnels survive the initiating request's completion. Resource targets require StartResourcePortForwardSession.

func (*Manager) StartResourcePortForwardSession added in v0.9.0

func (m *Manager) StartResourcePortForwardSession(
	pluginctx *types.PluginContext,
	opts PortForwardSessionOptions,
) (*PortForwardSession, error)

StartResourcePortForwardSession admits a resource target against the configured registry and retains its generation lease until tunnel closure or retirement. Cancellation remains attached throughout creation, readiness, and admission.

func (*Manager) StopAll

func (m *Manager) StopAll()

StopAll cancels all active sessions and waits for monitor goroutines to complete within the configured timeout.

type ManagerConfig

type ManagerConfig struct {
	Logger       logging.Logger
	Settings     settings.Provider
	PortChecker  PortChecker    // nil → RealPortChecker
	Clock        timeutil.Clock // nil → timeutil.RealClock
	CloseTimeout time.Duration  // default 10s
}

ManagerConfig configures the Manager.

type NetworkerError

type NetworkerError struct {
	Code      NetworkerErrorCode
	SessionID string
	Message   string
	Err       error // optional wrapped error
}

NetworkerError is a structured error for networker operations.

func NewForwarderFailedError

func NewForwarderFailedError(sessionID string, err error) *NetworkerError

NewForwarderFailedError wraps a native failure and associates it with a session.

func NewInvalidConnectionTypeError

func NewInvalidConnectionTypeError(connectionType string) *NetworkerError

NewInvalidConnectionTypeError identifies an unsupported connection kind.

func NewInvalidStateTransitionError

func NewInvalidStateTransitionError(sessionID string, from, to SessionState) *NetworkerError

NewInvalidStateTransitionError describes the rejected session state change.

func NewManagerShuttingDownError

func NewManagerShuttingDownError(sessionID string) *NetworkerError

NewManagerShuttingDownError reports that shutdown prevents work on the session.

func NewNoHandlerFoundError

func NewNoHandlerFoundError(resourceKey string) *NetworkerError

NewNoHandlerFoundError identifies a resource key without a registered forwarder.

func NewPortUnavailableError

func NewPortUnavailableError(port int32) *NetworkerError

NewPortUnavailableError identifies the local port that cannot be used.

func NewSessionNotFoundError

func NewSessionNotFoundError(sessionID string) *NetworkerError

NewSessionNotFoundError identifies the session that could not be found.

func (*NetworkerError) Error

func (e *NetworkerError) Error() string

Error formats the code, optional session ID, and diagnostic message.

func (*NetworkerError) Is

func (e *NetworkerError) Is(target error) bool

Is reports whether target matches this error's code.

func (*NetworkerError) Unwrap

func (e *NetworkerError) Unwrap() error

Unwrap returns the underlying forwarder error, if present.

type NetworkerErrorCode

type NetworkerErrorCode int

NetworkerErrorCode classifies networker errors for programmatic handling.

const (
	// ErrCodeSessionNotFound identifies an unknown session ID.
	ErrCodeSessionNotFound NetworkerErrorCode = iota + 1
	// ErrCodeNoHandlerFound identifies a resource without a registered forwarder.
	ErrCodeNoHandlerFound
	// ErrCodePortUnavailable identifies a local port already in use.
	ErrCodePortUnavailable
	// ErrCodeForwarderFailed identifies a native tunnel startup or runtime failure.
	ErrCodeForwarderFailed
	// ErrCodeManagerShuttingDown rejects work after manager shutdown begins.
	ErrCodeManagerShuttingDown
	// ErrCodeInvalidStateTransition identifies an unsupported session state change.
	ErrCodeInvalidStateTransition
	// ErrCodeInvalidConnectionType identifies an unsupported connection kind.
	ErrCodeInvalidConnectionType
)

func (NetworkerErrorCode) String

func (c NetworkerErrorCode) String() string

String returns the stable uppercase error code, or UNKNOWN for an unrecognized code.

type Plugin

type Plugin struct {
	plugin.Plugin

	Impl Provider
}

Plugin connects a forwarding provider to the HashiCorp gRPC plugin protocol.

func (*Plugin) BindConnectionContextProvider added in v0.9.0

func (p *Plugin) BindConnectionContextProvider(provider resourcev2.ConnectionContextProvider)

BindConnectionContextProvider delegates registry binding to capable providers.

func (*Plugin) GRPCClient

func (p *Plugin) GRPCClient(
	_ context.Context,
	_ *plugin.GRPCBroker,
	c *grpc.ClientConn,
) (any, error)

GRPCClient creates a forwarding client for the supplied plugin connection.

func (*Plugin) GRPCServer

func (p *Plugin) GRPCServer(_ *plugin.GRPCBroker, s *grpc.Server) error

GRPCServer registers the provider with resource-aware request admission.

type PluginClient

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

PluginClient manages remote forwarding sessions through resource-aware gRPC calls.

func (*PluginClient) ClosePortForwardSession

func (p *PluginClient) ClosePortForwardSession(
	ctx *types.PluginContext,
	sessionID string,
) (*PortForwardSession, error)

ClosePortForwardSession closes the remote session and returns its final snapshot.

func (*PluginClient) FindPortForwardSessions

func (p *PluginClient) FindPortForwardSessions(
	ctx *types.PluginContext,
	req FindPortForwardSessionRequest,
) ([]*PortForwardSession, error)

FindPortForwardSessions returns all of the port forward sessions that match the given request.

func (*PluginClient) GetPortForwardSession

func (p *PluginClient) GetPortForwardSession(
	ctx *types.PluginContext,
	sessionID string,
) (*PortForwardSession, error)

GetPortForwardSession returns a port forward session by ID.

func (*PluginClient) GetSupportedPortForwardTargets

func (p *PluginClient) GetSupportedPortForwardTargets(ctx *types.PluginContext) ([]string, error)

GetSupportedPortForwardTargets returns the list of targets that are supported by this plugin for port forwarding.

func (*PluginClient) ListPortForwardSessions

func (p *PluginClient) ListPortForwardSessions(
	ctx *types.PluginContext,
) ([]*PortForwardSession, error)

ListPortForwardSessions returns all of the port forward sessions.

func (*PluginClient) StartPortForwardSession

func (p *PluginClient) StartPortForwardSession(
	ctx *types.PluginContext,
	opts PortForwardSessionOptions,
) (*PortForwardSession, error)

StartPortForwardSession starts a static forward or dispatches resource options through the lossless resource RPC without falling back to the legacy RPC.

func (*PluginClient) StartResourcePortForwardSession added in v0.9.0

func (p *PluginClient) StartResourcePortForwardSession(
	ctx *types.PluginContext,
	opts PortForwardSessionOptions,
) (*PortForwardSession, error)

StartResourcePortForwardSession requires resource-v2 support and carries the caller's admission observations and cancellation through native readiness. An accepted session remains open after this RPC completes.

func (*PluginClient) StopAll

func (p *PluginClient) StopAll()

StopAll performs a best-effort shutdown of all remote sessions by listing them and closing each individually. Per-session close errors are logged but do not stop the loop.

type PluginOpts

type PluginOpts struct {
	// ResourceForwarders maps resource key → ResourceForwarder.
	ResourceForwarders map[string]ResourceForwarder
	// StaticForwarders maps key → StaticForwarder.
	StaticForwarders map[string]StaticForwarder
}

PluginOpts contains the options for the networker plugin, passed to RegisterPlugin.

type PluginServer

type PluginServer struct {
	networkerpb.UnimplementedNetworkerPluginServer

	Impl Provider
}

PluginServer exposes a forwarding provider over gRPC with resource wire admission.

func (*PluginServer) ClosePortForwardSession

ClosePortForwardSession closes the requested forward and returns its final snapshot.

func (*PluginServer) FindPortForwardSessions

FindPortForwardSessions returns bounded snapshots matching the supplied filters.

func (*PluginServer) GetPortForwardSession

GetPortForwardSession returns a bounded wire snapshot for the requested session.

func (*PluginServer) GetSupportedPortForwardTargets

func (s *PluginServer) GetSupportedPortForwardTargets(
	ctx context.Context,
	_ *emptypb.Empty,
) (*networkerpb.GetSupportedPortForwardTargetsResponse, error)

GetSupportedPortForwardTargets lists resource keys with registered forwarders.

func (*PluginServer) ListPortForwardSessions

func (s *PluginServer) ListPortForwardSessions(
	ctx context.Context,
	_ *emptypb.Empty,
) (*networkerpb.PortForwardSessionListResponse, error)

ListPortForwardSessions returns session snapshots within the aggregate wire limit.

func (*PluginServer) StartPortForwardSession

StartPortForwardSession starts a legacy static forward and rejects resource payloads.

func (*PluginServer) StartResourcePortForwardSession added in v0.9.0

StartResourcePortForwardSession admits resource-v2 context and starts a forward. Caller cancellation remains attached through readiness; accepted session lifetime and its retained connection-generation lease belong to the forwarding provider.

type PortChecker

type PortChecker interface {
	// FindFreePort returns a free TCP port.
	FindFreePort() (int32, error)
	// IsPortUnavailable returns true if the port is already in use.
	IsPortUnavailable(port int32) bool
}

PortChecker abstracts port availability operations so tests can inject fakes.

type PortForwardConnectionType

type PortForwardConnectionType string

PortForwardConnectionType distinguishes resource and static forwarding targets.

const (
	// PortForwardConnectionTypeResource selects a registered resource forwarder.
	PortForwardConnectionTypeResource PortForwardConnectionType = "RESOURCE"
	// PortForwardConnectionTypeStatic selects a registered address forwarder.
	PortForwardConnectionTypeStatic PortForwardConnectionType = "STATIC"
)

type PortForwardProtocol

type PortForwardProtocol string

PortForwardProtocol selects the native transport protocol.

const (
	// PortForwardProtocolTCP requests a TCP tunnel.
	PortForwardProtocolTCP PortForwardProtocol = "TCP"
	// PortForwardProtocolUDP requests a UDP tunnel.
	PortForwardProtocolUDP PortForwardProtocol = "UDP"
)

func PortForwardProtocolFromProto

func PortForwardProtocolFromProto(
	p networkerpb.PortForwardProtocol,
) PortForwardProtocol

PortForwardProtocolFromProto converts from the protobuf enum. Unknown proto values map to an invalid internal protocol (empty string), which callers can detect via Valid().

func (PortForwardProtocol) String

func (p PortForwardProtocol) String() string

String returns the protocol label.

func (PortForwardProtocol) ToProto

ToProto converts to the protobuf enum. Unknown values are encoded as an unknown enum value (-1), so callers should validate with Valid() upstream.

func (PortForwardProtocol) Valid

func (p PortForwardProtocol) Valid() bool

Valid returns true if the protocol is a known value (TCP or UDP).

type PortForwardProvider

type PortForwardProvider interface {
	GetSupportedPortForwardTargets(*types.PluginContext) ([]string, error)
	GetPortForwardSession(*types.PluginContext, string) (*PortForwardSession, error)
	ListPortForwardSessions(*types.PluginContext) ([]*PortForwardSession, error)
	FindPortForwardSessions(
		*types.PluginContext,
		FindPortForwardSessionRequest,
	) ([]*PortForwardSession, error)
	StartPortForwardSession(
		*types.PluginContext,
		PortForwardSessionOptions,
	) (*PortForwardSession, error)
	ClosePortForwardSession(*types.PluginContext, string) (*PortForwardSession, error)
	StopAll()
}

PortForwardProvider manages forwarding sessions and reports supported resource targets.

type PortForwardResourceConnection

type PortForwardResourceConnection struct {
	ResourceData *resourcev2.Value             `json:"resource_data,omitempty"`
	Reference    *resourcev2.ResourceReference `json:"reference,omitempty"`
	Route        *resourcev2.AccessRoute       `json:"route,omitempty"`
	ConnectionID string                        `json:"connection_id"`
	PluginID     string                        `json:"plugin_id"`
	ResourceID   string                        `json:"resource_id"`
	ResourceKey  string                        `json:"resource_key"`
}

PortForwardResourceConnection carries exact tagged resource data and only the reference and route supplied by the caller. Opaque legacy selectors retain their original spelling; no identity or resource acquisition is inferred.

func PortForwardResourceConnectionFromProto

func PortForwardResourceConnectionFromProto(
	o *networkerpb.PortForwardResourceConnection,
) (PortForwardResourceConnection, error)

PortForwardResourceConnectionFromProto validates version, unknown fields, and tagged values before decoding. The result owns its decoded resource data.

func (*PortForwardResourceConnection) ToProto

ToProto validates exact tagged data and returns an independently owned wire value. Nil receivers and oversized frames return classified resource errors.

func (*PortForwardResourceConnection) UnmarshalJSON added in v0.9.0

func (c *PortForwardResourceConnection) UnmarshalJSON(data []byte) error

UnmarshalJSON rejects unknown fields and invalid resource references, routes, or lossless values before replacing the receiver.

type PortForwardSession

type PortForwardSession struct {
	CreatedAt      time.Time                    `json:"created_at"`
	UpdatedAt      time.Time                    `json:"updated_at"`
	Connection     Connection                   `json:"connection"`
	Labels         map[string]string            `json:"labels"`
	ID             string                       `json:"id"`
	Protocol       PortForwardProtocol          `json:"protocol"`
	State          SessionState                 `json:"state"`
	ConnectionType PortForwardConnectionType    `json:"connection_type"`
	Encryption     PortForwardSessionEncryption `json:"encryption"`
	LocalPort      int32                        `json:"local_port"`
	RemotePort     int32                        `json:"remote_port"`
}

PortForwardSession represents a session between a forwarding target and the host.

func NewPortForwardSessionFromProto

func NewPortForwardSessionFromProto(s *networkerpb.PortForwardSession) (*PortForwardSession, error)

NewPortForwardSessionFromProto validates and decodes a bounded session frame. Nil input stays absent; invalid resource states, timestamps, and versions fail.

func (*PortForwardSession) ToProto

ToProto validates and copies the session into a bounded wire frame. A nil receiver represents an absent session and returns nil without error.

type PortForwardSessionEncryption

type PortForwardSessionEncryption struct {
	Algorithm string `json:"algorithm"`
	Key       string `json:"key"`
	Enabled   bool   `json:"enabled"`
}

PortForwardSessionEncryption carries forwarder-specific encryption settings. The manager transports these settings; the native forwarder enforces support.

func PortForwardSessionEncryptionFromProto

func PortForwardSessionEncryptionFromProto(
	o *networkerpb.PortForwardSessionEncryption,
) PortForwardSessionEncryption

PortForwardSessionEncryptionFromProto copies settings; nil produces disabled encryption.

func (*PortForwardSessionEncryption) ToProto

ToProto copies encryption settings; nil stays absent.

type PortForwardSessionOptions

type PortForwardSessionOptions struct {
	Connection     Connection                   `json:"connection"`
	Labels         map[string]string            `json:"labels"`
	Params         map[string]string            `json:"params"`
	Protocol       PortForwardProtocol          `json:"protocol"`
	ConnectionType PortForwardConnectionType    `json:"connection_type"`
	Encryption     PortForwardSessionEncryption `json:"encryption"`
	LocalPort      int32                        `json:"local_port"`
	RemotePort     int32                        `json:"remote_port"`
}

PortForwardSessionOptions configures a new tunnel. LocalPort zero requests an available port. The manager copies labels and connection data on acceptance.

func NewPortForwardSessionOptionsFromProto

func NewPortForwardSessionOptionsFromProto(
	o *networkerpb.PortForwardSessionOptions,
) (*PortForwardSessionOptions, error)

NewPortForwardSessionOptionsFromProto validates the wire frame and resource version before decoding. Nil options return INVALID_REQUEST.

func (*PortForwardSessionOptions) ToProto

ToProto validates metadata and resource payloads before allocating a bounded frame. Nil options return INVALID_REQUEST.

func (*PortForwardSessionOptions) UnmarshalJSON added in v0.2.1

func (o *PortForwardSessionOptions) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a strict options envelope and validates resource targets without inferring identity from legacy selectors.

type PortForwardStaticConnection

type PortForwardStaticConnection struct {
	Address string `json:"address"`
}

PortForwardStaticConnection identifies a native address without resource identity.

func PortForwardStaticConnectionFromJson

func PortForwardStaticConnectionFromJson(o map[string]any) *PortForwardStaticConnection

PortForwardStaticConnectionFromJson reads a string address; absent or nonstring addresses remain empty, matching the static target's zero value.

func PortForwardStaticConnectionFromProto

func PortForwardStaticConnectionFromProto(
	o *networkerpb.PortForwardStaticConnection,
) PortForwardStaticConnection

PortForwardStaticConnectionFromProto copies the address; nil produces the zero value.

func (*PortForwardStaticConnection) ToProto

ToProto copies the address; a nil receiver stays absent.

func (*PortForwardStaticConnection) ToSessionOptionsProto

ToSessionOptionsProto wraps the address in the options connection oneof.

func (*PortForwardStaticConnection) ToSessionProto

ToSessionProto wraps the address in the session connection oneof.

type Provider

type Provider interface {
	PortForwardProvider
}

Provider embeds the session-management contract shared by local managers and remote clients. Resource forwarding is an optional ResourcePortForwardProvider.

type RealPortChecker

type RealPortChecker struct{}

RealPortChecker performs actual network checks.

func (RealPortChecker) FindFreePort

func (RealPortChecker) FindFreePort() (int32, error)

FindFreePort returns an available TCP port selected by the operating system.

func (RealPortChecker) IsPortUnavailable

func (RealPortChecker) IsPortUnavailable(port int32) bool

IsPortUnavailable reports whether a TCP connection to the local port succeeds.

type ResourceForwarder

type ResourceForwarder interface {
	ForwardResource(
		ctx context.Context,
		pctx *types.PluginContext,
		opts ResourcePortForwardHandlerOpts,
	) (*ForwarderResult, error)
}

ResourceForwarder initiates a port forward for a resource.

type ResourceForwarderFunc

type ResourceForwarderFunc func(ctx context.Context, pctx *types.PluginContext, opts ResourcePortForwardHandlerOpts) (*ForwarderResult, error)

ResourceForwarderFunc adapts a plain function to the ResourceForwarder interface.

func (ResourceForwarderFunc) ForwardResource

ForwardResource calls f with the resource forwarding request.

type ResourcePortForwardHandlerOpts

type ResourcePortForwardHandlerOpts struct {
	Resource PortForwardResourceConnection `json:"resource"`
	Options  PortForwardSessionOptions     `json:"options"`
}

ResourcePortForwardHandlerOpts pairs resource identity with forwarding options.

type ResourcePortForwardProvider added in v0.9.0

type ResourcePortForwardProvider interface {
	StartResourcePortForwardSession(*types.PluginContext, PortForwardSessionOptions) (*PortForwardSession, error)
}

ResourcePortForwardProvider opts into lossless resource forwarding through the existing forwarding engine. Resource connections use this method even when ResourceData is nil. Older peers return UNSUPPORTED; clients never retry the legacy static-only StartPortForwardSession RPC.

type SessionState

type SessionState string

SessionState describes tunnel availability; stopped and failed states are terminal.

const (
	// SessionStateActive means the forwarder has reported readiness.
	SessionStateActive SessionState = "ACTIVE"
	// SessionStatePaused permits resumption or termination.
	SessionStatePaused SessionState = "PAUSED"
	// SessionStateStopped marks intentional termination.
	SessionStateStopped SessionState = "STOPPED"
	// SessionStateFailed marks unexpected termination.
	SessionStateFailed SessionState = "FAILED"
)

func (SessionState) String

func (s SessionState) String() string

String returns the stable state label.

func (SessionState) ToProto

ToProto encodes the state; unknown states map to stopped.

type StaticForwarder

type StaticForwarder interface {
	ForwardStatic(
		ctx context.Context,
		pctx *types.PluginContext,
		opts StaticPortForwardHandlerOpts,
	) (*ForwarderResult, error)
}

StaticForwarder initiates a port forward for a static address.

type StaticForwarderFunc

type StaticForwarderFunc func(ctx context.Context, pctx *types.PluginContext, opts StaticPortForwardHandlerOpts) (*ForwarderResult, error)

StaticForwarderFunc adapts a plain function to the StaticForwarder interface.

func (StaticForwarderFunc) ForwardStatic

ForwardStatic calls f with the static forwarding request.

type StaticPortForwardHandlerOpts

type StaticPortForwardHandlerOpts struct {
	Static  PortForwardStaticConnection `json:"static"`
	Options PortForwardSessionOptions   `json:"options"`
}

StaticPortForwardHandlerOpts pairs a native address with forwarding options.

Directories

Path Synopsis
Package networktest provides forwarding fakes, session harnesses, and state observers for tests that exercise the real networker session manager.
Package networktest provides forwarding fakes, session harnesses, and state observers for tests that exercise the real networker session manager.

Jump to

Keyboard shortcuts

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