tunnel

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package tunnel manages SSH local port forwarding for database connections.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled           bool
	Host              string
	Port              int
	User              string
	Password          string
	PrivateKey        string
	KnownHosts        string
	KeepAliveInterval time.Duration
	Reconnect         bool
	ReconnectAttempts int
	JumpHost          string
	JumpPort          int
	JumpUser          string
	JumpPassword      string
	JumpPrivateKey    string
	JumpKnownHosts    string
	RemoteHost        string
	RemotePort        int
}

Config describes the SSH endpoint, authentication material, and remote database endpoint used to create a local tunnel.

type Tunnel

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

Tunnel represents an active local TCP listener backed by an SSH client.

func Start

func Start(ctx context.Context, cfg Config) (*Tunnel, error)

Start opens an SSH tunnel when cfg.Enabled is true. Disabled tunnels return nil without error so callers can handle optional tunneling uniformly.

func (*Tunnel) Close

func (t *Tunnel) Close() error

Close stops accepting local connections and closes the SSH client.

func (*Tunnel) LocalHost

func (t *Tunnel) LocalHost() string

LocalHost returns the local address database clients should connect to.

func (*Tunnel) LocalPort

func (t *Tunnel) LocalPort() int

LocalPort returns the ephemeral local port assigned to the tunnel.

Jump to

Keyboard shortcuts

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