server

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 13 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 server assembles the hub half: a registry, a tunnel endpoint peers attach to, and (optionally) a proxy endpoint that reaches them, served together under one lifecycle.

Index

Constants

View Source
const (
	DefaultTunnelAddr = "127.0.0.1:7200"
	DefaultProxyAddr  = "127.0.0.1:7202"
)

The addresses New serves on when WithTunnel / WithProxy are not given — holt's canonical loopback ports.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option interface{ ApplyServer(*Server) }

Option configures a Server; every SharedOption is one too.

func WithGrace

func WithGrace(grace time.Duration) Option

WithGrace bounds how long Run waits for in-flight work when draining. Default 5s.

func WithLogger

func WithLogger(logger *zap.Logger) Option

WithLogger sets the logger. Default: no logging.

func WithProxy

func WithProxy(p *proxy.Proxy) Option

WithProxy serves the given proxy endpoint instead of the default one on DefaultProxyAddr (see proxy.NewProxy). Nil disables the proxy entirely, for a tunnel-only process.

func WithRegistry

func WithRegistry(reg *registry.Registry) Option

WithRegistry supplies the registry instead of the default registry.NewRegistry(logger) — the way to set a hub id, a shared presence Directory, or a MeterProvider.

func WithTunnel

func WithTunnel(t *tunnel.Tunnel) Option

WithTunnel serves the given tunnel endpoint instead of the default one on DefaultTunnelAddr (see tunnel.NewTunnel). Nil disables the tunnel entirely, for a proxy-only process.

type Server

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

Server is the assembled hub: a Registry, a Tunnel endpoint peers attach to, and (optionally) a Proxy endpoint that reaches them. It is the one-call counterpart of client.New for the server side.

Zero configuration works: New().Run(ctx) serves a tunnel on 127.0.0.1:7200 and a proxy on 127.0.0.1:7202 with the development identity — peers name themselves with the x-holt-peer header (or get a generated name) and nothing verifies the claim. That identity is loopback-only by construction: a tunnel bound to anything other than a loopback address with no identity configured refuses to start, so the trusting default cannot reach a network.

The operator surface stays reachable through Registry: roster, stop, watch, or mounting the admin service.

func New

func New(opts ...Option) *Server

New assembles a hub from the options, laid over the defaults — the caller's options are just applied last, so overriding a default is passing the same option with another value. Nothing binds or serves until Run.

func (*Server) Registry

func (s *Server) Registry() *registry.Registry

Registry is the operational surface over the server's live tunnels: roster, stop, watch, and the value to build an admin service on.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run binds the configured endpoints, serves, and blocks until ctx is cancelled — then stops every tunnel, drains the listeners for up to the grace period, and returns nil. Binding is synchronous, so a taken port fails here, before anything serves.

Jump to

Keyboard shortcuts

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