tunnel

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 19 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 tunnel implements the node side of flock.tunnel.v1.TunnelService: the persistent, node-initiated session over which the coordinator pushes dispatches, challenges and model assignments (SPEC §3: nodes dial out, never listen).

Index

Constants

This section is empty.

Variables

View Source
var ErrBadSignature = errors.New("tunnel: dispatch signature verification failed")

ErrBadSignature means a DispatchRequest failed verification against the pinned coordinator key. Such dispatches are never executed (SPEC §6).

Functions

func SignDispatch

func SignDispatch(priv ed25519.PrivateKey, d *tunnelv1.DispatchRequest) error

SignDispatch sets d.Signature (coordinator side; used by fakecoord and control-plane tests).

func VerifyDispatch

func VerifyDispatch(pub ed25519.PublicKey, d *tunnelv1.DispatchRequest) error

VerifyDispatch checks d.Signature against the pinned coordinator key.

Types

type Admitter

type Admitter interface {
	Admit(ctx context.Context, id string) (context.Context, func(), error)
}

Admitter gates work through the governor. *governor.Governor satisfies it.

type Client

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

Client maintains the session and handles pushed work.

func NewClient

func NewClient(o Options) (*Client, error)

NewClient validates options and builds a client.

func (*Client) Run

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

Run keeps the session alive until ctx is cancelled, reconnecting with jittered exponential backoff.

func (*Client) Sessions

func (c *Client) Sessions() int

Sessions returns the number of successful handshakes (reconnect tests).

type Dialer

type Dialer interface {
	Dial(ctx context.Context, addr string) (*grpc.ClientConn, error)
}

Dialer abstracts the transport so it can swap without touching the session logic. Production transport is QUIC via quic-go (SPEC §6); gRPC-over-HTTP/2 with mTLS is the current implementation and remains the documented fallback. TODO(quic): add a quic-go Dialer implementing this interface once the coordinator terminates QUIC.

type Engine

type Engine interface {
	Complete(ctx context.Context, req rt.CompletionRequest) (rt.TokenStream, error)
}

Engine runs inference for dispatches and challenges. Satisfied by the daemon's engine wrapper around runtime.Instance.

type InsecureDialer

type InsecureDialer struct{}

InsecureDialer is for local development only.

func (InsecureDialer) Dial

type Options

type Options struct {
	Dialer Dialer
	Addr   string
	NodeID string
	// CoordinatorPubKey is the Ed25519 dispatch-signing key pinned at
	// enrollment. Required: dispatches with bad signatures are dropped.
	CoordinatorPubKey ed25519.PublicKey

	Engine Engine
	Admit  Admitter
	// Heartbeat returns a fresh heartbeat message (telemetry assembly).
	Heartbeat func() *tunnelv1.Heartbeat
	// Hello returns the session-open message (capability, models, budget).
	Hello func() *tunnelv1.Hello
	// OnModelAssignment is invoked for coordinator model placement pushes.
	OnModelAssignment func(ctx context.Context, ma *tunnelv1.ModelAssignment)

	HeartbeatInterval time.Duration
	ReconnectMin      time.Duration
	ReconnectMax      time.Duration
	Log               *slog.Logger
}

Options configures the Client.

type TLSDialer

type TLSDialer struct {
	// TLS may carry RootCAs (pinned coordinator CA) and Certificates
	// (client cert from enrollment).
	TLS *tls.Config
}

TLSDialer dials gRPC over TLS/H2, optionally with a client certificate (mTLS after enrollment).

func (*TLSDialer) Dial

func (d *TLSDialer) Dial(_ context.Context, addr string) (*grpc.ClientConn, error)

Directories

Path Synopsis
Package fakecoord is an in-process fake coordinator implementing flock.tunnel.v1.TunnelService over bufconn (SPEC §A2.2 key seam).
Package fakecoord is an in-process fake coordinator implementing flock.tunnel.v1.TunnelService over bufconn (SPEC §A2.2 key seam).

Jump to

Keyboard shortcuts

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