111
All checks were successful
Build Multi-Platform Binaries / build-frontend (push) Successful in 29s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Successful in 48s
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Successful in 37s
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Successful in 59s
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Successful in 36s
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Successful in 57s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Successful in 38s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Successful in 1m6s
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Successful in 50s
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Successful in 35s
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Successful in 1m0s
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Successful in 52s
All checks were successful
Build Multi-Platform Binaries / build-frontend (push) Successful in 29s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Successful in 48s
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Successful in 37s
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Successful in 59s
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Successful in 36s
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Successful in 57s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Successful in 38s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Successful in 1m6s
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Successful in 50s
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Successful in 35s
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Successful in 1m0s
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Successful in 52s
This commit is contained in:
@@ -45,6 +45,12 @@ type ConfigField struct {
|
||||
Description string `json:"description,omitempty"` // 字段描述
|
||||
}
|
||||
|
||||
// RuleSchema 规则表单模式定义
|
||||
type RuleSchema struct {
|
||||
NeedsLocalAddr bool `json:"needs_local_addr"` // 是否需要本地地址
|
||||
ExtraFields []ConfigField `json:"extra_fields,omitempty"` // 额外字段
|
||||
}
|
||||
|
||||
// PluginMetadata 描述一个 plugin
|
||||
type PluginMetadata struct {
|
||||
Name string `json:"name"` // 唯一标识符 (如 "socks5")
|
||||
@@ -57,7 +63,8 @@ type PluginMetadata struct {
|
||||
Checksum string `json:"checksum,omitempty"` // WASM 二进制的 SHA256
|
||||
Size int64 `json:"size,omitempty"` // WASM 二进制大小
|
||||
Capabilities []string `json:"capabilities,omitempty"` // 所需 host functions
|
||||
ConfigSchema []ConfigField `json:"config_schema,omitempty"`// 配置模式定义
|
||||
ConfigSchema []ConfigField `json:"config_schema,omitempty"`// 插件配置模式
|
||||
RuleSchema *RuleSchema `json:"rule_schema,omitempty"` // 规则表单模式
|
||||
}
|
||||
|
||||
// PluginInfo 组合元数据和运行时状态
|
||||
@@ -90,6 +97,15 @@ type ProxyHandler interface {
|
||||
Close() error
|
||||
}
|
||||
|
||||
// ExtendedProxyHandler 扩展的代理处理器接口
|
||||
// 支持 PluginAPI 的插件应实现此接口
|
||||
type ExtendedProxyHandler interface {
|
||||
ProxyHandler
|
||||
|
||||
// SetAPI 设置 PluginAPI,允许插件调用系统功能
|
||||
SetAPI(api PluginAPI)
|
||||
}
|
||||
|
||||
// LogLevel 日志级别
|
||||
type LogLevel uint8
|
||||
|
||||
@@ -100,6 +116,101 @@ const (
|
||||
LogError
|
||||
)
|
||||
|
||||
// =============================================================================
|
||||
// API 相关类型
|
||||
// =============================================================================
|
||||
|
||||
// Side 运行侧
|
||||
type Side string
|
||||
|
||||
const (
|
||||
SideServer Side = "server"
|
||||
SideClient Side = "client"
|
||||
)
|
||||
|
||||
// Context 插件运行上下文
|
||||
type Context struct {
|
||||
PluginName string
|
||||
Side Side
|
||||
ClientID string
|
||||
Config map[string]string
|
||||
}
|
||||
|
||||
// ServerInfo 服务端信息
|
||||
type ServerInfo struct {
|
||||
BindAddr string
|
||||
BindPort int
|
||||
Version string
|
||||
}
|
||||
|
||||
// RuleConfig 代理规则配置
|
||||
type RuleConfig struct {
|
||||
ClientID string `json:"client_id"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
LocalIP string `json:"local_ip"`
|
||||
LocalPort int `json:"local_port"`
|
||||
RemotePort int `json:"remote_port"`
|
||||
Enabled bool `json:"enabled"`
|
||||
PluginName string `json:"plugin_name,omitempty"`
|
||||
PluginConfig map[string]string `json:"plugin_config,omitempty"`
|
||||
}
|
||||
|
||||
// ClientInfo 客户端信息
|
||||
type ClientInfo struct {
|
||||
ID string `json:"id"`
|
||||
Nickname string `json:"nickname"`
|
||||
Online bool `json:"online"`
|
||||
LastPing string `json:"last_ping,omitempty"`
|
||||
}
|
||||
|
||||
// EventType 事件类型
|
||||
type EventType string
|
||||
|
||||
const (
|
||||
EventClientConnect EventType = "client_connect"
|
||||
EventClientDisconnect EventType = "client_disconnect"
|
||||
EventRuleCreated EventType = "rule_created"
|
||||
EventRuleDeleted EventType = "rule_deleted"
|
||||
EventProxyConnect EventType = "proxy_connect"
|
||||
EventProxyDisconnect EventType = "proxy_disconnect"
|
||||
)
|
||||
|
||||
// Event 事件
|
||||
type Event struct {
|
||||
Type EventType `json:"type"`
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
Data map[string]interface{} `json:"data"`
|
||||
}
|
||||
|
||||
// EventHandler 事件处理函数
|
||||
type EventHandler func(event *Event)
|
||||
|
||||
// =============================================================================
|
||||
// 错误定义
|
||||
// =============================================================================
|
||||
|
||||
// APIError API 错误
|
||||
type APIError struct {
|
||||
Code int
|
||||
Message string
|
||||
}
|
||||
|
||||
func (e *APIError) Error() string {
|
||||
return e.Message
|
||||
}
|
||||
|
||||
// 常见 API 错误
|
||||
var (
|
||||
ErrNotSupported = &APIError{Code: 1, Message: "operation not supported"}
|
||||
ErrClientNotFound = &APIError{Code: 2, Message: "client not found"}
|
||||
ErrPortOccupied = &APIError{Code: 3, Message: "port already occupied"}
|
||||
ErrRuleNotFound = &APIError{Code: 4, Message: "rule not found"}
|
||||
ErrRuleExists = &APIError{Code: 5, Message: "rule already exists"}
|
||||
ErrNotConnected = &APIError{Code: 6, Message: "not connected"}
|
||||
ErrInvalidConfig = &APIError{Code: 7, Message: "invalid configuration"}
|
||||
)
|
||||
|
||||
// ConnHandle WASM 连接句柄
|
||||
type ConnHandle uint32
|
||||
|
||||
|
||||
Reference in New Issue
Block a user