agent

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 20 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	ID          string
	DeviceName  string
	ServerURL   string
	SecurityKey string
	Sessions    map[string]*Session
	Conn        *jsonrpc2.Conn
	// contains filtered or unexported fields
}

Agent represents the agent that connects to the server.

func New

func New(id, deviceName, serverURL string) *Agent

New creates a new Agent instance.

func NewWithSecurityKey

func NewWithSecurityKey(id, deviceName, serverURL, securityKey string) *Agent

NewWithSecurityKey creates a new Agent instance with authentication.

func (*Agent) AddSession

func (a *Agent) AddSession(session *Session)

AddSession adds a session to the agent.

func (*Agent) Connect

func (a *Agent) Connect() error

Connect establishes connection with the server.

func (*Agent) GetSession

func (a *Agent) GetSession(sessionID string) (*Session, bool)

GetSession returns a session by ID.

func (*Agent) RemoveSession

func (a *Agent) RemoveSession(sessionID string)

RemoveSession removes a session from the agent.

func (*Agent) Run

func (a *Agent) Run()

Run starts the agent with automatic reconnection using exponential backoff.

type Handler

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

Handler implements jsonrpc2.Handler to process server commands.

func NewHandler

func NewHandler(agent *Agent) *Handler

NewHandler creates a new handler for the agent.

func (*Handler) Handle

func (h *Handler) Handle(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request)

type Session

type Session struct {
	ID   string
	Pty  *os.File
	Cmd  *exec.Cmd
	Done chan struct{}
	// contains filtered or unexported fields
}

Session representa uma sessão ativa de shell.

func NewSession

func NewSession(id string, pty *os.File, cmd *exec.Cmd) *Session

NewSession cria uma nova sessão.

func (*Session) Close

func (s *Session) Close()

Close encerra a sessão.

func (*Session) Write

func (s *Session) Write(data []byte) error

Write escreve dados no PTY.

Jump to

Keyboard shortcuts

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