commands

package
v0.0.0-...-5f133c6 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: BSD-3-Clause, BSD-3-Clause Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBackgroundFork

func IsBackgroundFork() bool

IsBackgroundFork returns true if this code is running in the background fork of enkit.

func IsValid

func IsValid(filename string) error

func NewAgentCommand

func NewAgentCommand(bf *client.BaseFlags) *cobra.Command

func NewListAgentCommand

func NewListAgentCommand(flags *AgentCommandFlags) *cobra.Command

func NewPrintCommand

func NewPrintCommand(parent *cobra.Command, flags *AgentCommandFlags) *cobra.Command

func NewRunAgentCommand

func NewRunAgentCommand(parent *cobra.Command, flags *AgentCommandFlags) *cobra.Command

func RunAgentCommand

func RunAgentCommand(command *cobra.Command, flags *AgentCommandFlags, args []string) error

Types

type AgentCommandFlags

type AgentCommandFlags struct {
	Base  *client.BaseFlags
	Agent *kcerts.SSHAgentFlags
}

type SSH

type SSH struct {
	*cobra.Command
	*client.BaseFlags
	AgentFlags *kcerts.SSHAgentFlags

	Tunnel     string
	Extra      string
	Subcommand string

	Proxy string

	ProxyMap         []proxyMapping
	BufferSize       int
	SSH              string
	UseInternalAgent bool
	// contains filtered or unexported fields
}

func NewSSH

func NewSSH(base *client.BaseFlags) *SSH

func (*SSH) Run

func (r *SSH) Run(cmd *cobra.Command, args []string) error

func (*SSH) Username

func (r *SSH) Username() string

type Tunnel

type Tunnel struct {
	*cobra.Command
	*client.BaseFlags

	Proxy      string
	BufferSize int

	TunnelFlags *ptunnel.Flags
	Listen      string
	Background  bool
	CheckAccess bool
}

func NewTunnel

func NewTunnel(base *client.BaseFlags) *Tunnel

func (*Tunnel) CanConnect

func (r *Tunnel) CanConnect(proxy *url.URL, id, host string, port uint16, cookie *http.Cookie) error

func (*Tunnel) NewTunnelOptions

func (r *Tunnel) NewTunnelOptions(id string, cookie *http.Cookie) []ptunnel.GetModifier

func (*Tunnel) OpenAndListen

func (r *Tunnel) OpenAndListen(ctx context.Context, proxy *url.URL, id, host string, port uint16, cookie *http.Cookie, network string, localAddr string) error

OpenAndListen will start listening with whatever mechanism has been configured via flags.

If background is disabled, it will simply open a listening socket, and wait for connections.

If background is enabled, it will: 0) Check if OpenAndListen is being called as a result of the fork()/exec() in step 2) below.

If it is, re-use the already opened file descriptor, and finally start listening. If it is not...

  1. Open a listening socket - which guarantees that when the parent process exits, the port is open.
  2. Fork and exec enkit again - with exactly the same flags and parameters, passing the listening socket as file descriptor number 3 (this is part of the ExtraFiles API in cmd.Exec). This hopefully will get us back in this function. A simple fork() would have been significantly simpler, but the behavior with threads is undefined and evil.

func (*Tunnel) Run

func (r *Tunnel) Run(cmd *cobra.Command, args []string) (err error)

func (*Tunnel) RunBackground

func (r *Tunnel) RunBackground(listener knetwork.FileListener) error

func (*Tunnel) RunListener

func (r *Tunnel) RunListener(ctx context.Context, listener net.Listener, proxy *url.URL, host string, port uint16, cookie *http.Cookie, localAddr string) error

func (*Tunnel) RunTunnel

func (r *Tunnel) RunTunnel(proxy *url.URL, id, host string, port uint16, cookie *http.Cookie, reader io.ReadCloser, writer io.WriteCloser) error

func (*Tunnel) Username

func (r *Tunnel) Username() string

Jump to

Keyboard shortcuts

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