streamer

package
v1.0.55 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 13 Imported by: 1

Documentation

Overview

Package streamer describes interface for interaction on network level.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSupported = errors.New("not supported")

Functions

func CloserCTX

func CloserCTX(ctx context.Context, fn func()) context.CancelFunc

CloserCTX calls fn if ctx is cancelled. Returns cancel function.

func GetLastBytes

func GetLastBytes(data []byte, last int) []byte

func NetReader

func NetReader(ctx context.Context, buff chan []byte, conn net.Conn, logger *zap.Logger) error

NetReader reads data from connection and put it into channel

func NewTimerWithDefault

func NewTimerWithDefault(duration time.Duration) *time.Timer

func StopTimer

func StopTimer(timer *time.Timer)

func TCPDialCtx

func TCPDialCtx(ctx context.Context, network, addr string) (net.Conn, error)

TCPDialCtx net.Dial version with context arg

func ThrowCmdTimeoutException

func ThrowCmdTimeoutException(lastRead []byte) error

func ThrowEOFException

func ThrowEOFException(lastRead []byte) error

func ThrowReadTimeoutException

func ThrowReadTimeoutException(lastRead []byte) error

Types

type Chmod

type Chmod struct {
	UID int
	GID int
}

type CmdTimeoutException

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

func (*CmdTimeoutException) Error

func (e *CmdTimeoutException) Error() string

type Connector

type Connector interface {
	Init(context.Context) error
	GetCredentials() credentials.Credentials
	SetCredentialsInterceptor(func(credentials.Credentials) credentials.Credentials)
	SetTrace(trace.CB)
	SetReadTimeout(time.Duration) time.Duration
	Close()
	ReadTo(context.Context, expr.Expr) (ReadRes, error)
	Read(ctx context.Context, n int) ([]byte, error)
	Cmd(ctx context.Context, cmd string) (cmd.CmdRes, error)
	Write([]byte) error
	HasFeature(Const) bool
	Download(paths []string, recurse bool) (map[string]File, error)
	Upload(map[string]File) error
	InitAgentForward() error
}

type Const

type Const int
const (
	AutoLogin Const = iota
	Cmd
)

type EOFException

type EOFException struct {
	LastRead []byte
}

func (*EOFException) Error

func (m *EOFException) Error() string

func (*EOFException) Is

func (m *EOFException) Is(target error) bool

type File

type File struct {
	Data  []byte
	Mode  *os.FileMode
	Chmod *Chmod
	Err   error
}

func NewFile

func NewFile(data []byte, fileMode *os.FileMode, chmod *Chmod) File

func NewFileData

func NewFileData(data []byte) File

func NewFileError

func NewFileError(err error) File

type ReadRes

type ReadRes interface {
	GetBefore() []byte
	GetAfter() []byte
	GetMatchedGroups() map[string][]byte
	GetMatched() []byte
	GetPatternNo() int
	GetUnderlyingRes() ReadRes // may be nil
}

type ReadResImpl

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

func NewReadResImpl

func NewReadResImpl(before, after []byte, matchedGroups map[string][]byte, matched []byte, patternNo int) ReadResImpl

func NewReadResImplWithUnder added in v1.0.7

func NewReadResImplWithUnder(before, after []byte, matchedGroups map[string][]byte, matched []byte, patternNo int, underlying ReadRes) ReadResImpl

func (ReadResImpl) GetAfter

func (m ReadResImpl) GetAfter() []byte

func (ReadResImpl) GetBefore

func (m ReadResImpl) GetBefore() []byte

func (ReadResImpl) GetMatched

func (m ReadResImpl) GetMatched() []byte

func (ReadResImpl) GetMatchedGroups

func (m ReadResImpl) GetMatchedGroups() map[string][]byte

func (ReadResImpl) GetPatternNo

func (m ReadResImpl) GetPatternNo() int

func (ReadResImpl) GetUnderlyingRes added in v1.0.7

func (m ReadResImpl) GetUnderlyingRes() ReadRes

type ReadTimeoutException

type ReadTimeoutException struct {
	LastRead []byte
}

func (*ReadTimeoutException) Error

func (m *ReadTimeoutException) Error() string

func (*ReadTimeoutException) Is

func (m *ReadTimeoutException) Is(target error) bool

type ReadXRes

type ReadXRes struct {
	RetType   ReadXType
	ExprRes   ReadRes
	BytesRes  []byte
	ExprAfter []byte
}

func GenericReadX

func GenericReadX(ctx context.Context, inBuffer []byte, readCh chan []byte, readSize int, readTimeout time.Duration,
	regExpr expr.Expr, maxReadSize int, maxDuration time.Duration) (*ReadXRes, []byte, []byte, error)

GenericReadX reads from readCh till expr matched, exceeded time or read more than size. Returns error if nothing was read during readTimeout or ctx was Done readSize - maximum read size maxDuration - maximum time for reading regExpr - read till regex match Returns read res, left bytes, read bytes, error

func NewReadXRes

func NewReadXRes(retType ReadXType, bytesRes []byte, exprRes ReadRes, after []byte) *ReadXRes

type ReadXType

type ReadXType int64
const (
	Size ReadXType = iota
	Expr
	Timeout
	EOF
)

func (ReadXType) String added in v1.0.8

func (m ReadXType) String() string

Directories

Path Synopsis
https://www.rfc-editor.org/rfc/rfc2217.html
https://www.rfc-editor.org/rfc/rfc2217.html
Package ssh implements SSH transport.
Package ssh implements SSH transport.
Package telnet implements telnet transport at very basic level.
Package telnet implements telnet transport at very basic level.

Jump to

Keyboard shortcuts

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