updete
Some checks failed
Build Multi-Platform Binaries / build-frontend (push) Successful in 30s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Successful in 1m4s
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Successful in 45s
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Successful in 1m29s
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Successful in 45s
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Successful in 1m27s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Successful in 50s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Successful in 1m42s
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Has been cancelled
Some checks failed
Build Multi-Platform Binaries / build-frontend (push) Successful in 30s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Successful in 1m4s
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Successful in 45s
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Successful in 1m29s
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Successful in 45s
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Successful in 1m27s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Successful in 50s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Successful in 1m42s
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Has been cancelled
This commit is contained in:
58
internal/server/router/dto/client.go
Normal file
58
internal/server/router/dto/client.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/gotunnel/internal/server/db"
|
||||
"github.com/gotunnel/pkg/protocol"
|
||||
)
|
||||
|
||||
// CreateClientRequest 创建客户端请求
|
||||
// @Description 创建新客户端的请求体
|
||||
type CreateClientRequest struct {
|
||||
ID string `json:"id" binding:"required,min=1,max=64" example:"client-001"`
|
||||
Rules []protocol.ProxyRule `json:"rules"`
|
||||
}
|
||||
|
||||
// UpdateClientRequest 更新客户端请求
|
||||
// @Description 更新客户端配置的请求体
|
||||
type UpdateClientRequest struct {
|
||||
Nickname string `json:"nickname" binding:"max=128" example:"My Client"`
|
||||
Rules []protocol.ProxyRule `json:"rules"`
|
||||
Plugins []db.ClientPlugin `json:"plugins"`
|
||||
}
|
||||
|
||||
// ClientResponse 客户端详情响应
|
||||
// @Description 客户端详细信息
|
||||
type ClientResponse struct {
|
||||
ID string `json:"id" example:"client-001"`
|
||||
Nickname string `json:"nickname,omitempty" example:"My Client"`
|
||||
Rules []protocol.ProxyRule `json:"rules"`
|
||||
Plugins []db.ClientPlugin `json:"plugins,omitempty"`
|
||||
Online bool `json:"online" example:"true"`
|
||||
LastPing string `json:"last_ping,omitempty" example:"2025-01-02T10:30:00Z"`
|
||||
RemoteAddr string `json:"remote_addr,omitempty" example:"192.168.1.100:54321"`
|
||||
}
|
||||
|
||||
// ClientListItem 客户端列表项
|
||||
// @Description 客户端列表中的单个项目
|
||||
type ClientListItem struct {
|
||||
ID string `json:"id" example:"client-001"`
|
||||
Nickname string `json:"nickname,omitempty" example:"My Client"`
|
||||
Online bool `json:"online" example:"true"`
|
||||
LastPing string `json:"last_ping,omitempty"`
|
||||
RemoteAddr string `json:"remote_addr,omitempty"`
|
||||
RuleCount int `json:"rule_count" example:"3"`
|
||||
}
|
||||
|
||||
// InstallPluginsRequest 安装插件到客户端请求
|
||||
// @Description 安装插件到指定客户端
|
||||
type InstallPluginsRequest struct {
|
||||
Plugins []string `json:"plugins" binding:"required,min=1,dive,required" example:"socks5,http-proxy"`
|
||||
}
|
||||
|
||||
// ClientPluginActionRequest 客户端插件操作请求
|
||||
// @Description 对客户端插件执行操作
|
||||
type ClientPluginActionRequest struct {
|
||||
RuleName string `json:"rule_name"`
|
||||
Config map[string]string `json:"config,omitempty"`
|
||||
Restart bool `json:"restart"`
|
||||
}
|
||||
53
internal/server/router/dto/config.go
Normal file
53
internal/server/router/dto/config.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package dto
|
||||
|
||||
// UpdateServerConfigRequest 更新服务器配置请求
|
||||
// @Description 更新服务器配置
|
||||
type UpdateServerConfigRequest struct {
|
||||
Server *ServerConfigPart `json:"server"`
|
||||
Web *WebConfigPart `json:"web"`
|
||||
}
|
||||
|
||||
// ServerConfigPart 服务器配置部分
|
||||
// @Description 隧道服务器配置
|
||||
type ServerConfigPart struct {
|
||||
BindAddr string `json:"bind_addr" binding:"omitempty"`
|
||||
BindPort int `json:"bind_port" binding:"omitempty,min=1,max=65535"`
|
||||
Token string `json:"token" binding:"omitempty,min=8"`
|
||||
HeartbeatSec int `json:"heartbeat_sec" binding:"omitempty,min=1,max=300"`
|
||||
HeartbeatTimeout int `json:"heartbeat_timeout" binding:"omitempty,min=1,max=600"`
|
||||
}
|
||||
|
||||
// WebConfigPart Web 配置部分
|
||||
// @Description Web 控制台配置
|
||||
type WebConfigPart struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
BindAddr string `json:"bind_addr" binding:"omitempty"`
|
||||
BindPort int `json:"bind_port" binding:"omitempty,min=1,max=65535"`
|
||||
Username string `json:"username" binding:"omitempty,min=3,max=32"`
|
||||
Password string `json:"password" binding:"omitempty,min=6,max=64"`
|
||||
}
|
||||
|
||||
// ServerConfigResponse 服务器配置响应
|
||||
// @Description 服务器配置信息
|
||||
type ServerConfigResponse struct {
|
||||
Server ServerConfigInfo `json:"server"`
|
||||
Web WebConfigInfo `json:"web"`
|
||||
}
|
||||
|
||||
// ServerConfigInfo 服务器配置信息
|
||||
type ServerConfigInfo struct {
|
||||
BindAddr string `json:"bind_addr"`
|
||||
BindPort int `json:"bind_port"`
|
||||
Token string `json:"token"` // 脱敏后的 token
|
||||
HeartbeatSec int `json:"heartbeat_sec"`
|
||||
HeartbeatTimeout int `json:"heartbeat_timeout"`
|
||||
}
|
||||
|
||||
// WebConfigInfo Web 配置信息
|
||||
type WebConfigInfo struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
BindAddr string `json:"bind_addr"`
|
||||
BindPort int `json:"bind_port"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"` // 显示为 ****
|
||||
}
|
||||
105
internal/server/router/dto/plugin.go
Normal file
105
internal/server/router/dto/plugin.go
Normal file
@@ -0,0 +1,105 @@
|
||||
package dto
|
||||
|
||||
// PluginConfigRequest 更新插件配置请求
|
||||
// @Description 更新客户端插件配置
|
||||
type PluginConfigRequest struct {
|
||||
Config map[string]string `json:"config" binding:"required"`
|
||||
}
|
||||
|
||||
// PluginConfigResponse 插件配置响应
|
||||
// @Description 插件配置详情
|
||||
type PluginConfigResponse struct {
|
||||
PluginName string `json:"plugin_name"`
|
||||
Schema []ConfigField `json:"schema"`
|
||||
Config map[string]string `json:"config"`
|
||||
}
|
||||
|
||||
// ConfigField 配置字段定义
|
||||
// @Description 配置表单字段
|
||||
type ConfigField struct {
|
||||
Key string `json:"key"`
|
||||
Label string `json:"label"`
|
||||
Type string `json:"type"`
|
||||
Default string `json:"default,omitempty"`
|
||||
Required bool `json:"required,omitempty"`
|
||||
Options []string `json:"options,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
// RuleSchema 规则表单模式
|
||||
// @Description 代理规则的配置模式
|
||||
type RuleSchema struct {
|
||||
NeedsLocalAddr bool `json:"needs_local_addr"`
|
||||
ExtraFields []ConfigField `json:"extra_fields,omitempty"`
|
||||
}
|
||||
|
||||
// PluginInfo 插件信息
|
||||
// @Description 服务端插件信息
|
||||
type PluginInfo struct {
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
Type string `json:"type"`
|
||||
Description string `json:"description"`
|
||||
Source string `json:"source"`
|
||||
Icon string `json:"icon,omitempty"`
|
||||
Enabled bool `json:"enabled"`
|
||||
RuleSchema *RuleSchema `json:"rule_schema,omitempty"`
|
||||
}
|
||||
|
||||
// JSPluginCreateRequest 创建 JS 插件请求
|
||||
// @Description 创建新的 JS 插件
|
||||
type JSPluginCreateRequest struct {
|
||||
Name string `json:"name" binding:"required,min=1,max=64"`
|
||||
Source string `json:"source" binding:"required"`
|
||||
Signature string `json:"signature"`
|
||||
Description string `json:"description" binding:"max=500"`
|
||||
Author string `json:"author" binding:"max=64"`
|
||||
Config map[string]string `json:"config"`
|
||||
AutoStart bool `json:"auto_start"`
|
||||
}
|
||||
|
||||
// JSPluginUpdateRequest 更新 JS 插件请求
|
||||
// @Description 更新 JS 插件
|
||||
type JSPluginUpdateRequest struct {
|
||||
Source string `json:"source"`
|
||||
Signature string `json:"signature"`
|
||||
Description string `json:"description" binding:"max=500"`
|
||||
Author string `json:"author" binding:"max=64"`
|
||||
Config map[string]string `json:"config"`
|
||||
AutoStart bool `json:"auto_start"`
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
// JSPluginInstallRequest JS 插件安装请求
|
||||
// @Description 安装 JS 插件到客户端
|
||||
type JSPluginInstallRequest struct {
|
||||
PluginName string `json:"plugin_name" binding:"required"`
|
||||
Source string `json:"source" binding:"required"`
|
||||
Signature string `json:"signature"`
|
||||
RuleName string `json:"rule_name"`
|
||||
RemotePort int `json:"remote_port"`
|
||||
Config map[string]string `json:"config"`
|
||||
AutoStart bool `json:"auto_start"`
|
||||
}
|
||||
|
||||
// StorePluginInfo 扩展商店插件信息
|
||||
// @Description 插件商店中的插件信息
|
||||
type StorePluginInfo struct {
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
Type string `json:"type"`
|
||||
Description string `json:"description"`
|
||||
Author string `json:"author"`
|
||||
Icon string `json:"icon,omitempty"`
|
||||
DownloadURL string `json:"download_url,omitempty"`
|
||||
SignatureURL string `json:"signature_url,omitempty"`
|
||||
}
|
||||
|
||||
// StoreInstallRequest 从商店安装插件请求
|
||||
// @Description 从插件商店安装插件到客户端
|
||||
type StoreInstallRequest struct {
|
||||
PluginName string `json:"plugin_name" binding:"required"`
|
||||
DownloadURL string `json:"download_url" binding:"required,url"`
|
||||
SignatureURL string `json:"signature_url" binding:"required,url"`
|
||||
ClientID string `json:"client_id" binding:"required"`
|
||||
}
|
||||
76
internal/server/router/dto/update.go
Normal file
76
internal/server/router/dto/update.go
Normal file
@@ -0,0 +1,76 @@
|
||||
package dto
|
||||
|
||||
// CheckUpdateResponse 检查更新响应
|
||||
// @Description 更新检查结果
|
||||
type CheckUpdateResponse struct {
|
||||
HasUpdate bool `json:"has_update"`
|
||||
CurrentVersion string `json:"current_version"`
|
||||
LatestVersion string `json:"latest_version,omitempty"`
|
||||
DownloadURL string `json:"download_url,omitempty"`
|
||||
ReleaseNotes string `json:"release_notes,omitempty"`
|
||||
PublishedAt string `json:"published_at,omitempty"`
|
||||
}
|
||||
|
||||
// CheckClientUpdateQuery 检查客户端更新查询参数
|
||||
// @Description 检查客户端更新的查询参数
|
||||
type CheckClientUpdateQuery struct {
|
||||
OS string `form:"os" binding:"omitempty,oneof=linux darwin windows"`
|
||||
Arch string `form:"arch" binding:"omitempty,oneof=amd64 arm64 386 arm"`
|
||||
}
|
||||
|
||||
// ApplyServerUpdateRequest 应用服务端更新请求
|
||||
// @Description 应用服务端更新
|
||||
type ApplyServerUpdateRequest struct {
|
||||
DownloadURL string `json:"download_url" binding:"required,url"`
|
||||
Restart bool `json:"restart"`
|
||||
}
|
||||
|
||||
// ApplyClientUpdateRequest 应用客户端更新请求
|
||||
// @Description 推送更新到客户端
|
||||
type ApplyClientUpdateRequest struct {
|
||||
ClientID string `json:"client_id" binding:"required"`
|
||||
DownloadURL string `json:"download_url" binding:"required,url"`
|
||||
}
|
||||
|
||||
// VersionInfo 版本信息
|
||||
// @Description 当前版本信息
|
||||
type VersionInfo struct {
|
||||
Version string `json:"version"`
|
||||
GitCommit string `json:"git_commit,omitempty"`
|
||||
BuildTime string `json:"build_time,omitempty"`
|
||||
GoVersion string `json:"go_version,omitempty"`
|
||||
Platform string `json:"platform,omitempty"`
|
||||
}
|
||||
|
||||
// StatusResponse 服务器状态响应
|
||||
// @Description 服务器状态信息
|
||||
type StatusResponse struct {
|
||||
Server ServerStatus `json:"server"`
|
||||
ClientCount int `json:"client_count"`
|
||||
}
|
||||
|
||||
// ServerStatus 服务器状态
|
||||
type ServerStatus struct {
|
||||
BindAddr string `json:"bind_addr"`
|
||||
BindPort int `json:"bind_port"`
|
||||
}
|
||||
|
||||
// LoginRequest 登录请求
|
||||
// @Description 用户登录
|
||||
type LoginRequest struct {
|
||||
Username string `json:"username" binding:"required"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
}
|
||||
|
||||
// LoginResponse 登录响应
|
||||
// @Description 登录成功返回
|
||||
type LoginResponse struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
// TokenCheckResponse Token 检查响应
|
||||
// @Description Token 验证结果
|
||||
type TokenCheckResponse struct {
|
||||
Valid bool `json:"valid"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
Reference in New Issue
Block a user