Help us shape the future of Go! Take the 2026 Go Developer Survey

sshtunnel

package
v1.31.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoTunnelCloser func() error = func() error { return nil }

NoTunnelCloser is a function that does nothing and returns nil.

Functions

func Socks5HTTPTransport

func Socks5HTTPTransport(host string, port int) *http.Transport

Socks5HTTPTransport returns an http.Transport that uses the provided host and port as a socks5 proxy. This is useful for making http requests through a socks5 tunnel. It uses http.DefaultTransport as a base.

func ValidateHost added in v1.30.1

func ValidateHost(c *Config, opts ...util.HostValidationOption) error

ValidateHost validates the tunnel endpoint, if a tunnel is configured.

The ssh host is caller-supplied like every other connection field, and the tunnel is an outbound connection in its own right — so a benign warehouse host says nothing about where the tunnel actually goes. Connectors pass the same options they use for the warehouse host, so a config permitted to use loopback for the database may use it for the tunnel too.

Types

type Config

type Config struct {
	User       string `json:"sshUser"`
	Host       string `json:"sshHost"`
	Port       string `json:"sshPort"`
	PrivateKey string `json:"sshPrivateKey"`
}

Config represents the configuration for an SSH tunnel.

func ParseInlineConfig

func ParseInlineConfig(data []byte) (*Config, error)

ParseInlineConfig parses the given data as a JSON object and returns a Config if the "useSSH" field is true.

func (Config) Validate

func (c Config) Validate() error

Validate checks if the Config is valid.

type Tunnel

type Tunnel interface {
	// Addr returns the address that the tunnel is listening on
	Addr() string
	// Host returns the host that the tunnel is listening on
	Host() string
	// Port returns the port that the tunnel is listening on
	Port() int
	// Close closes the tunnel
	Close() error
}

Tunnel is an ssh tunnel

func NewSocks5Tunnel

func NewSocks5Tunnel(c Config) (Tunnel, error)

NewSocks5Tunnel creates a new socks5 proxy using the ssh tunnel

func NewTcpTunnel

func NewTcpTunnel(c Config, remoteHost string, remotePort int) (Tunnel, error)

NewTcpTunnel creates a new ssh tunnel forwading tcp traffic

Jump to

Keyboard shortcuts

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