web

package
v0.35.5 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package web provides web interface and proxy capabilities for Prism

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeTerminalHTML

func ServeTerminalHTML(w http.ResponseWriter, r *http.Request)

ServeTerminalHTML serves the terminal HTML interface

Types

type AuthFunc

type AuthFunc func(r *http.Request) (bool, string) // returns (authorized, username)

AuthFunc is a function that validates authentication for a request

type ConnectData

type ConnectData struct {
	InstanceID string `json:"instance_id"`
	Host       string `json:"host"`
	Port       int    `json:"port"`
	Username   string `json:"username"`
}

ConnectData contains connection parameters

type DashboardServer

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

DashboardServer provides a web dashboard for Prism

func NewDashboardServer

func NewDashboardServer(
	instanceFunc func() ([]*types.Instance, error),
	templateFunc func() (map[string]types.RuntimeTemplate, error),
	proxyManager *ProxyManager,
) *DashboardServer

NewDashboardServer creates a new dashboard server

func (*DashboardServer) ServeHTTP

func (ds *DashboardServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler

type InputData

type InputData struct {
	Data string `json:"data"`
}

InputData contains terminal input

type InstanceProxy

type InstanceProxy struct {
	InstanceID   string
	InstanceName string
	TargetURL    *url.URL
	Proxy        *httputil.ReverseProxy
	Created      time.Time
	LastAccessed time.Time
	AccessCount  int64
}

InstanceProxy represents a proxy to an instance's web service

type LocalTerminal

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

LocalTerminal provides local terminal execution (for development)

func NewLocalTerminal

func NewLocalTerminal() (*LocalTerminal, error)

NewLocalTerminal creates a new local terminal

func (*LocalTerminal) Close

func (lt *LocalTerminal) Close() error

Close terminates the terminal

func (*LocalTerminal) Read

func (lt *LocalTerminal) Read(p []byte) (int, error)

Read reads output from the terminal

func (*LocalTerminal) Write

func (lt *LocalTerminal) Write(data []byte) (int, error)

Write sends input to the terminal

type OutputData

type OutputData struct {
	Data string `json:"data"`
}

OutputData contains terminal output

type ProxyManager

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

ProxyManager manages web proxies for instance services

func NewProxyManager

func NewProxyManager(authFunc AuthFunc) *ProxyManager

NewProxyManager creates a new proxy manager

func (*ProxyManager) GetProxyStats

func (pm *ProxyManager) GetProxyStats() map[string]ProxyStats

GetProxyStats returns statistics for all proxies

func (*ProxyManager) RegisterInstance

func (pm *ProxyManager) RegisterInstance(instance *types.Instance) error

RegisterInstance registers a new instance for proxying

func (*ProxyManager) ServeHTTP

func (pm *ProxyManager) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler for the proxy manager

func (*ProxyManager) UnregisterInstance

func (pm *ProxyManager) UnregisterInstance(instanceID string) error

UnregisterInstance removes an instance from proxying

type ProxyStats

type ProxyStats struct {
	InstanceID   string    `json:"instance_id"`
	InstanceName string    `json:"instance_name"`
	TargetURL    string    `json:"target_url"`
	Created      time.Time `json:"created"`
	LastAccessed time.Time `json:"last_accessed"`
	AccessCount  int64     `json:"access_count"`
}

ProxyStats contains statistics for a proxy

type ResizeData

type ResizeData struct {
	Cols int `json:"cols"`
	Rows int `json:"rows"`
}

ResizeData contains terminal resize parameters

type TerminalMessage

type TerminalMessage struct {
	Type string          `json:"type"` // connect, resize, input, output, error, close
	Data json.RawMessage `json:"data"`
}

TerminalMessage represents a message between client and server

type TerminalServer

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

TerminalServer provides web-based terminal access to instances

func NewTerminalServer

func NewTerminalServer(sshConfig *ssh.ClientConfig) *TerminalServer

NewTerminalServer creates a new terminal server

func (*TerminalServer) ServeHTTP

func (ts *TerminalServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles terminal WebSocket connections

type TerminalSession

type TerminalSession struct {
	ID         string
	InstanceID string
	SSHClient  *ssh.Client
	Session    *ssh.Session
	StdinPipe  io.WriteCloser
	StdoutPipe io.Reader
	StderrPipe io.Reader
	Connected  bool
}

TerminalSession represents an active terminal session

type WebSocketProxy

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

WebSocketProxy handles WebSocket proxying for instances

func NewWebSocketProxy

func NewWebSocketProxy(targetURL string) (*WebSocketProxy, error)

NewWebSocketProxy creates a new WebSocket proxy

func (*WebSocketProxy) ServeHTTP

func (wp *WebSocketProxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles WebSocket proxy requests using gorilla/websocket

func (*WebSocketProxy) ServeHTTPOld

func (wp *WebSocketProxy) ServeHTTPOld(w http.ResponseWriter, r *http.Request)

ServeHTTPOld handles WebSocket proxy requests (old hijacking implementation)

type WebSocketUpgrader

type WebSocketUpgrader struct {
	CheckOrigin func(r *http.Request) bool
}

WebSocketUpgrader handles WebSocket upgrade

Jump to

Keyboard shortcuts

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