chclient

package
v0.0.0-...-391d5ce Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WatchdogStateReconnecting = "reconnecting"
	WatchdogStateConnected    = "connected"
	WatchdogStateInit         = "initialized"
)
View Source
const AuthTimeout = 30 * time.Second
View Source
const BackoffOnServerTimeoutMaxDuration = 1 * time.Second
View Source
const DefaultDataDir = "/var/lib/rport"
View Source
const DefaultMonitoringInterval = 60 * time.Second
View Source
const DialTimeout = 5 * 60 * time.Second
View Source
const InitialConnectionRequestSendDelayJitterMilliseconds = 10000
View Source
const MaxConnectionBackoffWaitTime = 10 * 60 * time.Second
View Source
const MaxKeepAliveJitterMilliseconds = 5000
View Source
const MinConnectionBackoffWaitTime = 5 * time.Second
View Source
const MinSendRequestRetryWaitTime = 1 * time.Second
View Source
const SendRequestTimeout = 30 * time.Second
View Source
const ServerReconnectRequestBackoffTime = 3 * 60 * time.Second

Variables

View Source
var FileReceptionGlobs = []string{
	"/bin", "/sbin", "/boot", "/usr/bin", "/usr/sbin", "/dev", "/lib*", "/run",
}

Functions

func ConnectionErrorHints

func ConnectionErrorHints(server string, logger *logger.Logger, err error) error

func DetectTransparentProxy

func DetectTransparentProxy(serverURL string) (proxy string, allHeaders string, error error)

func ParseTunnelAllowed

func ParseTunnelAllowed(input string) (*net.IPNet, string, error)

func PrepareDirs

func PrepareDirs(c *ClientConfigHolder) error

func TunnelIsAllowed

func TunnelIsAllowed(tunnelAllowed []string, remote string) (bool, error)

Types

type CapacityBuffer

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

func (*CapacityBuffer) Bytes

func (b *CapacityBuffer) Bytes() []byte

func (*CapacityBuffer) GetOverflowMessage

func (b *CapacityBuffer) GetOverflowMessage() string

func (*CapacityBuffer) HasOverflow

func (b *CapacityBuffer) HasOverflow() bool

func (*CapacityBuffer) String

func (b *CapacityBuffer) String() string

func (*CapacityBuffer) Write

func (b *CapacityBuffer) Write(p []byte) (n int, err error)

type Client

type Client struct {
	*logger.Logger

	SessionID string
	// contains filtered or unexported fields
}

Client represents a client instance

func NewClient

func NewClient(config *ClientConfigHolder, filesAPI files.FileAPI) (*Client, error)

NewClient creates a new client instance

func (*Client) Close

func (c *Client) Close() error

Close manually stops the client

func (*Client) CloseConnection

func (c *Client) CloseConnection() error

func (*Client) HandleRunCmdRequest

func (c *Client) HandleRunCmdRequest(ctx context.Context, reqPayload []byte) (*comm.RunCmdResponse, error)

func (*Client) Run

func (c *Client) Run(ctx context.Context) (err error)

Run starts client and blocks while connected

func (*Client) Start

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

Start client and do not block

func (*Client) ToUTF8

func (c *Client) ToUTF8(b []byte, decoder *encoding.Decoder) string

func (*Client) Wait

func (c *Client) Wait(ctx context.Context) (err error)

Wait blocks while the client is running. Can only be called once.

type ClientConfigHolder

type ClientConfigHolder struct {
	*clientconfig.Config
}

func (*ClientConfigHolder) GetProtectedUploadDirs

func (c *ClientConfigHolder) GetProtectedUploadDirs() []string

func (*ClientConfigHolder) GetScriptsDir

func (c *ClientConfigHolder) GetScriptsDir() string

func (*ClientConfigHolder) GetUploadDir

func (c *ClientConfigHolder) GetUploadDir() string

func (*ClientConfigHolder) IsFileReceptionEnabled

func (c *ClientConfigHolder) IsFileReceptionEnabled() bool

func (*ClientConfigHolder) ParseAndValidate

func (c *ClientConfigHolder) ParseAndValidate(skipScriptsDirValidation bool) error

func (*ClientConfigHolder) ParseAndValidateConnection

func (c *ClientConfigHolder) ParseAndValidateConnection() error

func (*ClientConfigHolder) ParseAndValidateFilePushConfig

func (c *ClientConfigHolder) ParseAndValidateFilePushConfig() error

func (*ClientConfigHolder) ParseAndValidateMonitoring

func (c *ClientConfigHolder) ParseAndValidateMonitoring() error

type LimitedWriter

type LimitedWriter struct {
	io.Writer
	Decoder *encoding.Decoder
	Limit   int
}

func (*LimitedWriter) Write

func (w *LimitedWriter) Write(p []byte) (int, error)

type OptionsProvider

type OptionsProvider interface {
	GetUploadDir() string
	GetProtectedUploadDirs() []string
	IsFileReceptionEnabled() bool
}

type SSHFileProvider

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

func (SSHFileProvider) Open

func (sfp SSHFileProvider) Open(path string) (io.ReadCloser, error)

type SftpSession

type SftpSession struct {
	RemoteFile io.ReadCloser
	SftpCl     *sftp.Client
}

func (*SftpSession) Close

func (ss *SftpSession) Close() error

func (*SftpSession) Read

func (ss *SftpSession) Read(p []byte) (n int, err error)

type SourceFileProvider

type SourceFileProvider interface {
	Open(path string) (io.ReadCloser, error)
}

type SummaryBuffer

type SummaryBuffer struct {
	io.Writer
	// contains filtered or unexported fields
}

SummaryBuffer extracts everything between <summary> and </summary> from io.Writer stream

func NewSummaryBuffer

func NewSummaryBuffer() *SummaryBuffer

func (*SummaryBuffer) GetSummary

func (s *SummaryBuffer) GetSummary() []byte

func (*SummaryBuffer) Stop

func (s *SummaryBuffer) Stop()

Stop closes and waits for writing to finish

type UploadManager

type UploadManager struct {
	*logger.Logger
	FilesAPI           files.FileAPI
	OptionsProvider    OptionsProvider
	SourceFileProvider SourceFileProvider
	SysUserLookup      system.SysUserLookup
}

func NewSSHUploadManager

func NewSSHUploadManager(
	l *logger.Logger,
	filesAPI files.FileAPI,
	optionsProvider OptionsProvider,
	sshConn ssh.Conn,
	sysUserLookup system.SysUserLookup,
) *UploadManager

func (*UploadManager) HandleUploadRequest

func (um *UploadManager) HandleUploadRequest(reqPayload []byte) (*models.UploadResponse, error)

type Watchdog

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

func NewWatchdog

func NewWatchdog(enabled bool, dataDir string, logger *logger.Logger) (*Watchdog, error)

func (*Watchdog) Close

func (w *Watchdog) Close() error

func (*Watchdog) Ping

func (w *Watchdog) Ping(state string, msg string)

Directories

Path Synopsis
fs

Jump to

Keyboard shortcuts

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