relay

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(ctx context.Context, addr string, handler http.Handler) (string, error)

ListenAndServe starts the relay on the given address. Returns the actual address (useful when addr is ":0").

func ListenAndServeQUIC

func ListenAndServeQUIC(ctx context.Context, addr string, handler http.Handler, tlsCfg *tls.Config) error

ListenAndServeQUIC starts an HTTP/3 (QUIC) server on the given UDP address, serving the same handler as the TCP listener. The addr should match the TCP port so clients can reach both protocols on the same host:port.

func ListenAndServeTLS

func ListenAndServeTLS(ctx context.Context, addr string, handler http.Handler, srv *http.Server) (string, error)

ListenAndServeTLS starts the relay with TLS on the given address. Returns the actual address (useful when addr is ":0").

func Port

func Port(addr string) string

Port extracts just the port number from an addr like "127.0.0.1:PORT".

Types

type Config

type Config struct {
	Token       string
	SSHDAddr    string
	BufSize     int
	NoTLS       bool
	IdleTimeout time.Duration // shut down if no client connected for this long (default 60s)
}

Config holds relay configuration.

type Relay

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

Relay manages a single SSH session bridged over HTTP streaming.

func New

func New(cfg Config) *Relay

New creates a new Relay with the given config.

func (*Relay) Done

func (r *Relay) Done() <-chan struct{}

Done returns a channel that is closed when the sshd connection drops (i.e. the SSH session ended). Callers should shut down the listener.

func (*Relay) Handler

func (r *Relay) Handler() http.Handler

Handler returns the HTTP handler for the relay endpoints.

func (*Relay) Idle

func (r *Relay) Idle() <-chan struct{}

Idle returns a channel that is closed when the relay has been idle (no connected client) for longer than IdleTimeout.

Jump to

Keyboard shortcuts

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