grpcp

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 24 Imported by: 0

README

grpcp

Description

This is a simple tool to copy files between local and remote hosts using gRPC stream.

Usage

Usage: grpcp [<src> [<dest>]] [flags]

Arguments:
  [<src>]
  [<dest>]

Flags:
  -h, --help                Show context-sensitive help.
  -h, --host="localhost"    host name
  -p, --port=8022           port number
  -q, --quiet               quiet mode
  -d, --debug               enable debug log
      --[no-]tls            enable TLS (default: true)
  -s, --server              run as server
      --cert=STRING         certificate file for server
      --key=STRING          private key file for server
      --verify              TLS verification for client
      --kill                send shutdown command to server
      --ping                send ping message to server

Start the server on the remote host:

$ grpcp --server

Copy a file from the remote host to the local host:

$ grpcp remote_host:/path/to/file /path/to/destination

Copy a file from the local host to the remote host:

$ grpcp /path/to/file remote_host:/path/to/destination

grpcp does not support copying directories, local to local, or remote to remote.

TLS Configuration

grpcp enables TLS with self-signed certificate by default. If you want to use your own certificate, you can specify the certificate and private key files:

$ grpcp --server --cert server.crt --key server.key

grpcp client does not verify the server certificate by default. If you want to verify the server certificate, you can specify the --verify flag:

$ grpcp --verify remote_host:/path/to/file /path/to/destination

LICENSE

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LogLevel = new(slog.LevelVar)
View Source
var (
	StreamBufferSize = 1024 * 1024
)

Functions

func RunCLI

func RunCLI(ctx context.Context) error

func RunServer

func RunServer(ctx context.Context, opt *ServerOption) error

Types

type CLI

type CLI struct {
	Host string `name:"host" short:"h" default:"localhost" help:"host name"`
	Port int    `name:"port" short:"p" default:"8022" help:"port number"`

	Quiet bool `name:"quiet" short:"q" help:"quiet mode"`
	Debug bool `name:"debug" short:"d" help:"enable debug log"`
	TLS   bool `name:"tls" negatable:"" default:"true" help:"enable TLS (default: true)"`

	Server bool   `name:"server" short:"s" help:"run as server"`
	Cert   string `name:"cert" help:"certificate file for server" type:"existingfile"`
	Key    string `name:"key" help:"private key file for server" type:"existingfile"`

	VerifyTLSCert bool `name:"verify-tls-cert" default:"false" help:"TLS verification for client"`
	Kill          bool `name:"kill" help:"send shutdown command to server"`
	Ping          bool `name:"ping" help:"send ping message to server"`

	Src  string `arg:"" optional:"" name:"src" short:"s" description:"source file path"`
	Dest string `arg:"" optional:"" name:"dest" short:"d" description:"destination file path"`
}

func (*CLI) ClientOption added in v0.1.0

func (c *CLI) ClientOption() *ClientOption

func (*CLI) ServerOption added in v0.1.0

func (c *CLI) ServerOption() *ServerOption

type Client

type Client struct {
	Option *ClientOption
}

func NewClient

func NewClient(opt *ClientOption) *Client

func (*Client) Copy

func (c *Client) Copy(ctx context.Context, src, dest string) error

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) (*pb.PingResponse, error)

func (*Client) Shutdown added in v0.0.5

func (c *Client) Shutdown(ctx context.Context) error

type ClientOption

type ClientOption struct {
	Host       string `json:"host"`
	Port       int    `json:"port"`
	Quiet      bool   `json:"quiet"`
	TLS        bool   `json:"tls"`
	SkipVerify bool   `json:"skip_verify"`
}

type ServerOption

type ServerOption struct {
	Port     int    `json:"port"`
	Listen   string `json:"listen"`
	TLS      bool   `json:"tls"`
	CertFile string `json:"cert_file"`
	KeyFile  string `json:"key_file"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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