session

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

adapter.go bridges the WebShell model (Session + host Executor) to the core.Session contract, so a WebShell foothold gets the same Exec/upload/ download surface as SSH and every downstream kit works against it unchanged.

Package session defines an already-established WebShell session and the host-provided executor. This module intentionally ships no default executor: the host must implement the actual command/file operation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CapabilitySession

type CapabilitySession struct {
	Shell    Session
	Executor Executor
}

CapabilitySession wraps a WebShell Session plus its host Executor into a core.Session.

func (*CapabilitySession) Close

func (c *CapabilitySession) Close() error

Close is a no-op: a WebShell has no connection to tear down.

func (*CapabilitySession) Download

func (c *CapabilitySession) Download(ctx context.Context, remote string) (io.ReadCloser, error)

Download reads a remote path through the WebShell file channel.

func (*CapabilitySession) Exec

func (c *CapabilitySession) Exec(ctx context.Context, cmd string, opts core.ExecOpts) (core.Output, error)

Exec runs a command through the WebShell executor.

func (*CapabilitySession) Info

Info describes the foothold without performing I/O.

func (*CapabilitySession) Upload

func (c *CapabilitySession) Upload(ctx context.Context, src io.Reader, remote string) error

Upload writes bytes to the remote path via the WebShell file channel.

type ExecResult

type ExecResult struct {
	Output     string
	HTTPStatus int
	TrafficID  string
	// Encoding declares how Output carries a file body on File reads: "base64"
	// when Output is base64 of the file, anything else (including "") when it is
	// the file itself. The adapter does not guess, because a plain-text body such
	// as "abcdefgh" is also a legal base64 string and sniffing it would silently
	// return 6 bytes of garbage instead of the file.
	Encoding string
}

type Executor

type Executor interface {
	Exec(ctx context.Context, session Session, command string) (*ExecResult, error)
	File(ctx context.Context, session Session, op FileOp) (*ExecResult, error)
}

Executor is the host boundary for command/file operations. Implementations must enforce scope, approval and evidence in the host.

type FileOp

type FileOp struct {
	Action  string // read | list | write | upload | download | delete
	Path    string
	Content []byte
}

type Session

type Session struct {
	ID           int64
	ProjectID    int64
	URL          string
	ShellType    string
	Method       string
	CmdParam     string
	PassParam    string
	Protocol     string
	ParamChannel string
	Encoding     string
	ProxyURL     string
	Password     string
}

Session is a registered, ready-to-use WebShell. Password handling (sealing, storage) belongs to the host.

Jump to

Keyboard shortcuts

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