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 ¶
- type Manager
- func (m *Manager) Args(name string) ([]string, error)
- func (m *Manager) Names() []string
- func (m *Manager) PIDFile(name string) string
- func (m *Manager) Profile(name string) (v1alpha1.TunnelSpec, error)
- func (m *Manager) Start(ctx context.Context, name string) error
- func (m *Manager) Status() []Status
- func (m *Manager) Stop(ctx context.Context, name string) error
- type Status
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 ¶
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) 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 ¶
Start brings a profile up. Starting one that is already running is reported rather than producing a second tunnel for the same networks.
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.