rsh

package module
v0.0.0-...-f858fe5 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: MIT Imports: 20 Imported by: 0

README

Remote shell over gRPC

Like ssh or kubectl exec, but over gRPC.

This library contains code to run remote commands using the gRPC framework. Apart from the library, client and server CLIs are included.

Features:

  • Execute shell commands or spawn an interactive shell on the server.
  • Interactive PTY sessions are used to run the commands.
  • Client is able to exit using the exit code of the remote command.

Usage

You'll need to have go > 1.18 installed.

  1. Create the server

    go run ./cmd/server
    
  2. Run the client

    # Spawn interactive shell
    go run ./cmd/client
    
    # Run command
    go run ./cmd/client -- ping 1.1.1.1 -c 3
    

Server and client use 127.0.0.1:22222 for the connections by default.

Building

To compile server and client binaries, run:

make

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the remote shell client.

func NewClientInsecure

func NewClientInsecure(server string) *Client

NewClientInsecure creates an insecure client.

func (*Client) Exec

func (c *Client) Exec(opts *ExecOptions) (*int, error)

Exec executes a command in the server.

func (*Client) ExecContext

func (c *Client) ExecContext(ctx context.Context, opts *ExecOptions) (*int, error)

ExecContext is like Exec, but with context.

type ExecOptions

type ExecOptions struct {
	Command string
	Args    []string
}

ExecOptions are the options for Exec.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the remote shell server.

func NewServer

func NewServer(address string, shell string) *Server

NewServer creates a new remote shell server.

func (*Server) Serve

func (s *Server) Serve() error

Serve starts the server.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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