network

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateTestKeys

func GenerateTestKeys(hostKeyPath, clientKeyPath, authKeysPath string) error

GenerateTestKeys generates RSA keys for testing

Types

type Client

type Client interface {
	Connect(ctx context.Context, serverAddr string) error
	Disconnect() error
	IsConnected() bool
	Reconnect(ctx context.Context, serverAddr string) error
	SendMouseEvent(event *MouseEvent) error
	SendMouseBatch(events []*MouseEvent) error
}

Client defines the interface for network clients

type EventHandler

type EventHandler func(event *MouseEvent) error

EventHandler is a callback for handling mouse events

type MouseEvent

type MouseEvent struct {
	*waymonProto.MouseEvent
}

MouseEvent wraps the protobuf mouse event for internal use

type SSHClient

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

SSHClient handles SSH connections to the server

func NewSSHClient

func NewSSHClient(privateKeyPath string) *SSHClient

NewSSHClient creates a new SSH client

func (*SSHClient) Connect

func (c *SSHClient) Connect(ctx context.Context, serverAddr string) error

Connect establishes an SSH connection to the server

func (*SSHClient) Disconnect

func (c *SSHClient) Disconnect() error

Disconnect closes the SSH connection

func (*SSHClient) IsConnected

func (c *SSHClient) IsConnected() bool

IsConnected returns true if connected to the server

func (*SSHClient) OnInputEvent

func (c *SSHClient) OnInputEvent(callback func(*protocol.InputEvent))

OnInputEvent sets the callback for receiving input events from server

func (*SSHClient) Reconnect

func (c *SSHClient) Reconnect(ctx context.Context, serverAddr string) error

Reconnect attempts to reconnect to the server

func (*SSHClient) SendInputEvent

func (c *SSHClient) SendInputEvent(event *protocol.InputEvent) error

SendInputEvent sends an input event to the server

type SSHServer

type SSHServer struct {

	// Event handlers
	OnInputEvent         func(event *protocol.InputEvent)
	OnClientConnected    func(addr string, publicKey string)
	OnClientDisconnected func(addr string)
	OnAuthRequest        func(addr, publicKey, fingerprint string) bool // Returns approval
	// contains filtered or unexported fields
}

SSHServer handles incoming connections over SSH

func NewSSHServer

func NewSSHServer(port int, hostKeyPath, authKeysPath string) *SSHServer

NewSSHServer creates a new SSH-based server

func (*SSHServer) GetClientSessions

func (s *SSHServer) GetClientSessions() map[string]string

GetClientSessions returns a map of sessionID -> client address for connected clients

func (*SSHServer) IsSSHEnabled

func (s *SSHServer) IsSSHEnabled() bool

IsSSHEnabled returns true since this is an SSH server

func (*SSHServer) Port

func (s *SSHServer) Port() int

Port returns the server's port

func (*SSHServer) SendEventToClient

func (s *SSHServer) SendEventToClient(clientAddr string, event *protocol.InputEvent) error

SendEventToClient sends an input event to a specific client by address

func (*SSHServer) SendInputEventToAllClients

func (s *SSHServer) SendInputEventToAllClients(event *protocol.InputEvent) error

SendInputEventToAllClients sends an input event to all connected clients

func (*SSHServer) SendInputEventToClient

func (s *SSHServer) SendInputEventToClient(sessionID string, event *protocol.InputEvent) error

SendInputEventToClient sends an input event to a specific client

func (*SSHServer) SetAuthHandlers

func (s *SSHServer) SetAuthHandlers(onAuthRequest func(addr, publicKey, fingerprint string) bool)

SetAuthHandlers sets the authentication callback handlers

func (*SSHServer) SetMaxClients

func (s *SSHServer) SetMaxClients(max int)

SetMaxClients sets the maximum number of concurrent clients

func (*SSHServer) Start

func (s *SSHServer) Start(ctx context.Context) error

Start begins listening for SSH connections

func (*SSHServer) Stop

func (s *SSHServer) Stop()

Stop shuts down the SSH server

Jump to

Keyboard shortcuts

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