update
All checks were successful
Build Multi-Platform Binaries / build-frontend (push) Successful in 38s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Successful in 59s
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Successful in 1m8s
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Successful in 1m17s
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Successful in 53s
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Successful in 1m14s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Successful in 2m8s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Successful in 1m10s
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Successful in 57s
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Successful in 58s
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Successful in 1m11s
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Successful in 55s
All checks were successful
Build Multi-Platform Binaries / build-frontend (push) Successful in 38s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Successful in 59s
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Successful in 1m8s
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Successful in 1m17s
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Successful in 53s
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Successful in 1m14s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Successful in 2m8s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Successful in 1m10s
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Successful in 57s
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Successful in 58s
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Successful in 1m11s
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Successful in 55s
This commit is contained in:
109
pkg/plugin/schema.go
Normal file
109
pkg/plugin/schema.go
Normal file
@@ -0,0 +1,109 @@
|
||||
package plugin
|
||||
|
||||
// 内置协议类型配置模式
|
||||
|
||||
// BuiltinRuleSchemas 返回所有内置协议类型的配置模式
|
||||
func BuiltinRuleSchemas() map[string]RuleSchema {
|
||||
return map[string]RuleSchema{
|
||||
"tcp": {
|
||||
NeedsLocalAddr: true,
|
||||
ExtraFields: nil,
|
||||
},
|
||||
"udp": {
|
||||
NeedsLocalAddr: true,
|
||||
ExtraFields: nil,
|
||||
},
|
||||
"http": {
|
||||
NeedsLocalAddr: false,
|
||||
ExtraFields: []ConfigField{
|
||||
{
|
||||
Key: "auth_enabled",
|
||||
Label: "启用认证",
|
||||
Type: ConfigFieldBool,
|
||||
Default: "false",
|
||||
Description: "是否启用 HTTP Basic 认证",
|
||||
},
|
||||
{
|
||||
Key: "username",
|
||||
Label: "用户名",
|
||||
Type: ConfigFieldString,
|
||||
Description: "HTTP 代理认证用户名",
|
||||
},
|
||||
{
|
||||
Key: "password",
|
||||
Label: "密码",
|
||||
Type: ConfigFieldPassword,
|
||||
Description: "HTTP 代理认证密码",
|
||||
},
|
||||
},
|
||||
},
|
||||
"https": {
|
||||
NeedsLocalAddr: false,
|
||||
ExtraFields: []ConfigField{
|
||||
{
|
||||
Key: "auth_enabled",
|
||||
Label: "启用认证",
|
||||
Type: ConfigFieldBool,
|
||||
Default: "false",
|
||||
Description: "是否启用 HTTPS 代理认证",
|
||||
},
|
||||
{
|
||||
Key: "username",
|
||||
Label: "用户名",
|
||||
Type: ConfigFieldString,
|
||||
Description: "HTTPS 代理认证用户名",
|
||||
},
|
||||
{
|
||||
Key: "password",
|
||||
Label: "密码",
|
||||
Type: ConfigFieldPassword,
|
||||
Description: "HTTPS 代理认证密码",
|
||||
},
|
||||
},
|
||||
},
|
||||
"socks5": {
|
||||
NeedsLocalAddr: false,
|
||||
ExtraFields: []ConfigField{
|
||||
{
|
||||
Key: "auth_enabled",
|
||||
Label: "启用认证",
|
||||
Type: ConfigFieldBool,
|
||||
Default: "false",
|
||||
Description: "是否启用 SOCKS5 用户名/密码认证",
|
||||
},
|
||||
{
|
||||
Key: "username",
|
||||
Label: "用户名",
|
||||
Type: ConfigFieldString,
|
||||
Description: "SOCKS5 认证用户名",
|
||||
},
|
||||
{
|
||||
Key: "password",
|
||||
Label: "密码",
|
||||
Type: ConfigFieldPassword,
|
||||
Description: "SOCKS5 认证密码",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// GetRuleSchema 获取指定协议类型的配置模式
|
||||
func GetRuleSchema(proxyType string) *RuleSchema {
|
||||
schemas := BuiltinRuleSchemas()
|
||||
if schema, ok := schemas[proxyType]; ok {
|
||||
return &schema
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsBuiltinType 检查是否为内置协议类型
|
||||
func IsBuiltinType(proxyType string) bool {
|
||||
builtinTypes := []string{"tcp", "udp", "http", "https"}
|
||||
for _, t := range builtinTypes {
|
||||
if t == proxyType {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -48,6 +48,10 @@ const (
|
||||
// JS 插件动态安装
|
||||
MsgTypeJSPluginInstall uint8 = 50 // 安装 JS 插件
|
||||
MsgTypeJSPluginResult uint8 = 51 // 安装结果
|
||||
|
||||
// 客户端控制消息
|
||||
MsgTypeClientRestart uint8 = 60 // 重启客户端
|
||||
MsgTypePluginConfigUpdate uint8 = 61 // 更新插件配置
|
||||
)
|
||||
|
||||
// Message 基础消息结构
|
||||
@@ -226,6 +230,33 @@ type JSPluginInstallResult struct {
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// ClientRestartRequest 客户端重启请求
|
||||
type ClientRestartRequest struct {
|
||||
Reason string `json:"reason,omitempty"` // 重启原因
|
||||
}
|
||||
|
||||
// ClientRestartResponse 客户端重启响应
|
||||
type ClientRestartResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
// PluginConfigUpdateRequest 插件配置更新请求
|
||||
type PluginConfigUpdateRequest struct {
|
||||
PluginName string `json:"plugin_name"` // 插件名称
|
||||
RuleName string `json:"rule_name"` // 规则名称
|
||||
Config map[string]string `json:"config"` // 新配置
|
||||
Restart bool `json:"restart"` // 是否重启插件
|
||||
}
|
||||
|
||||
// PluginConfigUpdateResponse 插件配置更新响应
|
||||
type PluginConfigUpdateResponse struct {
|
||||
PluginName string `json:"plugin_name"`
|
||||
RuleName string `json:"rule_name"`
|
||||
Success bool `json:"success"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// WriteMessage 写入消息到 writer
|
||||
func WriteMessage(w io.Writer, msg *Message) error {
|
||||
header := make([]byte, HeaderSize)
|
||||
|
||||
Reference in New Issue
Block a user