Documentation
¶
Overview ¶
Package netx opens the networks komando reaches targets through (docs/design/network.md). WireGuard and SOCKS run inside komando's own process, only for the connections that need them. Kinds that need an outside client (Tailscale, the openconnect family, OpenVPN) run as a background session that later commands reuse; most of them hand komando a local SOCKS port, so several VPNs work at once without touching the computer's routes. OpenVPN (OS mode) does change routes.
Index ¶
- Variables
- func Alive(pid int) bool
- func BuiltinSSL(kind string) bool
- func Clashes(before, after []Route) []string
- func Down(v *store.Vpn, err error) error
- func DownHint(v *store.Vpn) string
- func KindNames() []string
- func LiveSession(v *store.Vpn) *store.VpnSession
- func Lock(name string) (unlock func(), err error)
- func LoginRequired(v *store.Vpn) error
- func ReapIdle()
- func SSLVPNLogin(ctx context.Context, v *store.Vpn, ...) (string, error)
- func SecretHint(ref string) string
- func SessionAlive(s *store.VpnSession) bool
- func StopSession(s *store.VpnSession) error
- func StripWGKeys(text string) (clean, private, psk string, err error)
- func TailscaleDir(v *store.Vpn) string
- func TailscaleLogin(ctx context.Context, v *store.Vpn, show func(url string)) error
- func Terminate(pid int) error
- type Dialer
- type Kind
- type Route
- type WGConfig
- type WGPeer
Constants ¶
This section is empty.
Variables ¶
var ErrNeedsSudo = errors.New("the VPN runs as root and stopping it needs sudo")
ErrNeedsSudo means an OS-mode session runs as root and sudo wants a password; a person must run `komando vpn down` in a terminal.
var Kinds = map[string]Kind{ "wireguard": {Desc: "WireGuard, run inside komando (no admin rights, many at once)"}, "socks": {Desc: "a SOCKS5 proxy that is already running (`komando tunnel start HOST -D`, a company proxy)"}, "system": {Desc: "a VPN set up in your computer's settings (L2TP/IPsec, IKEv2, ...); --service lets `vpn up` connect it"}, "tailscale": {Desc: "Tailscale or Headscale, run inside komando (no tailscaled, no admin rights)", Session: true}, "globalprotect": {Desc: "Palo Alto GlobalProtect", Session: true, Client: []string{"openconnect", "ocproxy"}, Protocol: "gp"}, "fortinet": {Desc: "Fortinet SSL VPN (FortiClient)", Session: true, Client: []string{"openconnect", "ocproxy"}, Protocol: "fortinet"}, "anyconnect": {Desc: "Cisco AnyConnect / ocserv, run inside komando (no openconnect)", Session: true}, "pulse": {Desc: "Pulse Secure / Ivanti Connect Secure", Session: true, Client: []string{"openconnect", "ocproxy"}, Protocol: "pulse"}, "f5": {Desc: "F5 BIG-IP SSL VPN", Session: true, Client: []string{"openconnect", "ocproxy"}, Protocol: "f5"}, "openvpn": {Desc: "OpenVPN, also Pritunl profiles, run inside komando (no openvpn program, Docker or admin rights)", Session: true}, }
Kinds are the VPN kinds komando knows.
var SessionSecret string
SessionSecret is what a person gave for this session: a typed OpenVPN password, or the cookie of a VPN login done at the terminal. It reaches `komando vpn serve` on its stdin, never on a command line.
var StartSession func(ctx context.Context, name string) error
StartSession is set by the CLI: it brings up a session for a VPN that can connect without a human (no MFA). Open calls it on demand.
Functions ¶
func BuiltinSSL ¶
BuiltinSSL reports whether komando speaks the kind itself.
func Clashes ¶
Clashes compares the routes before and after a VPN connected. A new route that overlaps one another interface already had means two networks claim the same addresses: one of them will not be reachable.
func Down ¶
Down is the error for a VPN that cannot be used right now. The hint says what to do for its kind.
func LiveSession ¶
func LiveSession(v *store.Vpn) *store.VpnSession
LiveSession returns the VPN's background session if it is running and not idle for longer than the vpn_idle setting. An idle one is stopped.
func Lock ¶
Lock holds the per-VPN lock that starting and stopping a session take, so a stale stop can never hit a session another process just started.
func LoginRequired ¶
LoginRequired is the error for a VPN that needs a human to log in.
func ReapIdle ¶
func ReapIdle()
ReapIdle closes sessions unused for longer than vpn_idle. It runs at the start of every komando command, so sessions do not stay up forever.
func SSLVPNLogin ¶
func SSLVPNLogin(ctx context.Context, v *store.Vpn, prompt func(label string, secret bool) (string, error)) (string, error)
SSLVPNLogin logs in at the terminal and returns the session cookie.
func SecretHint ¶
SecretHint says how to provide a secret reference that does not resolve.
func SessionAlive ¶
func SessionAlive(s *store.VpnSession) bool
SessionAlive reports whether a session's process or container runs.
func StopSession ¶
func StopSession(s *store.VpnSession) error
StopSession ends a session's process or container (through sudo for OS-mode ones). A session that is no longer running is already stopped. It reports an error when it could not stop it; the caller keeps the session then.
func StripWGKeys ¶
StripWGKeys removes PrivateKey and PresharedKey lines from a wg-quick file, returning the rest and the keys, so only the vault holds them. komando supports one preshared key per VPN.
func TailscaleDir ¶
TailscaleDir is where the VPN's node keys and state are kept.
func TailscaleLogin ¶
TailscaleLogin logs the node in through the browser: show gets the login page. It returns once the node is connected; its state is kept, so later sessions start without a login until the key expires.
Types ¶
type Dialer ¶
Dialer opens a TCP connection through a network.
func Open ¶
Open starts v (or reuses its background session) and returns a dialer through it. Close the closer when done.
type Kind ¶
type Kind struct {
Desc string
Session bool
Client []string
Protocol string // openconnect --protocol
}
Kind describes a VPN kind. Session kinds run a client in the background (`komando vpn up`), reused by later commands; Client names the program that must be installed for it.