commands_forward

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ForwardCmd = &cli.Command{
	Name:        "forward",
	Usage:       "Forward a connection via the agent service",
	Description: "Forward a local connection to a remote server via the agent service.",
	MaxArgs:     cli.NoArgs,
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:    "server",
			Aliases: []string{"s"},
			Usage:   "The address of the remote server to proxy through.",
			EnvVars: []string{config.CONFIG_ENV_PREFIX + "_SERVER"},
			Global:  true,
		},
		&cli.StringFlag{
			Name:    "token",
			Aliases: []string{"t"},
			Usage:   "The token to use for authentication.",
			EnvVars: []string{config.CONFIG_ENV_PREFIX + "_TOKEN"},
			Global:  true,
		},
		&cli.BoolFlag{
			Name:         "tls-skip-verify",
			Usage:        "Skip TLS verification when talking to server.",
			ConfigPath:   []string{"tls.skip_verify"},
			EnvVars:      []string{config.CONFIG_ENV_PREFIX + "_TLS_SKIP_VERIFY"},
			DefaultValue: true,
			Global:       true,
		},
		&cli.StringFlag{
			Name:         "alias",
			Aliases:      []string{"a"},
			Usage:        "The server alias to use.",
			DefaultValue: "default",
			Global:       true,
		},
	},
	Commands: []*cli.Command{
		SshCmd,
		PortCmd,
	},
}
View Source
var PortCmd = &cli.Command{
	Name:        "port",
	Usage:       "Forwards a port into a space",
	Description: `Forwards a local port to a remote container running the agent via the proxy server.`,
	Arguments: []cli.Argument{
		&cli.StringArg{
			Name:     "listen",
			Usage:    "The local port to listen on",
			Required: true,
		},
		&cli.StringArg{
			Name:     "space",
			Usage:    "The name of the space to connect to",
			Required: true,
		},
		&cli.StringArg{
			Name:     "port",
			Usage:    "The remote port to connect to",
			Required: false,
		},
	},
	MaxArgs: cli.NoArgs,
	Run: func(ctx context.Context, cmd *cli.Command) error {
		alias := cmd.GetString("alias")
		cfg := config.GetServerAddr(alias, cmd)

		port, err := strconv.Atoi(cmd.GetStringArg("port"))
		if err != nil || port < 1 || port > 65535 {
			return fmt.Errorf("Invalid port number, port numbers must be between 1 and 65535")
		}

		proxy.RunTCPForwarderViaAgent(cfg.WsServer, util.FixListenAddress(cmd.GetStringArg("listen")), cmd.GetStringArg("space"), port, cfg.ApiToken, cmd.GetBool("tls-skip-verify"))
		<-ctx.Done()
		return nil
	},
}
View Source
var SshCmd = &cli.Command{
	Name:        "ssh",
	Usage:       "Forward SSH to a space",
	Description: `Forwards a SSH connection to a container running the agent via the proxy server.`,
	Arguments: []cli.Argument{
		&cli.StringArg{
			Name:     "space",
			Usage:    "The name of the space to connect to",
			Required: true,
		},
	},
	MaxArgs: cli.NoArgs,
	Run: func(ctx context.Context, cmd *cli.Command) error {
		space := cmd.GetStringArg("space")
		alias := cmd.GetString("alias")
		cfg := config.GetServerAddr(alias, cmd)

		return proxy.RunSSHForwarderViaAgent(cfg.WsServer, space, cfg.ApiToken, cmd.GetBool("tls-skip-verify"))
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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