sshtunnel

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 14 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.

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