tunnel

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: GPL-3.0, LGPL-3.0 Imports: 15 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 tunnel manages the sshuttle profiles a site offers.

A profile says which networks to route, through which host, and what to keep off the tunnel. It replaces the per site shell scripts that carried the same arguments, and it resolves network names and the workstation's own address from the configuration instead of hard coding them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// Profiles are the configured tunnels.
	Profiles map[string]v1alpha1.TunnelSpec
	// Networks maps a network name to a CIDR.
	Networks map[string]string
	// Destination resolves a profile's remote, a role name or a host, and
	// the account it names, if any, to the [user@]host sshuttle connects
	// to. The account is resolved the way every other connection resolves
	// it, so that the context's account applies where nothing names one.
	Destination func(remote, user string) (string, error)
	// SSH returns the ssh command sshuttle runs, with the generated
	// configuration: the site's host key file, strict checking and the
	// role's jump hosts reach the tunnel only through it.
	SSH func() ([]string, error)
	// StateDir holds the process id files. It is an absolute path: sshuttle
	// changes to / once it runs in the background.
	StateDir string
	// Binary is the sshuttle to run.
	Binary string
	// Vars are the template values a profile may refer to, such as
	// {workstation.host}.
	Vars map[string]string
}

Manager starts, stops and reports on the tunnels of a site.

func (*Manager) Args

func (m *Manager) Args(name string) ([]string, error)

Args builds the sshuttle argument vector for a profile.

The options clusterctl decides come after the profile's own, because sshuttle keeps the last value it is given for an option: an option of the profile can neither replace the ssh command, and with it the site's host key checking, nor the process id file the tunnel is found by.

func (*Manager) Names

func (m *Manager) Names() []string

Names lists the configured profiles in sorted order.

func (*Manager) PIDFile

func (m *Manager) PIDFile(name string) string

PIDFile is where a running profile records its process id.

func (*Manager) Profile added in v0.3.0

func (m *Manager) Profile(name string) (v1alpha1.TunnelSpec, error)

Profile returns a configured profile. Every operation goes through here, so that a name, which also names the process id file, is never a path.

func (*Manager) Start

func (m *Manager) Start(ctx context.Context, name string) error

Start brings a profile up. Starting one that is already running is reported rather than producing a second tunnel for the same networks.

func (*Manager) Status

func (m *Manager) Status() []Status

Status reports every profile and whether it is running.

func (*Manager) Stop

func (m *Manager) Stop(ctx context.Context, name string) error

Stop brings a profile down. Only a configured profile is stopped, and only a process that is its tunnel is signalled.

type Status

type Status struct {
	Name        string `json:"name" yaml:"name"`
	Running     bool   `json:"running" yaml:"running"`
	PID         int    `json:"pid,omitempty" yaml:"pid,omitempty"`
	Remote      string `json:"remote" yaml:"remote"`
	Subnets     string `json:"subnets" yaml:"subnets"`
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
}

Status describes one profile.

Jump to

Keyboard shortcuts

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