webterminal

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 25 Imported by: 0 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

Overview

Package webterminal 实现 Web 终端:通过 WebSocket 在浏览器中使用 SSH 或本机 Shell。

SSH 主机密钥采用"首次信任":第一次连接时记录指纹,之后指纹变化会拒绝连接,防止中间人攻击。 本机 Shell 等同于服务器的完全控制权,默认关闭,需要在模块设置中显式开启。

Index

Constants

View Source
const (
	TypeSSH   = "ssh"
	TypeLocal = "local"
)

连接类型

View Source
const ID = "webterminal"

ID 是模块标识。

Variables

This section is empty.

Functions

func Fingerprint

func Fingerprint(k ssh.PublicKey) string

Fingerprint 返回主机密钥的 SHA256 指纹(与 ssh-keygen -lf 输出格式一致)。

Types

type Connection

type Connection struct {
	Key    string      `json:"key"`
	Name   string      `json:"name"`
	Type   string      `json:"type"`
	SSH    SSHConfig   `json:"ssh"`
	Local  LocalConfig `json:"local"`
	Remark string      `json:"remark"`
	// Enable 为复用通用接口保留,终端连接始终可用
	Enable bool `json:"enable"`
}

Connection 是一个终端连接配置。

func (*Connection) Validate

func (c *Connection) Validate() error

Validate 校验连接配置。

type LocalConfig

type LocalConfig struct {
	Shell   string `json:"shell"`
	WorkDir string `json:"workDir"`
}

LocalConfig 是本机 Shell 参数。

type Module

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

Module 是 Web 终端模块。

func New

func New() *Module

New 创建模块。

func (*Module) ID

func (m *Module) ID() string

ID 实现 module.Module。

func (*Module) ImportLucky

func (m *Module) ImportLucky(doc luckyimport.Document, dryRun bool) (*luckyimport.Report, error)

ImportLucky 实现 luckyimport.Importer。

func (*Module) Init

func (m *Module) Init(env module.Env) error

Init 实现 module.Module。

func (*Module) Routes

func (m *Module) Routes(r module.Router)

Routes 实现 module.Module。

func (*Module) Start

func (m *Module) Start(context.Context) error

Start 实现 module.Module。

func (*Module) Stop

func (m *Module) Stop() error

Stop 实现 module.Module。

func (*Module) Title

func (m *Module) Title() string

Title 实现 module.Module。

type SSHConfig

type SSHConfig struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	Username string `json:"username"`
	// AuthType 为 password 或 key
	AuthType   string `json:"authType"`
	Password   string `json:"password"`
	PrivateKey string `json:"privateKey"`
	Passphrase string `json:"passphrase"`
	// HostKey 为首次连接时记录的主机密钥指纹(SHA256),为空表示下次连接时重新信任
	HostKey string `json:"hostKey"`
	// KeepAlive 为保活间隔(秒)
	KeepAlive int `json:"keepAlive"`
}

SSHConfig 是 SSH 连接参数。

type Settings

type Settings struct {
	// AllowLocalShell 允许打开本机 Shell
	AllowLocalShell bool `json:"allowLocalShell"`
	MaxSessions     int  `json:"maxSessions"`
}

Settings 是模块级配置。

Jump to

Keyboard shortcuts

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