server

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2024 License: Apache-2.0 Imports: 19 Imported by: 3

Documentation

Index

Constants

View Source
const InboundRpcErrorTimeoutTime = 30 * time.Second
View Source
const MaxFileDataPacketSize = 16 * 1024
View Source
const MaxWriteFileContextData = 100
View Source
const WriteFileContextTimeout = 30 * time.Second

Variables

This section is empty.

Functions

func RunServer

func RunServer() (int, error)

Types

type MServer

type MServer struct {
	Lock                *sync.Mutex
	MainInput           *packet.PacketParser
	Sender              *packet.PacketSender
	ClientMap           map[base.CommandKey]*shexec.ClientProc
	Debug               bool
	WriteErrorCh        chan bool // closed if there is a I/O write error
	WriteErrorChOnce    *sync.Once
	Done                bool
	InboundRpcHandlers  map[string]RpcHandler
	InboundRpcErrorSent map[string]time.Time // limits the amount of error messages sent back to the client
}

TODO create unblockable packet-sender (backed by an array) for clientproc

func (*MServer) Close

func (m *MServer) Close()

func (*MServer) MakeShellStatePacket

func (m *MServer) MakeShellStatePacket(reqId string, shellType string, stdinDataCh chan []byte) (*packet.ShellStatePacketType, error)

func (*MServer) ProcessCommandPacket

func (m *MServer) ProcessCommandPacket(pk packet.CommandPacketType)

func (*MServer) ProcessRpcPacket

func (m *MServer) ProcessRpcPacket(pk packet.RpcPacketType)

type ReinitRpcHandler

type ReinitRpcHandler struct {
	ReqId       string
	TimeoutTime time.Time
	StdinDataCh chan []byte
}

func (*ReinitRpcHandler) DispatchPacket

func (rh *ReinitRpcHandler) DispatchPacket(reqId string, pkArg packet.RpcFollowUpPacketType)

func (*ReinitRpcHandler) GetTimeoutTime

func (rh *ReinitRpcHandler) GetTimeoutTime() time.Time

func (*ReinitRpcHandler) UnRegisterCallback

func (rh *ReinitRpcHandler) UnRegisterCallback()

type RpcHandler

type RpcHandler interface {
	GetTimeoutTime() time.Time
	DispatchPacket(reqId string, pk packet.RpcFollowUpPacketType)
	UnRegisterCallback()
}

type ShellStateMap

type ShellStateMap struct {
	Lock            *sync.Mutex
	StateMap        map[shellStateMapKey]*packet.ShellState // shelltype+hash -> state
	CurrentStateMap map[string]string                       // shelltype -> hash
}

func MakeShellStateMap

func MakeShellStateMap() *ShellStateMap

func (*ShellStateMap) Clear

func (sm *ShellStateMap) Clear()

func (*ShellStateMap) GetCurrentState

func (sm *ShellStateMap) GetCurrentState(shellType string) (string, *packet.ShellState)

func (*ShellStateMap) GetShells

func (sm *ShellStateMap) GetShells() []string

func (*ShellStateMap) GetStateByHash

func (sm *ShellStateMap) GetStateByHash(shellType string, hash string) *packet.ShellState

func (*ShellStateMap) HasShell

func (sm *ShellStateMap) HasShell(shellType string) bool

func (*ShellStateMap) SetCurrentState

func (sm *ShellStateMap) SetCurrentState(shellType string, state *packet.ShellState) error

type WriteFileContext

type WriteFileContext struct {
	CVar       *sync.Cond
	Data       []*packet.FileDataPacketType
	LastActive time.Time
	Err        error
	Done       bool
}

func (*WriteFileContext) DispatchPacket

func (wfc *WriteFileContext) DispatchPacket(reqId string, pkArg packet.RpcFollowUpPacketType)

func (*WriteFileContext) GetTimeoutTime

func (wfc *WriteFileContext) GetTimeoutTime() time.Time

func (*WriteFileContext) UnRegisterCallback

func (wfc *WriteFileContext) UnRegisterCallback()

Jump to

Keyboard shortcuts

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