handler

package
v4.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 66 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPageSize = 20
	MaxPageSize     = 100
)

Pagination defaults and limits.

Variables

View Source
var (
	BuildVersion = "dev"
	BuildTime    = "unknown"
	BuildCode    = ""
	BuildCommit  = "unknown"
)

BuildInfo is set via ldflags at build time.

Functions

func AdminMFASettings added in v4.1.0

func AdminMFASettings(db *gorm.DB) (map[string]any, error)

AdminMFASettings returns the admin MFA configuration as the admin API shows it, with defaults applied; KernelIdentity seeds identity with it.

func ClampPagination

func ClampPagination(page, pageSize int) (int, int)

ClampPagination ensures page >= 1 and pageSize is within [1, MaxPageSize]. It returns the clamped values, using DefaultPageSize when pageSize is zero.

func FinalizeIdentity added in v4.1.0

func FinalizeIdentity(c *gin.Context)

FinalizeIdentity removes the legacy credentials. It cannot be undone.

func IdentityJWKS added in v4.1.0

func IdentityJWKS(c *gin.Context)

IdentityJWKS publishes the identity module's token keys that Control accepts, so other services can verify identity tokens issued for Control.

func IdentityLogout added in v4.1.0

func IdentityLogout(c *gin.Context)

IdentityLogout ends the calling session: its token stops working at once, in every Control process, until it would have expired anyway. Tokens issued before session ids existed carry none and cannot be ended alone.

func IdentityStatus added in v4.1.0

func IdentityStatus(c *gin.Context)

IdentityStatus reports the identity authority state and the account import progress.

func NewV2CompatibilityGateway

func NewV2CompatibilityGateway(cfg *config.Config, cache *compatv2.VerifiedRouteCache) *compatv2.Gateway

NewV2CompatibilityGateway builds the unary v2 compatibility gateway. A missing or invalid trust root remains a resolver error, so the gateway fails closed rather than using legacy code.

func NewV2RouteCache added in v4.1.0

func NewV2RouteCache() *compatv2.VerifiedRouteCache

NewV2RouteCache returns the verified-route cache that one router's unary and WebSocket v2 gateways share, so a signed release artifact is verified once rather than per request and per gateway.

func NewV2WebSocketGateway

func NewV2WebSocketGateway(cfg *config.Config, cache *compatv2.VerifiedRouteCache) *compatv2.WebSocketGateway

NewV2WebSocketGateway exposes the optional streaming capability only when the current manager explicitly implements it.

func PublicConfigHandler added in v4.1.0

func PublicConfigHandler(cfg *config.Config) gin.HandlerFunc

PublicConfigHandler serves GET /api/v4/public/config.

@Summary 公开配置 @Description 产品版本 (community / commercial)、该版本隐藏的包,以及注册是否需要邀请码 @Tags 系统 @Produce json @Success 200 {object} map[string]interface{} @Router /api/v4/public/config [get]

func StartIdentityCutover added in v4.1.0

func StartIdentityCutover(c *gin.Context)

StartIdentityCutover hands group A to identity in the background; IdentityStatus follows it.

func StartIdentityImport added in v4.1.0

func StartIdentityImport(c *gin.Context)

StartIdentityImport starts a full or delta account import in the background; IdentityStatus follows it.

func StartIdentityRollback added in v4.1.0

func StartIdentityRollback(c *gin.Context)

StartIdentityRollback hands group A back to the legacy handlers (before finalize) in the background; IdentityStatus follows it.

Types

type AdminCouponHandler

type AdminCouponHandler struct{}

AdminCouponHandler 优惠券处理器

func NewAdminCouponHandler

func NewAdminCouponHandler() *AdminCouponHandler

NewAdminCouponHandler 创建优惠券处理器

func (*AdminCouponHandler) CreateCoupon

func (h *AdminCouponHandler) CreateCoupon(c *gin.Context)

CreateCoupon 创建优惠券

func (*AdminCouponHandler) DeleteCoupon

func (h *AdminCouponHandler) DeleteCoupon(c *gin.Context)

DeleteCoupon 删除优惠券

func (*AdminCouponHandler) GetCoupons

func (h *AdminCouponHandler) GetCoupons(c *gin.Context)

GetCoupons 获取优惠券列表

type AdminHandler

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

AdminHandler 管理员处理器

func NewAdminHandler

func NewAdminHandler() *AdminHandler

NewAdminHandler 创建管理员处理器

func (*AdminHandler) AssignPlanToUser

func (h *AdminHandler) AssignPlanToUser(c *gin.Context)

AssignPlanToUser godoc @Summary 分配套餐给用户 @Description 管理员将指定套餐分配给用户 @Tags 管理端-套餐 @Accept json @Produce json @Security BearerAuth @Param id path int true "套餐ID" @Param request body map[string]any true "分配请求 {user_id: uint, expire_at: int64}" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/plans/{id}/assign [post]

func (*AdminHandler) BanUser

func (h *AdminHandler) BanUser(c *gin.Context)

BanUser godoc @Summary 封禁用户 @Description 管理员封禁指定用户 @Tags 管理端-用户 @Accept json @Produce json @Security BearerAuth @Param id path int true "用户ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/users/{id}/ban [post]

func (*AdminHandler) CancelOrder

func (h *AdminHandler) CancelOrder(c *gin.Context)

CancelOrder godoc @Summary 取消订单 @Description 管理员取消指定订单 @Tags 管理端-订单 @Accept json @Produce json @Security BearerAuth @Param id path int true "订单ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/orders/{id}/cancel [post]

func (*AdminHandler) CreatePlan

func (h *AdminHandler) CreatePlan(c *gin.Context)

CreatePlan godoc @Summary 创建套餐 @Description 管理员创建新套餐 @Tags 管理端-套餐 @Accept json @Produce json @Security BearerAuth @Param request body model.Plan true "套餐信息" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/plans [post]

func (*AdminHandler) CreateUser

func (h *AdminHandler) CreateUser(c *gin.Context)

CreateUser godoc @Summary 创建用户 @Description 管理员创建新用户 @Tags 管理端-用户 @Accept json @Produce json @Security BearerAuth @Param request body model.AdminCreateUserRequest true "用户信息" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Router /admin/users [post]

func (*AdminHandler) DeletePlan

func (h *AdminHandler) DeletePlan(c *gin.Context)

DeletePlan godoc @Summary 删除套餐 @Description 管理员删除指定套餐 @Tags 管理端-套餐 @Accept json @Produce json @Security BearerAuth @Param id path int true "套餐ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/plans/{id} [delete]

func (*AdminHandler) DeleteUser

func (h *AdminHandler) DeleteUser(c *gin.Context)

DeleteUser godoc @Summary 删除用户 @Description 管理员删除指定用户 @Tags 管理端-用户 @Accept json @Produce json @Security BearerAuth @Param id path int true "用户ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/users/{id} [delete]

func (*AdminHandler) GetDashboard

func (h *AdminHandler) GetDashboard(c *gin.Context)

GetDashboard godoc @Summary 获取仪表盘数据 @Description 管理员获取仪表盘统计数据,包括用户数、订单数、收入等 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Param refresh query bool false "是否强制刷新缓存" @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/dashboard [get]

func (*AdminHandler) GetHourlyTraffic

func (h *AdminHandler) GetHourlyTraffic(c *gin.Context)

GetHourlyTraffic 返回最近 N 小时的流量序列 (默认 24 小时, 最多 720 小时) GET /api/v2/admin/traffic/hourly?hours=24&user_id=0

func (*AdminHandler) GetOrder

func (h *AdminHandler) GetOrder(c *gin.Context)

GetOrder godoc The order with its plan's id and name and its buyer's id and e-mail (service.OrderView). @Summary 获取订单详情 @Description 管理员获取指定订单的详细信息 @Tags 管理端-订单 @Accept json @Produce json @Security BearerAuth @Param id path int true "订单ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 404 {object} map[string]any @Router /admin/orders/{id} [get]

func (*AdminHandler) GetOrderList

func (h *AdminHandler) GetOrderList(c *gin.Context)

GetOrderList godoc Each order carries its plan's id and name and its buyer's id and e-mail (service.OrderView), never the rest of their rows. @Summary 获取订单列表 @Description 管理员获取订单列表,支持分页和筛选 @Tags 管理端-订单 @Accept json @Produce json @Security BearerAuth @Param page query int false "页码" default(1) @Param page_size query int false "每页数量" default(20) @Param trade_no query string false "订单号" @Param email query string false "用户邮箱" @Param status query int false "订单状态" @Param type query int false "订单类型" @Param user_id query int false "用户ID" @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/orders [get]

func (*AdminHandler) GetOrderStats

func (h *AdminHandler) GetOrderStats(c *gin.Context)

GetOrderStats godoc @Summary 获取订单统计 @Description 管理员获取订单统计数据 @Tags 管理端-订单 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/orders/stats [get]

func (*AdminHandler) GetPlan

func (h *AdminHandler) GetPlan(c *gin.Context)

GetPlan godoc @Summary 获取套餐详情 @Description 管理员获取指定套餐的详细信息 @Tags 管理端-套餐 @Accept json @Produce json @Security BearerAuth @Param id path int true "套餐ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 404 {object} map[string]any @Router /admin/plans/{id} [get]

func (*AdminHandler) GetPlans

func (h *AdminHandler) GetPlans(c *gin.Context)

GetPlans godoc @Summary 获取套餐列表 @Description 管理员获取所有套餐列表 @Tags 管理端-套餐 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/plans [get]

func (*AdminHandler) GetSystemInfo

func (h *AdminHandler) GetSystemInfo(c *gin.Context)

GET /api/v2/admin/system/info

func (*AdminHandler) GetUser

func (h *AdminHandler) GetUser(c *gin.Context)

GetUser godoc @Summary 获取用户详情 @Description 管理员获取用户详细信息 @Tags 管理端-用户 @Accept json @Produce json @Security BearerAuth @Param id path int true "用户ID" @Success 200 {object} map[string]any @Router /admin/users/{id} [get]

func (*AdminHandler) GetUserList

func (h *AdminHandler) GetUserList(c *gin.Context)

GetUserList godoc Each user carries the account and subscription summary (service.UserListItem), never the subscription token or proxy uuid, which the user detail answers for one user. @Summary 获取用户列表 @Description 管理员获取用户列表 @Tags 管理端-用户 @Accept json @Produce json @Security BearerAuth @Param page query int false "页码" default(1) @Param page_size query int false "每页数量" default(20) @Param email query string false "邮箱搜索" @Param status query string false "状态筛选" @Param plan_id query int false "套餐ID筛选" @Success 200 {object} map[string]any @Router /admin/users [get]

func (*AdminHandler) GetUserStats

func (h *AdminHandler) GetUserStats(c *gin.Context)

GetUserStats godoc @Summary 获取用户统计 @Description 管理员获取用户统计数据,包括总用户数、活跃用户等 @Tags 管理端-用户 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/users/stats [get]

func (*AdminHandler) GetUserTrafficRanking

func (h *AdminHandler) GetUserTrafficRanking(c *gin.Context)

GetUserTrafficRanking 返回最近 N 小时内按用户聚合的流量排行 (默认 24 小时, top 20) GET /api/v2/admin/traffic/user-ranking?hours=24&limit=20

func (*AdminHandler) MarkOrderPaid

func (h *AdminHandler) MarkOrderPaid(c *gin.Context)

MarkOrderPaid godoc @Summary 标记订单已支付 @Description 管理员手动标记订单为已支付并开通服务 @Tags 管理端-订单 @Accept json @Produce json @Security BearerAuth @Param id path int true "订单ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/orders/{id}/paid [post]

func (*AdminHandler) ResetCompatFlow

func (h *AdminHandler) ResetCompatFlow(c *gin.Context)

ResetCompatFlow is the Flux-style POST /api/v2/user/reset: type 1 zeroes a subscriber's traffic, under service.ForwardUserResetRequestID in the subscriber request ledger so that a retry applies once whichever side serves it (the forward package serves the route natively too); type 2 zeroes a tunnel permission's traffic and that of its forwards.

func (*AdminHandler) ResetUserSubscribe

func (h *AdminHandler) ResetUserSubscribe(c *gin.Context)

ResetUserSubscribe godoc @Summary 重置用户订阅 @Description 管理员为用户重新生成订阅 token, 旧订阅链接立即失效 (UUID 不变) @Tags 管理端-用户 @Accept json @Produce json @Security BearerAuth @Param id path int true "用户ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/users/{id}/reset-subscribe [post]

func (*AdminHandler) ResetUserTraffic

func (h *AdminHandler) ResetUserTraffic(c *gin.Context)

ResetUserTraffic godoc @Summary 重置用户流量 @Description 管理员重置指定用户的已使用流量 @Tags 管理端-用户 @Accept json @Produce json @Security BearerAuth @Param id path int true "用户ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/users/{id}/reset-traffic [post]

func (*AdminHandler) UnbanUser

func (h *AdminHandler) UnbanUser(c *gin.Context)

UnbanUser godoc @Summary 解封用户 @Description 管理员解封指定用户 @Tags 管理端-用户 @Accept json @Produce json @Security BearerAuth @Param id path int true "用户ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/users/{id}/unban [post]

func (*AdminHandler) UpdateOrderStatus

func (h *AdminHandler) UpdateOrderStatus(c *gin.Context)

UpdateOrderStatus godoc @Summary 更新订单状态 @Description 管理员更新指定订单的状态 @Tags 管理端-订单 @Accept json @Produce json @Security BearerAuth @Param id path int true "订单ID" @Param request body map[string]any true "状态请求 {status: int}" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/orders/{id}/status [put]

func (*AdminHandler) UpdatePlan

func (h *AdminHandler) UpdatePlan(c *gin.Context)

UpdatePlan godoc @Summary 更新套餐 @Description 管理员更新指定套餐信息 @Tags 管理端-套餐 @Accept json @Produce json @Security BearerAuth @Param id path int true "套餐ID" @Param request body model.Plan true "套餐信息" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/plans/{id} [put]

func (*AdminHandler) UpdateUser

func (h *AdminHandler) UpdateUser(c *gin.Context)

UpdateUser godoc @Summary 更新用户信息 @Description 管理员更新用户信息,支持修改邮箱、密码、余额、套餐等 @Tags 管理端-用户 @Accept json @Produce json @Security BearerAuth @Param id path int true "用户ID" @Param request body map[string]any true "用户更新信息" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/users/{id} [put]

type AdminKnowledgeHandler

type AdminKnowledgeHandler struct{}

AdminKnowledgeHandler 知识库处理器

func NewAdminKnowledgeHandler

func NewAdminKnowledgeHandler() *AdminKnowledgeHandler

NewAdminKnowledgeHandler 创建知识库处理器

func (*AdminKnowledgeHandler) CreateArticle

func (h *AdminKnowledgeHandler) CreateArticle(c *gin.Context)

CreateArticle 创建文章

func (*AdminKnowledgeHandler) DeleteArticle

func (h *AdminKnowledgeHandler) DeleteArticle(c *gin.Context)

DeleteArticle 删除文章

func (*AdminKnowledgeHandler) GetArticles

func (h *AdminKnowledgeHandler) GetArticles(c *gin.Context)

GetArticles 获取文章列表

func (*AdminKnowledgeHandler) UpdateArticle

func (h *AdminKnowledgeHandler) UpdateArticle(c *gin.Context)

UpdateArticle 更新文章

type AdminTicketHandler

type AdminTicketHandler struct{}

AdminTicketHandler 工单处理器

func NewAdminTicketHandler

func NewAdminTicketHandler() *AdminTicketHandler

NewAdminTicketHandler 创建工单处理器

func (*AdminTicketHandler) CloseTicket

func (h *AdminTicketHandler) CloseTicket(c *gin.Context)

CloseTicket 关闭工单

func (*AdminTicketHandler) GetTickets

func (h *AdminTicketHandler) GetTickets(c *gin.Context)

GetTickets 获取工单列表

func (*AdminTicketHandler) ReplyTicket

func (h *AdminTicketHandler) ReplyTicket(c *gin.Context)

ReplyTicket 回复工单

type AgentConnection

type AgentConnection struct {
	NodeID        uint
	LastSeen      time.Time
	Version       string
	SystemInfo    map[string]any
	Capabilities  []string
	IsForwardNode bool
	WsConn        *websocket.Conn
	// contains filtered or unexported fields
}

AgentConnection Agent 连接信息

type AgentHandler

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

AgentHandler Agent 管理 API

func NewAgentHandler

func NewAgentHandler() *AgentHandler

NewAgentHandler 创建 Handler

func (*AgentHandler) AgentGetForwardRules

func (h *AgentHandler) AgentGetForwardRules(c *gin.Context)

AgentGetForwardRules godoc @Summary 获取转发规则 @Description Agent 获取该节点的转发规则 @Tags Agent @Produce json @Param node_id query int true "节点 ID" @Param X-API-Key header string true "forward node API token" @Success 200 {object} map[string]any @Failure 401 {object} map[string]any @Failure 403 {object} map[string]any @Router /api/v2/forward/agent/rules [get]

Only a forward node reads its rules: the request names the node (node_id, or the X-Node-ID header) and carries its API token (the X-API-Key header, or api_key or token), as the agent's other calls do. The route is public, and the rules show where every user's traffic goes.

func (*AgentHandler) AgentGetTasks

func (h *AgentHandler) AgentGetTasks(c *gin.Context)

AgentGetTasks godoc @Summary 获取待执行任务 @Description Agent 轮询获取待执行的任务 @Tags Agent @Produce json @Param node_id query int true "节点 ID" @Success 200 {object} map[string]any @Router /api/v2/agent/tasks [get]

func (*AgentHandler) AgentHeartbeat

func (h *AgentHandler) AgentHeartbeat(c *gin.Context)

AgentHeartbeat godoc @Summary Agent 心跳 @Description Agent 定期发送心跳 @Tags Agent @Accept json @Produce json @Param request body AgentHeartbeatRequest true "心跳信息" @Success 200 {object} map[string]any @Router /api/v2/agent/heartbeat [post]

func (*AgentHandler) AgentMonitor

func (h *AgentHandler) AgentMonitor(c *gin.Context)

AgentMonitor godoc @Summary 上报监控数据 @Description Agent 上报系统监控数据 @Tags Agent @Accept json @Produce json @Param request body AgentMonitorRequest true "监控数据" @Success 200 {object} map[string]any @Router /api/v2/agent/monitor [post]

func (*AgentHandler) AgentRegister

func (h *AgentHandler) AgentRegister(c *gin.Context)

AgentRegister godoc @Summary Agent 注册 @Description Agent 启动时注册到面板 @Tags Agent @Accept json @Produce json @Param request body AgentRegisterRequest true "注册信息" @Success 200 {object} map[string]any @Router /api/v2/agent/register [post]

func (*AgentHandler) AgentReportResult

func (h *AgentHandler) AgentReportResult(c *gin.Context)

AgentReportResult godoc @Summary 上报任务结果 @Description Agent 上报任务执行结果 @Tags Agent @Accept json @Produce json @Param request body AgentTaskResult true "任务结果" @Success 200 {object} map[string]any @Router /api/v2/agent/result [post]

func (*AgentHandler) AgentWebSocketUnified

func (h *AgentHandler) AgentWebSocketUnified(c *gin.Context)

AgentWebSocketUnified supports both legacy message-auth and header/query-auth. @Summary WebSocket 连接 @Description Agent 建立 WebSocket 长连接 @Tags Agent @Success 101 @Router /api/v2/agent/ws [get]

func (*AgentHandler) CreateTask

func (h *AgentHandler) CreateTask(c *gin.Context)

CreateTask godoc @Summary 创建任务 @Description 管理员向节点下发任务 @Tags 管理端 Agent @Accept json @Produce json @Security BearerAuth @Param request body CreateTaskRequest true "任务信息" @Success 200 {object} map[string]any @Router /admin/agent/tasks [post]

func (*AgentHandler) ExecuteCommand

func (h *AgentHandler) ExecuteCommand(c *gin.Context)

ExecuteCommand godoc @Summary 执行命令 @Description 管理员在节点上执行命令 @Tags 管理端 Agent @Accept json @Produce json @Security BearerAuth @Param request body ExecuteCommandRequest true "命令信息" @Success 200 {object} map[string]any @Router /admin/agent/execute [post]

func (*AgentHandler) GetMonitor

func (h *AgentHandler) GetMonitor(c *gin.Context)

GetMonitor godoc @Summary Get latest monitor payload from agent node @Description Query monitor data by node_id @Tags 管理端 Agent @Produce json @Security BearerAuth @Param node_id query int true "Node ID" @Success 200 {object} map[string]any @Failure 404 {object} map[string]any @Router /admin/agent/monitor [get]

func (*AgentHandler) GetTaskResult

func (h *AgentHandler) GetTaskResult(c *gin.Context)

GetTaskResult godoc @Summary Get task execution result @Description Query the latest status/result for a task by task_id @Tags 管理端 Agent @Produce json @Security BearerAuth @Param task_id path string true "Task ID" @Success 200 {object} map[string]any @Failure 404 {object} map[string]any @Router /admin/agent/tasks/{task_id} [get]

func (*AgentHandler) ListAgents

func (h *AgentHandler) ListAgents(c *gin.Context)

ListAgents godoc @Summary 获取在线 Agent 列表 @Description 管理员获取所有在线的 Agent @Tags 管理端 Agent @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Router /admin/agent/list [get]

func (*AgentHandler) ListDiagnosticTasks

func (h *AgentHandler) ListDiagnosticTasks(c *gin.Context)

ListDiagnosticTasks godoc @Summary List diagnostic task history @Description Query recent whitelisted diagnostic tasks, optionally filtered by node_id @Tags 管理端 Agent @Produce json @Security BearerAuth @Param node_id query int false "Node ID" @Param limit query int false "Limit" @Success 200 {object} map[string]any @Router /admin/agent/tasks [get]

func (*AgentHandler) PrepareWebSocketBridge

func (h *AgentHandler) PrepareWebSocketBridge(c *gin.Context) bool

PrepareWebSocketBridge authenticates optional request credentials before a package-host relay is opened. It retains only the verified node identity in Gin context; the credential itself never reaches the package host.

func (*AgentHandler) RequireAgentNode added in v4.1.0

func (h *AgentHandler) RequireAgentNode(c *gin.Context)

RequireAgentNode authenticates an agent's HTTP request in the kernel, before the package gateway, as the agent WebSocket's preflight does: the node id comes from X-Node-ID or the node_id query, the token from X-API-Key or the api_key or token query, and verifyForwardNodeToken checks it. The verified node travels to the legacy handler as the kernel's trusted agent identity, so the credential never reaches the package host.

The heartbeat, task, result and monitor routes had no authentication: anyone could mark any node online, take and complete its queued tasks (forward runtime jobs included) or report its monitoring data.

func (*AgentHandler) WebSockets added in v4.1.0

func (h *AgentHandler) WebSockets() agentstreams.WebSockets

WebSockets is this handler's connected agents as the KernelNodeOps session RPCs and the agent.diagnostic executor read them (agentstreams.WebSockets).

type AgentHeartbeatRequest

type AgentHeartbeatRequest struct {
	NodeID    uint           `json:"node_id" binding:"required,gt=0"`
	Status    string         `json:"status" binding:"omitempty,max=32"`
	Resources map[string]any `json:"resources"`
}

AgentHeartbeatRequest 心跳请求

type AgentMonitorRequest

type AgentMonitorRequest struct {
	NodeID uint           `json:"node_id" binding:"required"`
	System map[string]any `json:"system"`
}

AgentMonitorRequest 监控请求

type AgentMonitorSnapshot

type AgentMonitorSnapshot struct {
	NodeID    uint           `json:"node_id"`
	System    map[string]any `json:"system"`
	UpdatedAt time.Time      `json:"updated_at"`
}

AgentMonitorSnapshot stores the latest monitor payload pushed by an agent node.

type AgentPKIHandler added in v4.1.0

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

AgentPKIHandler administers agent enrollment: one-time credentials that enroll a new node's agent (node-ops-service.md, section 5.3). Routes sit behind admin authentication and the audit log.

func NewAgentPKIHandler added in v4.1.0

func NewAgentPKIHandler() *AgentPKIHandler

NewAgentPKIHandler builds the agent PKI from the loaded configuration on each request.

func (*AgentPKIHandler) CreateEnrollmentToken added in v4.1.0

func (h *AgentPKIHandler) CreateEnrollmentToken(c *gin.Context)

CreateEnrollmentToken issues a one-time agent enrollment credential bound to a node.

type AgentRegisterRequest

type AgentRegisterRequest struct {
	NodeID       uint           `json:"node_id" binding:"required,gt=0"`
	Token        string         `json:"token" binding:"required,min=1"`
	Version      string         `json:"version" binding:"omitempty,max=64"`
	System       map[string]any `json:"system"`
	Capabilities []string       `json:"capabilities"`
}

AgentRegisterRequest 注册请求

type AgentTask

type AgentTask = agentstreams.DiagnosticTask

AgentTask 任务定义

type AgentTaskResult

type AgentTaskResult struct {
	TaskID    string    `json:"task_id" binding:"required"`
	NodeID    uint      `json:"node_id,omitempty"`
	Type      string    `json:"type,omitempty"`
	Action    string    `json:"action,omitempty"`
	Success   bool      `json:"success"`
	Output    string    `json:"output"`
	Error     string    `json:"error,omitempty"`
	Data      any       `json:"data,omitempty"`
	Duration  int64     `json:"duration_ms"`
	Timestamp time.Time `json:"timestamp"`
}

AgentTaskResult 任务结果

type AgentTransportsHandler added in v4.1.0

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

AgentTransportsHandler serves the agent transport inventory (node-ops-service.md, section 5.6): which channel each node's agent was last seen on, before agent_control.mtls becomes required.

func NewAgentTransportsHandler added in v4.1.0

func NewAgentTransportsHandler(policy agenttransport.Policy) *AgentTransportsHandler

NewAgentTransportsHandler reads the kernel database and this process's live sightings under policy, the router's agent_control.

func (*AgentTransportsHandler) List added in v4.1.0

func (h *AgentTransportsHandler) List(c *gin.Context)

List godoc @Summary Agent transport inventory @Description Lists every proxy and forward node with the transport its agent was last seen on (mtls-stream, apikey-stream, http-legacy, websocket, clean-agent, uniproxy, v2board-grpc), its agent version, its newest valid agent certificate and when it was last seen. legacy_only=true keeps the nodes on a legacy AnixOps Agent channel. summary.ready_for_required (with required_reasons and required_blockers, computed over every node) is false while agent_control.mtls: required, the default from v4.2, would refuse an enabled node: a legacy one or one that never enrolled. @Tags Kernel @Produce json @Security BearerAuth @Param legacy_only query bool false "only nodes on a legacy AnixOps Agent channel" @Success 200 {object} map[string]any @Router /api/v4/kernel/agents/transports [get]

type AuthHandler

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

func NewAuthHandler

func NewAuthHandler(cfg *config.Config) *AuthHandler

func (*AuthHandler) Login

func (h *AuthHandler) Login(c *gin.Context)

Login godoc @Summary 用户登录 @Description 用户登录获取 JWT Token @Tags 认证 @Accept json @Produce json @Param request body model.LoginRequest true "登录请求" @Success 200 {object} map[string]any "登录成功" @Failure 401 {object} map[string]any "认证失败" @Router /login [post]

func (*AuthHandler) Register

func (h *AuthHandler) Register(c *gin.Context)

Register godoc @Summary 用户注册 @Description 创建新用户账户 @Tags 认证 @Accept json @Produce json @Param request body model.RegisterRequest true "注册请求" @Success 200 {object} map[string]any "注册成功" @Failure 400 {object} map[string]any "参数错误" @Router /register [post]

type BroadcastRequest

type BroadcastRequest struct {
	Message string `json:"message" binding:"required"`
}

BroadcastRequest 广播请求

type CouponHandler

type CouponHandler struct{}

CouponHandler 用户端优惠券处理器

func NewCouponHandler

func NewCouponHandler() *CouponHandler

NewCouponHandler 创建优惠券处理器

func (*CouponHandler) CheckCoupon

func (h *CouponHandler) CheckCoupon(c *gin.Context)

CheckCoupon 校验优惠券是否可用

type CreateAnsibleMachineRequest

type CreateAnsibleMachineRequest struct {
	Name   string `json:"name" binding:"required"`
	Host   string `json:"host" binding:"required"`
	Port   int    `json:"port" binding:"required,min=1,max=65535"`
	Region string `json:"region"`
	ISP    string `json:"isp"`
	Weight int    `json:"weight"`
}

type CreateGatewayRequest

type CreateGatewayRequest struct {
	Name        string  `json:"name" binding:"required"`
	Type        string  `json:"type" binding:"required,oneof=alipay wechat stripe usdt epay"`
	Icon        string  `json:"icon"`
	Config      any     `json:"config"`
	FeeRate     float64 `json:"fee_rate"`
	FeeFixed    float64 `json:"fee_fixed"`
	MinAmount   float64 `json:"min_amount"`
	MaxAmount   float64 `json:"max_amount"`
	Sort        int     `json:"sort"`
	Description string  `json:"description"`
}

CreateGatewayRequest 创建网关请求

type CreateNodeRequest

type CreateNodeRequest struct {
	Name        string `json:"name" binding:"required"`
	Type        string `json:"type" binding:"required,oneof=relay exit"`
	Host        string `json:"host" binding:"required"`
	Port        int    `json:"port" binding:"required,min=1,max=65535"`
	APIPort     int    `json:"api_port"`
	APIToken    string `json:"api_token"`
	MetricsPort int    `json:"metrics_port"`
	Region      string `json:"region"`
	ISP         string `json:"isp"`
	Bandwidth   int64  `json:"bandwidth"`
	Weight      int    `json:"weight"`
	MaxConn     int    `json:"max_conn"`
}

CreateNodeRequest 创建节点请求

type CreatePaymentRequest

type CreatePaymentRequest struct {
	GatewayID uint    `json:"gateway_id" binding:"required"`
	Amount    float64 `json:"amount" binding:"required,min=1"`
	OrderID   *uint   `json:"order_id"`
}

CreatePaymentRequest 创建支付请求

type CreateRuleRequest

type CreateRuleRequest struct {
	Name         string     `json:"name" binding:"required"`
	RelayNodeID  uint       `json:"relay_node_id" binding:"required"`
	ListenPort   int        `json:"listen_port" binding:"required,min=1,max=65535"`
	Protocol     string     `json:"protocol" binding:"omitempty,oneof=tcp udp both"`
	ExitNodeID   uint       `json:"exit_node_id" binding:"required"`
	TargetHost   string     `json:"target_host" binding:"required"`
	TargetPort   int        `json:"target_port" binding:"required,min=1,max=65535"`
	UserID       *uint      `json:"user_id"`
	UserGroupID  *uint      `json:"user_group_id"`
	SpeedLimit   *int64     `json:"speed_limit"`
	TrafficLimit *int64     `json:"traffic_limit"`
	ExpireTime   *time.Time `json:"expire_time"`
	Remark       string     `json:"remark"`
}

CreateRuleRequest 创建规则请求

type CreateTaskRequest

type CreateTaskRequest struct {
	NodeID  uint           `json:"node_id" binding:"required"`
	Type    string         `json:"type" binding:"required"`
	Action  string         `json:"action" binding:"required"`
	Params  map[string]any `json:"params"`
	Timeout int            `json:"timeout"`
}

CreateTaskRequest 创建任务请求

type DeltaData

type DeltaData struct {
	Overview    *MonitorOverview `json:"overview,omitempty"`
	NodeUpdates []NodeDelta      `json:"node_updates"`
}

DeltaData 增量数据

type ExecuteCommandRequest

type ExecuteCommandRequest struct {
	NodeID  uint           `json:"node_id" binding:"required"`
	Action  string         `json:"action" binding:"required"`
	Params  map[string]any `json:"params"`
	Timeout int            `json:"timeout"`
}

ExecuteCommandRequest 白名单诊断动作请求

type ForwardCleanAgentHandler

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

func NewForwardCleanAgentHandler

func NewForwardCleanAgentHandler() *ForwardCleanAgentHandler

func (*ForwardCleanAgentHandler) CreateAgentToken

func (h *ForwardCleanAgentHandler) CreateAgentToken(c *gin.Context)

func (*ForwardCleanAgentHandler) Heartbeat

func (h *ForwardCleanAgentHandler) Heartbeat(c *gin.Context)

func (*ForwardCleanAgentHandler) InstallScript

func (h *ForwardCleanAgentHandler) InstallScript(c *gin.Context)

func (*ForwardCleanAgentHandler) ListAgents

func (h *ForwardCleanAgentHandler) ListAgents(c *gin.Context)

func (*ForwardCleanAgentHandler) Register

func (h *ForwardCleanAgentHandler) Register(c *gin.Context)

func (*ForwardCleanAgentHandler) Report

func (h *ForwardCleanAgentHandler) Report(c *gin.Context)

func (*ForwardCleanAgentHandler) RevokeAgent

func (h *ForwardCleanAgentHandler) RevokeAgent(c *gin.Context)

type ForwardHandler

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

ForwardHandler 转发处理器

func NewForwardHandler

func NewForwardHandler() *ForwardHandler

NewForwardHandler 创建处理器

func (*ForwardHandler) AssignPanelUserTunnel

func (h *ForwardHandler) AssignPanelUserTunnel(c *gin.Context)

func (*ForwardHandler) CheckAnsibleMachine

func (h *ForwardHandler) CheckAnsibleMachine(c *gin.Context)

func (*ForwardHandler) CheckNode

func (h *ForwardHandler) CheckNode(c *gin.Context)

CheckNode godoc @Summary 健康检查节点 @Description 管理员对指定中转节点进行健康检查 @Tags 管理端-转发 @Accept json @Produce json @Security BearerAuth @Param id path int true "节点ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/forward/nodes/{id}/check [post]

func (*ForwardHandler) CreateAnsibleMachine

func (h *ForwardHandler) CreateAnsibleMachine(c *gin.Context)

func (*ForwardHandler) CreateNode

func (h *ForwardHandler) CreateNode(c *gin.Context)

CreateNode godoc @Summary 创建中转节点 @Description 管理员创建新的中转节点 @Tags 管理端-转发 @Accept json @Produce json @Security BearerAuth @Param request body CreateNodeRequest true "节点信息" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/forward/nodes [post]

func (*ForwardHandler) CreatePanelForward

func (h *ForwardHandler) CreatePanelForward(c *gin.Context)

func (*ForwardHandler) CreatePanelTunnel

func (h *ForwardHandler) CreatePanelTunnel(c *gin.Context)

func (*ForwardHandler) CreateRule

func (h *ForwardHandler) CreateRule(c *gin.Context)

CreateRule godoc @Summary 创建转发规则 @Description 管理员创建新的转发规则 @Tags 管理端-转发 @Accept json @Produce json @Security BearerAuth @Param request body CreateRuleRequest true "规则信息" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/forward/rules [post]

func (*ForwardHandler) CreateUserRule

func (h *ForwardHandler) CreateUserRule(c *gin.Context)

CreateUserRule godoc @Summary 管理员创建自己的旧版转发规则 @Description 旧版转发规则只能由管理员创建或修改:规则直接运行在所选中转和落地节点上,用户的隧道权限不覆盖它们。普通用户收到错误,应通过已授权的隧道创建转发 (/forward/create)。 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Param request body service.CreateRuleRequest true "规则信息" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Router /user/forward/rules [post]

func (*ForwardHandler) DeleteAnsibleMachine

func (h *ForwardHandler) DeleteAnsibleMachine(c *gin.Context)

func (*ForwardHandler) DeleteNode

func (h *ForwardHandler) DeleteNode(c *gin.Context)

DeleteNode godoc @Summary 删除中转节点 @Description 管理员删除指定中转节点 @Tags 管理端-转发 @Accept json @Produce json @Security BearerAuth @Param id path int true "节点ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/forward/nodes/{id} [delete]

func (*ForwardHandler) DeletePanelForward

func (h *ForwardHandler) DeletePanelForward(c *gin.Context)

func (*ForwardHandler) DeletePanelTunnel

func (h *ForwardHandler) DeletePanelTunnel(c *gin.Context)

func (*ForwardHandler) DeleteRule

func (h *ForwardHandler) DeleteRule(c *gin.Context)

DeleteRule godoc @Summary 删除转发规则 @Description 管理员删除指定转发规则 @Tags 管理端-转发 @Accept json @Produce json @Security BearerAuth @Param id path int true "规则ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/forward/rules/{id} [delete]

func (*ForwardHandler) DiagnoseLocalRuntime

func (h *ForwardHandler) DiagnoseLocalRuntime(c *gin.Context)

func (*ForwardHandler) DiagnoseNodeXRuntime

func (h *ForwardHandler) DiagnoseNodeXRuntime(c *gin.Context)

func (*ForwardHandler) DiagnosePanelForward

func (h *ForwardHandler) DiagnosePanelForward(c *gin.Context)

func (*ForwardHandler) DiagnosePanelRuntime

func (h *ForwardHandler) DiagnosePanelRuntime(c *gin.Context)

func (*ForwardHandler) DiagnosePanelTunnel

func (h *ForwardHandler) DiagnosePanelTunnel(c *gin.Context)

func (*ForwardHandler) ForceDeletePanelForward

func (h *ForwardHandler) ForceDeletePanelForward(c *gin.Context)

func (*ForwardHandler) GetAnsibleMachine

func (h *ForwardHandler) GetAnsibleMachine(c *gin.Context)

func (*ForwardHandler) GetForwardStats

func (h *ForwardHandler) GetForwardStats(c *gin.Context)

GetForwardStats godoc @Summary 获取转发统计 @Description 管理员获取转发统计数据,包括节点数、在线数、流量等 @Tags 管理端-转发 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Router /admin/forward/stats [get]

func (*ForwardHandler) GetLocalRuntimeStatus

func (h *ForwardHandler) GetLocalRuntimeStatus(c *gin.Context)

func (*ForwardHandler) GetNode

func (h *ForwardHandler) GetNode(c *gin.Context)

GetNode godoc @Summary 获取中转节点详情 @Description 管理员获取指定中转节点的详细信息 @Tags 管理端-转发 @Accept json @Produce json @Security BearerAuth @Param id path int true "节点ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 404 {object} map[string]any @Router /admin/forward/nodes/{id} [get]

func (*ForwardHandler) GetNodeXRuntimeStatus

func (h *ForwardHandler) GetNodeXRuntimeStatus(c *gin.Context)

func (*ForwardHandler) GetObservabilityMultiIngress

func (h *ForwardHandler) GetObservabilityMultiIngress(c *gin.Context)

GetObservabilityMultiIngress GET /admin/forward/observability/multi-ingress?targetId=

func (*ForwardHandler) GetObservabilityTopology

func (h *ForwardHandler) GetObservabilityTopology(c *gin.Context)

GetObservabilityTopology GET /admin/forward/observability/topology

func (*ForwardHandler) GetObservabilityTrend

func (h *ForwardHandler) GetObservabilityTrend(c *gin.Context)

GetObservabilityTrend GET /admin/forward/observability/trend?targetKey=&from=&to=

func (*ForwardHandler) GetPanelRuntimeStatus

func (h *ForwardHandler) GetPanelRuntimeStatus(c *gin.Context)

func (*ForwardHandler) GetRule

func (h *ForwardHandler) GetRule(c *gin.Context)

GetRule godoc @Summary 获取转发规则详情 @Description 管理员获取指定转发规则的详细信息 @Tags 管理端-转发 @Accept json @Produce json @Security BearerAuth @Param id path int true "规则ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 404 {object} map[string]any @Router /admin/forward/rules/{id} [get]

func (*ForwardHandler) GetUserRules

func (h *ForwardHandler) GetUserRules(c *gin.Context)

GetUserRules godoc @Summary 获取用户的转发规则 @Description 用户获取自己的转发规则列表 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /user/forward/rules [get]

func (*ForwardHandler) ListAnsibleMachines

func (h *ForwardHandler) ListAnsibleMachines(c *gin.Context)

func (*ForwardHandler) ListNodes

func (h *ForwardHandler) ListNodes(c *gin.Context)

ListNodes godoc @Summary 获取中转节点列表 @Description 管理员获取中转节点列表,支持分页和类型筛选 @Tags 管理端-转发 @Accept json @Produce json @Security BearerAuth @Param type query string false "节点类型 (relay/exit)" @Param page query int false "页码" default(1) @Param page_size query int false "每页数量" default(20) @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/forward/nodes [get]

func (*ForwardHandler) ListObservabilityTargets

func (h *ForwardHandler) ListObservabilityTargets(c *gin.Context)

ListObservabilityTargets GET /admin/forward/observability/targets

func (*ForwardHandler) ListPanelAdminTunnels

func (h *ForwardHandler) ListPanelAdminTunnels(c *gin.Context)

func (*ForwardHandler) ListPanelForwards

func (h *ForwardHandler) ListPanelForwards(c *gin.Context)

func (*ForwardHandler) ListPanelRuntimeJobs

func (h *ForwardHandler) ListPanelRuntimeJobs(c *gin.Context)

func (*ForwardHandler) ListPanelTunnels

func (h *ForwardHandler) ListPanelTunnels(c *gin.Context)

func (*ForwardHandler) ListPanelUserTunnels

func (h *ForwardHandler) ListPanelUserTunnels(c *gin.Context)

func (*ForwardHandler) ListRules

func (h *ForwardHandler) ListRules(c *gin.Context)

ListRules godoc @Summary 获取转发规则列表 @Description 管理员获取转发规则列表,支持分页和用户筛选 @Tags 管理端-转发 @Accept json @Produce json @Security BearerAuth @Param page query int false "页码" default(1) @Param page_size query int false "每页数量" default(20) @Param user_id query int false "用户ID" @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/forward/rules [get]

func (*ForwardHandler) PausePanelForward

func (h *ForwardHandler) PausePanelForward(c *gin.Context)

func (*ForwardHandler) RemovePanelUserTunnel

func (h *ForwardHandler) RemovePanelUserTunnel(c *gin.Context)

func (*ForwardHandler) ReportPanelForwardTraffic

func (h *ForwardHandler) ReportPanelForwardTraffic(c *gin.Context)

func (*ForwardHandler) ResumePanelForward

func (h *ForwardHandler) ResumePanelForward(c *gin.Context)

func (*ForwardHandler) SnapshotPanelForwardTraffic

func (h *ForwardHandler) SnapshotPanelForwardTraffic(c *gin.Context)

func (*ForwardHandler) SyncAnsibleMachineStats

func (h *ForwardHandler) SyncAnsibleMachineStats(c *gin.Context)

func (*ForwardHandler) SyncForwardsToBackend

func (h *ForwardHandler) SyncForwardsToBackend(c *gin.Context)

func (*ForwardHandler) SyncNodeStats

func (h *ForwardHandler) SyncNodeStats(c *gin.Context)

SyncNodeStats godoc @Summary 同步节点统计数据 @Description 从 gost 节点同步流量和连接统计数据到面板 @Tags 管理端-转发 @Accept json @Produce json @Security BearerAuth @Param id path int true "节点ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Router /admin/forward/nodes/{id}/sync-stats [post]

func (*ForwardHandler) TestGostConnection

func (h *ForwardHandler) TestGostConnection(c *gin.Context)

TestGostConnection godoc @Summary 测试 gost 节点连接 @Description 测试与 gost 节点的 API 连接是否正常 @Tags 管理端-转发 @Accept json @Produce json @Security BearerAuth @Param request body TestGostConnectionRequest true "连接信息" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Router /admin/forward/test-connection [post]

func (*ForwardHandler) ToggleAnsibleMachine

func (h *ForwardHandler) ToggleAnsibleMachine(c *gin.Context)

func (*ForwardHandler) ToggleNode

func (h *ForwardHandler) ToggleNode(c *gin.Context)

ToggleNode godoc @Summary 切换节点状态 @Description 管理员启用或禁用指定中转节点 @Tags 管理端-转发 @Accept json @Produce json @Security BearerAuth @Param id path int true "节点ID" @Param request body ToggleRequest true "状态请求" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 404 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/forward/nodes/{id}/toggle [post]

func (*ForwardHandler) ToggleRule

func (h *ForwardHandler) ToggleRule(c *gin.Context)

ToggleRule godoc @Summary 切换规则状态 @Description 管理员启用或禁用指定转发规则 @Tags 管理端-转发 @Accept json @Produce json @Security BearerAuth @Param id path int true "规则ID" @Param request body ToggleRequest true "状态请求" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/forward/rules/{id}/toggle [post]

func (*ForwardHandler) UpdateAnsibleMachine

func (h *ForwardHandler) UpdateAnsibleMachine(c *gin.Context)

func (*ForwardHandler) UpdateNode

func (h *ForwardHandler) UpdateNode(c *gin.Context)

UpdateNode godoc @Summary 更新中转节点 @Description 管理员更新指定中转节点的信息 @Tags 管理端-转发 @Accept json @Produce json @Security BearerAuth @Param id path int true "节点ID" @Param request body UpdateNodeRequest true "节点更新信息" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 404 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/forward/nodes/{id} [put]

func (*ForwardHandler) UpdatePanelForward

func (h *ForwardHandler) UpdatePanelForward(c *gin.Context)

func (*ForwardHandler) UpdatePanelForwardOrder

func (h *ForwardHandler) UpdatePanelForwardOrder(c *gin.Context)

func (*ForwardHandler) UpdatePanelTunnel

func (h *ForwardHandler) UpdatePanelTunnel(c *gin.Context)

func (*ForwardHandler) UpdatePanelUserTunnel

func (h *ForwardHandler) UpdatePanelUserTunnel(c *gin.Context)

func (*ForwardHandler) UpdateRule

func (h *ForwardHandler) UpdateRule(c *gin.Context)

UpdateRule godoc @Summary 更新转发规则 @Description 管理员更新指定转发规则的信息 @Tags 管理端-转发 @Accept json @Produce json @Security BearerAuth @Param id path int true "规则ID" @Param request body UpdateRuleRequest true "规则更新信息" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 404 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/forward/rules/{id} [put]

func (*ForwardHandler) UploadPanelFlowData

func (h *ForwardHandler) UploadPanelFlowData(c *gin.Context)

type ForwardRuleForAgent

type ForwardRuleForAgent struct {
	ID         uint   `json:"id"`
	Enabled    bool   `json:"enabled"`
	ListenPort int    `json:"listen_port"`
	Protocol   string `json:"protocol"`
	TargetHost string `json:"target_host"`
	TargetPort int    `json:"target_port"`
}

ForwardRuleForAgent 转发规则(Agent 格式)

type InviteCodeAdminHandler added in v4.1.0

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

InviteCodeAdminHandler serves the administrator's invite codes (registration control): list, generate and revoke. identity-platform declares the routes and the identity bridge relays them here, in every edition; commissions, withdrawals and invite statistics stay in the affiliate package (InviteHandler).

func NewInviteCodeAdminHandler added in v4.1.0

func NewInviteCodeAdminHandler() *InviteCodeAdminHandler

NewInviteCodeAdminHandler returns the handler on the kernel database.

func (*InviteCodeAdminHandler) GenerateCodes added in v4.1.0

func (h *InviteCodeAdminHandler) GenerateCodes(c *gin.Context)

GenerateCodes godoc @Summary Generate invite codes @Description Generates 1 to 50 codes that belong to no user. expire_days overrides the configured expiry (0: never). @Tags admin-invite-codes @Accept json @Produce json @Security BearerAuth @Param request body map[string]any false "{count, expire_days}" @Success 200 {object} map[string]any @Router /admin/invite/codes [post]

func (*InviteCodeAdminHandler) ListCodes added in v4.1.0

func (h *InviteCodeAdminHandler) ListCodes(c *gin.Context)

ListCodes godoc @Summary List invite codes @Description Every invite code, newest first; status filters unused, used or expired codes. @Tags admin-invite-codes @Produce json @Security BearerAuth @Param status query string false "unused, used or expired" @Param page query int false "page" default(1) @Param page_size query int false "page size" default(20) @Success 200 {object} map[string]any @Router /admin/invite/codes [get]

func (*InviteCodeAdminHandler) RevokeCode added in v4.1.0

func (h *InviteCodeAdminHandler) RevokeCode(c *gin.Context)

RevokeCode godoc @Summary Revoke an invite code @Description Deletes an unused invite code; a used code is kept. @Tags admin-invite-codes @Produce json @Security BearerAuth @Param id path int true "invite code id" @Success 200 {object} map[string]any @Router /admin/invite/codes/{id} [delete]

type InviteHandler

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

InviteHandler 邀请处理器

func NewInviteHandler

func NewInviteHandler() *InviteHandler

NewInviteHandler 创建处理器

func (*InviteHandler) GenerateCode

func (h *InviteHandler) GenerateCode(c *gin.Context)

GenerateCode godoc @Summary 生成邀请码 @Description 用户生成新的邀请码 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /user/invite/generate [post]

func (*InviteHandler) GetCommissionRecords

func (h *InviteHandler) GetCommissionRecords(c *gin.Context)

GetCommissionRecords godoc @Summary 获取佣金记录 @Description 用户获取自己的佣金记录列表 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Param page query int false "页码" default(1) @Param page_size query int false "每页数量" default(20) @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /user/invite/commissions [get]

func (*InviteHandler) GetConfig

func (h *InviteHandler) GetConfig(c *gin.Context)

GetConfig godoc @Summary 获取邀请配置 @Description 管理员获取邀请系统配置 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/invite/config [get]

func (*InviteHandler) GetInviteInfo

func (h *InviteHandler) GetInviteInfo(c *gin.Context)

GetInviteInfo godoc @Summary 获取邀请信息 @Description 用户获取自己的邀请码和佣金信息 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /user/invite [get]

func (*InviteHandler) GetInviteStats

func (h *InviteHandler) GetInviteStats(c *gin.Context)

GetInviteStats godoc @Summary 获取邀请统计 @Description 管理员获取邀请系统统计数据 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Router /admin/invite/stats [get]

func (*InviteHandler) GetWithdrawRecords

func (h *InviteHandler) GetWithdrawRecords(c *gin.Context)

GetWithdrawRecords godoc @Summary 获取提现记录 @Description 用户获取自己的提现记录列表 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Param page query int false "页码" default(1) @Param page_size query int false "每页数量" default(20) @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /user/invite/withdrawals [get]

func (*InviteHandler) GetWithdrawals

func (h *InviteHandler) GetWithdrawals(c *gin.Context)

GetWithdrawals godoc @Summary 获取提现申请列表 @Description 管理员获取提现申请列表 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Param status query string false "Status filter" @Param page query int false "页码" default(1) @Param page_size query int false "每页数量" default(20) @Success 200 {object} map[string]any @Router /admin/invite/withdrawals [get]

func (*InviteHandler) ProcessWithdraw

func (h *InviteHandler) ProcessWithdraw(c *gin.Context)

ProcessWithdraw godoc @Summary 处理提现申请 @Description 管理员处理提现申请,批准或拒绝 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Param id path int true "提现记录ID" @Param request body map[string]any true "处理请求 {status, remark}" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 404 {object} map[string]any @Router /admin/invite/withdrawals/{id}/process [post]

func (*InviteHandler) RequestWithdraw

func (h *InviteHandler) RequestWithdraw(c *gin.Context)

RequestWithdraw godoc @Summary 申请提现 @Description 用户申请佣金提现 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Param request body map[string]any true "提现请求 {amount, method, account, name}" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Router /user/invite/withdraw [post]

func (*InviteHandler) UpdateConfig

func (h *InviteHandler) UpdateConfig(c *gin.Context)

UpdateConfig godoc @Summary 更新邀请配置 @Description 管理员更新邀请系统配置 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Param request body model.InviteConfig true "Invite configuration" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/invite/config [put]

type KernelHandler

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

func NewKernelHandler

func NewKernelHandler() *KernelHandler

func (*KernelHandler) AddGroupPlan

func (h *KernelHandler) AddGroupPlan(c *gin.Context)

func (*KernelHandler) AddGroupUser

func (h *KernelHandler) AddGroupUser(c *gin.Context)

func (*KernelHandler) ApplyDeployment

func (h *KernelHandler) ApplyDeployment(c *gin.Context)

func (*KernelHandler) CancelOperation

func (h *KernelHandler) CancelOperation(c *gin.Context)

func (*KernelHandler) CreateAccessGroup

func (h *KernelHandler) CreateAccessGroup(c *gin.Context)

func (*KernelHandler) CreateOperation

func (h *KernelHandler) CreateOperation(c *gin.Context)

func (*KernelHandler) CreateResourceGrant

func (h *KernelHandler) CreateResourceGrant(c *gin.Context)

func (*KernelHandler) CreateTopology

func (h *KernelHandler) CreateTopology(c *gin.Context)

func (*KernelHandler) CreateTopologyRevision

func (h *KernelHandler) CreateTopologyRevision(c *gin.Context)

func (*KernelHandler) DeleteAccessGroup

func (h *KernelHandler) DeleteAccessGroup(c *gin.Context)

func (*KernelHandler) DeleteAssignment

func (h *KernelHandler) DeleteAssignment(c *gin.Context)

func (*KernelHandler) DeleteQuotaPolicy

func (h *KernelHandler) DeleteQuotaPolicy(c *gin.Context)

func (*KernelHandler) DeleteResourceGrant

func (h *KernelHandler) DeleteResourceGrant(c *gin.Context)

func (*KernelHandler) DiagnoseTopologyDeployment

func (h *KernelHandler) DiagnoseTopologyDeployment(c *gin.Context)

DiagnoseTopologyDeployment is a semantic alias retained for clients that use the contract's diagnose naming. Both endpoints are strictly read-only.

func (*KernelHandler) GetAccessGroupDetail

func (h *KernelHandler) GetAccessGroupDetail(c *gin.Context)

GetAccessGroupDetail returns the associated identities and policy records needed to safely administer one access group. The underlying models stay normalized so the allow-union resolver remains the single authorization implementation rather than a client-side reconstruction.

func (*KernelHandler) GetDeploymentStatus

func (h *KernelHandler) GetDeploymentStatus(c *gin.Context)

func (*KernelHandler) GetPluginInstallationConfiguration

func (h *KernelHandler) GetPluginInstallationConfiguration(c *gin.Context)

func (*KernelHandler) GetPluginReleaseArtifact

func (h *KernelHandler) GetPluginReleaseArtifact(c *gin.Context)

func (*KernelHandler) GetTopologyRevision

func (h *KernelHandler) GetTopologyRevision(c *gin.Context)

func (*KernelHandler) ListAccessGroups

func (h *KernelHandler) ListAccessGroups(c *gin.Context)

func (*KernelHandler) ListAssignments

func (h *KernelHandler) ListAssignments(c *gin.Context)

func (*KernelHandler) ListDeployments

func (h *KernelHandler) ListDeployments(c *gin.Context)

func (*KernelHandler) ListExtensions

func (h *KernelHandler) ListExtensions(c *gin.Context)

func (*KernelHandler) ListObservedStates

func (h *KernelHandler) ListObservedStates(c *gin.Context)

func (*KernelHandler) ListOperations

func (h *KernelHandler) ListOperations(c *gin.Context)

func (*KernelHandler) ListPluginInstallations

func (h *KernelHandler) ListPluginInstallations(c *gin.Context)

func (*KernelHandler) ListPluginReleases

func (h *KernelHandler) ListPluginReleases(c *gin.Context)

func (*KernelHandler) ListPlugins

func (h *KernelHandler) ListPlugins(c *gin.Context)

func (*KernelHandler) ListQuotaPolicies

func (h *KernelHandler) ListQuotaPolicies(c *gin.Context)

func (*KernelHandler) ListResourceGrants

func (h *KernelHandler) ListResourceGrants(c *gin.Context)

func (*KernelHandler) ListServiceScopes

func (h *KernelHandler) ListServiceScopes(c *gin.Context)

func (*KernelHandler) ListTopologies

func (h *KernelHandler) ListTopologies(c *gin.Context)

func (*KernelHandler) ListTopologyRevisions

func (h *KernelHandler) ListTopologyRevisions(c *gin.Context)

func (*KernelHandler) PlanDeployment

func (h *KernelHandler) PlanDeployment(c *gin.Context)

func (*KernelHandler) PluginInstallationAction

func (h *KernelHandler) PluginInstallationAction(c *gin.Context)

func (*KernelHandler) PluginRouteGateway

func (h *KernelHandler) PluginRouteGateway(c *gin.Context)

func (*KernelHandler) PreviewDeployment

func (h *KernelHandler) PreviewDeployment(c *gin.Context)

PreviewDeployment is the body-addressed variant used by automation that has not yet selected a nested topology route.

func (*KernelHandler) PreviewTopologyDeployment

func (h *KernelHandler) PreviewTopologyDeployment(c *gin.Context)

PreviewTopologyDeployment runs the read-only topology preflight. It returns HTTP 200 with valid=false and structured issues for an invalid graph so the editor can render all problems in one request; only missing database rows are transport errors.

func (*KernelHandler) RegisterPluginRelease

func (h *KernelHandler) RegisterPluginRelease(c *gin.Context)

func (*KernelHandler) RemoveGroupPlan

func (h *KernelHandler) RemoveGroupPlan(c *gin.Context)

func (*KernelHandler) RemoveGroupUser

func (h *KernelHandler) RemoveGroupUser(c *gin.Context)

func (*KernelHandler) ResolveAccess

func (h *KernelHandler) ResolveAccess(c *gin.Context)

func (*KernelHandler) RollbackDeployment

func (h *KernelHandler) RollbackDeployment(c *gin.Context)

func (*KernelHandler) ServeAgentPluginArtifact

func (h *KernelHandler) ServeAgentPluginArtifact(c *gin.Context)

func (*KernelHandler) ServeAgentPluginManifest

func (h *KernelHandler) ServeAgentPluginManifest(c *gin.Context)

func (*KernelHandler) ServePluginWebUIAsset

func (h *KernelHandler) ServePluginWebUIAsset(c *gin.Context)

func (*KernelHandler) UpdateAccessGroup

func (h *KernelHandler) UpdateAccessGroup(c *gin.Context)

func (*KernelHandler) UpdatePluginInstallationConfiguration

func (h *KernelHandler) UpdatePluginInstallationConfiguration(c *gin.Context)

func (*KernelHandler) UploadPluginReleaseArtifact

func (h *KernelHandler) UploadPluginReleaseArtifact(c *gin.Context)

func (*KernelHandler) UpsertAssignment

func (h *KernelHandler) UpsertAssignment(c *gin.Context)

func (*KernelHandler) UpsertPluginInstallation

func (h *KernelHandler) UpsertPluginInstallation(c *gin.Context)

func (*KernelHandler) UpsertQuotaPolicy

func (h *KernelHandler) UpsertQuotaPolicy(c *gin.Context)

func (*KernelHandler) ValidateTopology

func (h *KernelHandler) ValidateTopology(c *gin.Context)

type KernelNodeOperationsHandler added in v4.1.0

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

KernelNodeOperationsHandler lists the KernelNodeOps ledger for administrators (docs/architecture/node-ops-service.md section 3.9). It is read-only.

func NewKernelNodeOperationsHandler added in v4.1.0

func NewKernelNodeOperationsHandler() *KernelNodeOperationsHandler

NewKernelNodeOperationsHandler reads the kernel database.

func (*KernelNodeOperationsHandler) List added in v4.1.0

List answers GET /api/v4/kernel/node-operations: every package's node operations, newest first, filtered by package_id, family, kind, state, request_id, operation_id, parent_operation_id, or target_kind with target_id, and paged by before (a cursor) and limit (at most 500).

type KnowledgeHandler

type KnowledgeHandler struct{}

KnowledgeHandler 用户端知识库处理器

func NewKnowledgeHandler

func NewKnowledgeHandler() *KnowledgeHandler

NewKnowledgeHandler 创建知识库处理器

func (*KnowledgeHandler) GetArticle

func (h *KnowledgeHandler) GetArticle(c *gin.Context)

GetArticle 获取单篇文章详情

func (*KnowledgeHandler) GetArticles

func (h *KnowledgeHandler) GetArticles(c *gin.Context)

GetArticles 获取文章列表 (仅可见且按排序)

type LoadBalancerHandler

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

LoadBalancerHandler 负载均衡处理器

func NewLoadBalancerHandler

func NewLoadBalancerHandler() *LoadBalancerHandler

NewLoadBalancerHandler 创建处理器

func (*LoadBalancerHandler) CreateLoadBalancer

func (h *LoadBalancerHandler) CreateLoadBalancer(c *gin.Context)

CreateLoadBalancer godoc @Summary 创建负载均衡器 @Description 管理员创建新的负载均衡器 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Param request body model.LoadBalancer true "负载均衡器配置" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/loadbalancers [post]

func (*LoadBalancerHandler) DeleteLoadBalancer

func (h *LoadBalancerHandler) DeleteLoadBalancer(c *gin.Context)

DeleteLoadBalancer godoc @Summary 删除负载均衡器 @Description 管理员删除指定负载均衡器 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Param id path int true "负载均衡器ID" @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/loadbalancers/{id} [delete]

func (*LoadBalancerHandler) GetLoadBalancer

func (h *LoadBalancerHandler) GetLoadBalancer(c *gin.Context)

GetLoadBalancer godoc @Summary 获取负载均衡器详情 @Description 管理员获取指定负载均衡器的详细信息 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Param id path int true "负载均衡器ID" @Success 200 {object} map[string]any @Failure 404 {object} map[string]any @Router /admin/loadbalancers/{id} [get]

func (*LoadBalancerHandler) GetLoadBalancerStats

func (h *LoadBalancerHandler) GetLoadBalancerStats(c *gin.Context)

GetLoadBalancerStats godoc @Summary 获取负载均衡统计 @Description 管理员获取指定负载均衡器的统计数据 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Param id path int true "负载均衡器ID" @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/loadbalancers/{id}/stats [get]

func (*LoadBalancerHandler) ListLoadBalancers

func (h *LoadBalancerHandler) ListLoadBalancers(c *gin.Context)

ListLoadBalancers godoc @Summary 获取负载均衡器列表 @Description 管理员获取负载均衡器列表 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Param group_id query int false "分组ID" @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/loadbalancers [get]

func (*LoadBalancerHandler) RunHealthCheck

func (h *LoadBalancerHandler) RunHealthCheck(c *gin.Context)

RunHealthCheck godoc @Summary 执行健康检查 @Description 管理员对指定负载均衡器执行健康检查 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Param id path int true "负载均衡器ID" @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/loadbalancers/{id}/check [post]

func (*LoadBalancerHandler) UpdateLoadBalancer

func (h *LoadBalancerHandler) UpdateLoadBalancer(c *gin.Context)

UpdateLoadBalancer godoc @Summary 更新负载均衡器 @Description 管理员更新指定负载均衡器的配置 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Param id path int true "负载均衡器ID" @Param request body model.LoadBalancer true "负载均衡器配置" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 404 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/loadbalancers/{id} [put]

type MFAHandler

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

MFAHandler handles user and admin MFA endpoints.

func NewMFAHandler

func NewMFAHandler() *MFAHandler

NewMFAHandler creates MFA handler.

func (*MFAHandler) DisableMFA

func (h *MFAHandler) DisableMFA(c *gin.Context)

DisableMFA disables MFA with password confirmation.

func (*MFAHandler) EnableTOTP

func (h *MFAHandler) EnableTOTP(c *gin.Context)

EnableTOTP enables TOTP with verification code.

func (*MFAHandler) GetAdminConfig

func (h *MFAHandler) GetAdminConfig(c *gin.Context)

GetAdminConfig returns global MFA admin config.

func (*MFAHandler) GetStatus

func (h *MFAHandler) GetStatus(c *gin.Context)

GetStatus gets MFA status for current user.

func (*MFAHandler) RegenerateBackupCodes

func (h *MFAHandler) RegenerateBackupCodes(c *gin.Context)

RegenerateBackupCodes regenerates backup codes for current user.

func (*MFAHandler) SetupTOTP

func (h *MFAHandler) SetupTOTP(c *gin.Context)

SetupTOTP sets up TOTP for current user.

func (*MFAHandler) UpdateAdminConfig

func (h *MFAHandler) UpdateAdminConfig(c *gin.Context)

UpdateAdminConfig updates and persists MFA admin config.

func (*MFAHandler) VerifyMFA

func (h *MFAHandler) VerifyMFA(c *gin.Context)

VerifyMFA verifies MFA code.

type MetricsHandler

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

MetricsHandler Prometheus 指标处理器

func NewMetricsHandler

func NewMetricsHandler() *MetricsHandler

NewMetricsHandler 创建指标处理器

func (*MetricsHandler) GetMetrics

func (h *MetricsHandler) GetMetrics(c *gin.Context)

GetMetrics godoc @Summary Prometheus 指标 @Description 获取 Prometheus 格式的系统指标 @Tags 系统 @Produce plain @Success 200 {string} string "Prometheus metrics" @Router /metrics [get]

func (*MetricsHandler) RecordRequest

func (h *MetricsHandler) RecordRequest(success bool)

RecordRequest 记录请求

type ModuleHandler added in v4.1.0

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

ModuleHandler administers the module PKI: enrollment credentials for network modules and CA rotation. Routes sit behind admin authentication and the audit log.

func NewModuleHandler added in v4.1.0

func NewModuleHandler() *ModuleHandler

NewModuleHandler builds the authority from the loaded configuration on each request, so the handler follows configuration reloads in tests.

func (*ModuleHandler) CreateEnrollment added in v4.1.0

func (h *ModuleHandler) CreateEnrollment(c *gin.Context)

CreateEnrollment issues an enrollment credential for a module.

func (*ModuleHandler) ListEnrollments added in v4.1.0

func (h *ModuleHandler) ListEnrollments(c *gin.Context)

ListEnrollments lists enrollment credentials without their secrets.

func (*ModuleHandler) ListRuntimes added in v4.1.0

func (h *ModuleHandler) ListRuntimes(c *gin.Context)

ListRuntimes lists the packages whose runtime was chosen explicitly; all others run locally.

func (*ModuleHandler) RevokeEnrollment added in v4.1.0

func (h *ModuleHandler) RevokeEnrollment(c *gin.Context)

RevokeEnrollment revokes a credential and the certificates issued with it.

func (*ModuleHandler) RotateCA added in v4.1.0

func (h *ModuleHandler) RotateCA(c *gin.Context)

RotateCA creates the next module CA; it signs after one certificate lifetime.

func (*ModuleHandler) SetRuntime added in v4.1.0

func (h *ModuleHandler) SetRuntime(c *gin.Context)

SetRuntime selects local or remote for a package. It applies at the package's next lifecycle operation.

func (*ModuleHandler) TrustBundle added in v4.1.0

func (h *ModuleHandler) TrustBundle(c *gin.Context)

TrustBundle returns the module CA bundle as PEM for module deployments.

type MonitorOverview

type MonitorOverview struct {
	TotalNodes    int64 `json:"total_nodes"`
	OnlineNodes   int64 `json:"online_nodes"`
	OfflineNodes  int64 `json:"offline_nodes"`
	PendingNodes  int64 `json:"pending_nodes"`
	TotalUpload   int64 `json:"total_upload"`
	TotalDownload int64 `json:"total_download"`
}

MonitorOverview 监控概览

type MonitorSnapshot

type MonitorSnapshot struct {
	Overview MonitorOverview `json:"overview"`
	Nodes    []NodeSnapshot  `json:"nodes"`
}

MonitorSnapshot 初始快照

type MonitorWSHandler

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

MonitorWSHandler 处理 WebSocket 监控连接

func NewMonitorWSHandler

func NewMonitorWSHandler() *MonitorWSHandler

NewMonitorWSHandler 创建 WebSocket 监控处理器

func (*MonitorWSHandler) HandleMonitorWS

func (h *MonitorWSHandler) HandleMonitorWS(c *gin.Context)

HandleMonitorWS 处理 WebSocket 监控连接 @Summary WebSocket 实时监控 @Description 实时推送节点监控数据 @Tags 管理端-WebSocket @Produce json @Security BearerAuth @Success 101 @Router /admin/ws/monitor [get]

type MonitorWSMessage

type MonitorWSMessage struct {
	Type      string `json:"type"`
	Timestamp int64  `json:"timestamp"`
	Data      any    `json:"data,omitempty"`
	Error     string `json:"error,omitempty"`
}

MonitorWSMessage WebSocket 监控消息

type Node

type Node struct{}

func (Node) TableName

func (Node) TableName() string

type NodeDelta

type NodeDelta struct {
	ID            uint     `json:"id"`
	Name          string   `json:"name"`
	Status        string   `json:"status,omitempty"`
	CPUUsage      float64  `json:"cpu_usage,omitempty"`
	MemoryUsage   float64  `json:"memory_usage,omitempty"`
	DiskUsage     float64  `json:"disk_usage,omitempty"`
	OnlineUsers   int      `json:"online_users,omitempty"`
	TotalUpload   int64    `json:"total_upload,omitempty"`
	TotalDownload int64    `json:"total_download,omitempty"`
	Uptime        int64    `json:"uptime,omitempty"`
	ChangedFields []string `json:"changed_fields"`
}

NodeDelta 节点变化

type NodeHandler

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

NodeHandler 节点处理器

func NewNodeHandler

func NewNodeHandler() *NodeHandler

NewNodeHandler 创建节点处理器

func (*NodeHandler) CreateNode

func (h *NodeHandler) CreateNode(c *gin.Context)

CreateNode godoc @Summary 创建节点 @Description 管理员手动创建节点 @Tags 管理端-节点 @Accept json @Produce json @Security BearerAuth @Param request body model.Node true "节点信息" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/nodes [post]

func (*NodeHandler) CreateProtocol

func (h *NodeHandler) CreateProtocol(c *gin.Context)

CreateProtocol godoc @Summary 创建节点协议 @Description 管理员为指定节点创建协议配置 @Tags 管理端-节点 @Accept json @Produce json @Security BearerAuth @Param id path int true "节点ID" @Param request body model.NodeProtocol true "协议配置" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/nodes/{id}/protocols [post]

func (*NodeHandler) DeleteAuthKey

func (h *NodeHandler) DeleteAuthKey(c *gin.Context)

DeleteAuthKey godoc @Summary 删除授权密钥 @Description 管理员删除指定的授权密钥 @Tags 管理端-节点 @Accept json @Produce json @Security BearerAuth @Param id path int true "密钥ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/auth-keys/{id} [delete]

func (*NodeHandler) DeleteNode

func (h *NodeHandler) DeleteNode(c *gin.Context)

DeleteNode godoc @Summary 删除节点 @Description 管理员删除指定节点 @Tags 管理端-节点 @Accept json @Produce json @Security BearerAuth @Param id path int true "节点ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/nodes/{id} [delete]

func (*NodeHandler) DeleteProtocol

func (h *NodeHandler) DeleteProtocol(c *gin.Context)

DeleteProtocol godoc @Summary 删除节点协议 @Description 管理员删除指定的节点协议配置 @Tags 管理端-节点 @Accept json @Produce json @Security BearerAuth @Param protocol_id path int true "协议ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/nodes/protocols/{protocol_id} [delete]

func (*NodeHandler) DispatchAgentControlOperation

func (h *NodeHandler) DispatchAgentControlOperation(c *gin.Context)

DispatchAgentControlOperation sends a bounded, capability-backed operation.

func (*NodeHandler) GenerateAuthKey

func (h *NodeHandler) GenerateAuthKey(c *gin.Context)

GenerateAuthKey godoc @Summary 生成授权密钥 @Description 管理员生成节点自动注册的授权密钥 @Tags 管理端-节点 @Accept json @Produce json @Security BearerAuth @Param request body map[string]any true "密钥请求 {name, expire_days}" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/auth-keys [post]

func (*NodeHandler) GenerateWireGuardKeypair

func (h *NodeHandler) GenerateWireGuardKeypair(c *gin.Context)

GenerateWireGuardKeypair creates a WireGuard server keypair for the admin protocol form. The private key is returned only to the authenticated caller and is never stored by this endpoint.

func (*NodeHandler) GetAgentControlStatus

func (h *NodeHandler) GetAgentControlStatus(c *gin.Context)

GetAgentControlStatus returns the live v3 control-stream state for one node.

func (*NodeHandler) GetAuthKeys

func (h *NodeHandler) GetAuthKeys(c *gin.Context)

GetAuthKeys godoc @Summary 获取授权密钥列表 @Description 管理员获取所有授权密钥列表。密钥值显示为 ********, 只在生成时返回一次。 @Tags 管理端-节点 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/auth-keys [get]

func (*NodeHandler) GetNode

func (h *NodeHandler) GetNode(c *gin.Context)

GetNode godoc @Summary 获取节点详情 @Description 管理员获取指定节点的详细信息 @Tags 管理端-节点 @Accept json @Produce json @Security BearerAuth @Param id path int true "节点ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 404 {object} map[string]any @Router /admin/nodes/{id} [get]

func (*NodeHandler) GetNodeCredentials

func (h *NodeHandler) GetNodeCredentials(c *gin.Context)

GetNodeCredentials godoc @Summary 获取节点凭证 @Description 管理员获取指定节点的 api_key / secret, 用于 AnixOps Agent 对接配置。 @Description Node.APIKey/Secret 在普通序列化里是隐藏字段 (json:"-"), 此接口显式返回, @Description 仅限管理员, 供 Ansible 等部署工具自动拉取节点凭证。 @Description 每次读取都写入管理员审计日志 (action "reveal")。 @Tags 管理端-节点 @Accept json @Produce json @Security BearerAuth @Param id path int true "节点ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 404 {object} map[string]any @Router /admin/nodes/{id}/credentials [get]

func (*NodeHandler) GetNodeLogs

func (h *NodeHandler) GetNodeLogs(c *gin.Context)

GetNodeLogs godoc @Summary 获取节点运行日志 @Description 管理员获取指定节点通过 gRPC 上报的运行日志 @Tags 管理端-节点 @Accept json @Produce json @Security BearerAuth @Param id path int true "节点ID" @Param page query int false "页码" default(1) @Param page_size query int false "每页数量" default(20) @Param level query string false "日志级别" @Param source query string false "日志来源" @Param search query string false "关键词" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/nodes/{id}/logs [get]

func (*NodeHandler) GetNodeRawConfig

func (h *NodeHandler) GetNodeRawConfig(c *gin.Context)

GetNodeRawConfig godoc @Summary 获取节点原始配置 @Description 管理员获取指定节点的原始JSON配置 @Tags 管理端-节点 @Accept json @Produce json @Security BearerAuth @Param id path int true "节点ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 404 {object} map[string]any @Router /admin/nodes/{id}/raw-config [get]

func (*NodeHandler) GetNodeStats

func (h *NodeHandler) GetNodeStats(c *gin.Context)

GetNodeStats godoc @Summary 获取节点统计 @Description 管理员获取节点统计数据 @Tags 管理端-节点 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/nodes/stats [get]

func (*NodeHandler) GetNodes

func (h *NodeHandler) GetNodes(c *gin.Context)

GetNodes godoc @Summary 获取节点列表 @Description 管理员获取节点列表,支持分页和筛选 @Tags 管理端-节点 @Accept json @Produce json @Security BearerAuth @Param page query int false "页码" default(1) @Param page_size query int false "每页数量" default(20) @Param search query string false "搜索关键词" @Param status query int false "节点状态" @Param group_id query int false "分组ID" @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/nodes [get]

func (*NodeHandler) GetProtocolTemplates

func (h *NodeHandler) GetProtocolTemplates(c *gin.Context)

GetProtocolTemplates godoc @Summary 获取协议模板 @Description 管理员获取可用的协议模板列表 @Tags 管理端-节点 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Router /admin/protocol-templates [get]

func (*NodeHandler) GetProtocols

func (h *NodeHandler) GetProtocols(c *gin.Context)

GetProtocols godoc @Summary 获取节点协议列表 @Description 管理员获取指定节点的协议配置列表 @Tags 管理端-节点 @Accept json @Produce json @Security BearerAuth @Param id path int true "节点ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/nodes/{id}/protocols [get]

func (*NodeHandler) Heartbeat

func (h *NodeHandler) Heartbeat(c *gin.Context)

Heartbeat godoc @Summary 节点心跳 @Description 节点向面板发送心跳以保持在线状态 @Tags 节点通信 @Accept json @Produce json @Security BearerAuth @Param request body model.NodeHeartbeatRequest true "心跳请求" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 401 {object} map[string]any @Failure 500 {object} map[string]any @Router /node/heartbeat [post]

func (*NodeHandler) InternalGenerateAuthKey

func (h *NodeHandler) InternalGenerateAuthKey(c *gin.Context)

InternalGenerateAuthKey godoc @Summary 内部生成授权密钥 @Description 使用API Token认证生成节点自动注册的授权密钥(供Ansible等自动化工具使用) @Tags 内部API @Accept json @Produce json @Security ApiTokenAuth @Param request body map[string]any true "密钥请求 {name, expire_days, node_name}" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /internal/auth-keys [post]

func (*NodeHandler) Register

func (h *NodeHandler) Register(c *gin.Context)

Register godoc @Summary 节点自动注册 @Description 节点通过授权密钥自动注册到面板 @Tags 节点通信 @Accept json @Produce json @Param request body model.NodeRegisterRequest true "注册请求" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Router /node/register [post]

func (*NodeHandler) RuntimeHealth

func (h *NodeHandler) RuntimeHealth(c *gin.Context)

RuntimeHealth godoc @Summary 上报节点运行时健康状态 @Description 节点上报 WireGuard/GOST 等托管运行时的进程健康状态,不覆盖普通心跳状态 @Tags 节点通信 @Accept json @Produce json @Security BearerAuth @Param request body model.NodeRuntimeHealthRequest true "运行时健康状态" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 401 {object} map[string]any @Failure 404 {object} map[string]any @Failure 500 {object} map[string]any @Router /node/runtime-health [post]

func (*NodeHandler) SyncProtocol

func (h *NodeHandler) SyncProtocol(c *gin.Context)

SyncProtocol godoc @Summary 同步协议到节点 @Description 管理员将协议配置同步到指定节点 @Tags 管理端-节点 @Accept json @Produce json @Security BearerAuth @Param id path int true "节点ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/nodes/{id}/sync [post]

func (*NodeHandler) UpdateNode

func (h *NodeHandler) UpdateNode(c *gin.Context)

UpdateNode godoc @Summary 更新节点 @Description 管理员更新指定节点的信息 @Tags 管理端-节点 @Accept json @Produce json @Security BearerAuth @Param id path int true "节点ID" @Param request body map[string]any true "节点更新信息" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/nodes/{id} [put]

func (*NodeHandler) UpdateNodeRawConfig

func (h *NodeHandler) UpdateNodeRawConfig(c *gin.Context)

UpdateNodeRawConfig godoc @Summary 更新节点原始配置 @Description 管理员更新指定节点的原始JSON配置(高级模式) @Tags 管理端-节点 @Accept json @Produce json @Security BearerAuth @Param id path int true "节点ID" @Param request body map[string]any true "原始配置 {raw_config: object}" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/nodes/{id}/raw-config [put]

func (*NodeHandler) UpdateProtocol

func (h *NodeHandler) UpdateProtocol(c *gin.Context)

UpdateProtocol godoc @Summary 更新节点协议 @Description 管理员更新指定的节点协议配置 @Tags 管理端-节点 @Accept json @Produce json @Security BearerAuth @Param protocol_id path int true "协议ID" @Param request body map[string]any true "协议更新信息" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/nodes/protocols/{protocol_id} [put]

func (*NodeHandler) ValidateRawConfig

func (h *NodeHandler) ValidateRawConfig(c *gin.Context)

ValidateRawConfig godoc @Summary 验证原始配置 @Description 管理员验证节点原始JSON配置的有效性 @Tags 管理端-节点 @Accept json @Produce json @Security BearerAuth @Param request body map[string]any true "原始配置 {raw_config: object}" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Router /admin/nodes/validate-config [post]

type NodeSnapshot

type NodeSnapshot struct {
	ID            uint    `json:"id"`
	Name          string  `json:"name"`
	Host          string  `json:"host"`
	Status        string  `json:"status"`
	CPUUsage      float64 `json:"cpu_usage"`
	MemoryUsage   float64 `json:"memory_usage"`
	DiskUsage     float64 `json:"disk_usage"`
	OnlineUsers   int     `json:"online_users"`
	TotalUpload   int64   `json:"total_upload"`
	TotalDownload int64   `json:"total_download"`
	Uptime        int64   `json:"uptime"`
}

NodeSnapshot 节点快照

type NotificationHandler

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

NotificationHandler 通知处理器

func NewNotificationHandler

func NewNotificationHandler() *NotificationHandler

NewNotificationHandler 创建处理器

func (*NotificationHandler) CreateTemplate

func (h *NotificationHandler) CreateTemplate(c *gin.Context)

CreateTemplate godoc @Summary 创建通知模板 @Description 管理员创建新的通知模板 @Tags 管理端-通知 @Accept json @Produce json @Security BearerAuth @Param request body map[string]any true "模板信息" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/notification/templates [post]

func (*NotificationHandler) DeleteTemplate

func (h *NotificationHandler) DeleteTemplate(c *gin.Context)

DeleteTemplate godoc @Summary 删除通知模板 @Description 管理员删除指定通知模板 @Tags 管理端-通知 @Accept json @Produce json @Security BearerAuth @Param id path int true "模板ID" @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/notification/templates/{id} [delete]

func (*NotificationHandler) GetEmailConfig

func (h *NotificationHandler) GetEmailConfig(c *gin.Context)

GetEmailConfig godoc @Summary 获取邮件配置 @Description 管理员获取邮件发送配置 @Tags 管理端-通知 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Router /admin/notification/email/config [get]

func (*NotificationHandler) GetUnreadCount

func (h *NotificationHandler) GetUnreadCount(c *gin.Context)

GetUnreadCount godoc @Summary 获取未读通知数量 @Description 用户获取未读通知的数量 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Router /user/notifications/unread-count [get]

func (*NotificationHandler) GetUserNotifications

func (h *NotificationHandler) GetUserNotifications(c *gin.Context)

GetUserNotifications godoc @Summary 获取用户通知列表 @Description 用户获取自己的通知列表 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Param page query int false "页码" default(1) @Param page_size query int false "每页数量" default(20) @Success 200 {object} map[string]any @Router /user/notifications [get]

func (*NotificationHandler) ListLogs

func (h *NotificationHandler) ListLogs(c *gin.Context)

ListLogs godoc @Summary 获取通知日志列表 @Description 管理员获取通知日志列表 @Tags 管理端-通知 @Accept json @Produce json @Security BearerAuth @Param page query int false "页码" default(1) @Param page_size query int false "每页数量" default(20) @Param type query string false "通知类型" @Param status query string false "发送状态" @Success 200 {object} map[string]any @Router /admin/notification/logs [get]

func (*NotificationHandler) ListTemplates

func (h *NotificationHandler) ListTemplates(c *gin.Context)

ListTemplates godoc @Summary 获取通知模板列表 @Description 管理员获取通知模板列表 @Tags 管理端-通知 @Accept json @Produce json @Security BearerAuth @Param type query string false "通知类型" @Success 200 {object} map[string]any @Router /admin/notification/templates [get]

func (*NotificationHandler) MarkAllAsRead

func (h *NotificationHandler) MarkAllAsRead(c *gin.Context)

MarkAllAsRead godoc @Summary 标记所有通知为已读 @Description 用户将所有通知标记为已读 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Router /user/notifications/read-all [post]

func (*NotificationHandler) MarkAsRead

func (h *NotificationHandler) MarkAsRead(c *gin.Context)

MarkAsRead godoc @Summary 标记通知为已读 @Description 用户将指定通知标记为已读 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Param id path int true "通知ID" @Success 200 {object} map[string]any @Failure 404 {object} map[string]any @Router /user/notifications/{id}/read [post]

func (*NotificationHandler) SendTestNotification

func (h *NotificationHandler) SendTestNotification(c *gin.Context)

SendTestNotification godoc @Summary 发送测试通知 @Description 管理员发送测试通知 @Tags 管理端-通知 @Accept json @Produce json @Security BearerAuth @Param request body map[string]any true "测试通知请求" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/notification/test [post]

func (*NotificationHandler) UpdateEmailConfig

func (h *NotificationHandler) UpdateEmailConfig(c *gin.Context)

UpdateEmailConfig godoc @Summary 更新邮件配置 @Description 管理员更新邮件发送配置 @Tags 管理端-通知 @Accept json @Produce json @Security BearerAuth @Param request body map[string]any true "邮件配置" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Router /admin/notification/email/config [put]

func (*NotificationHandler) UpdateTemplate

func (h *NotificationHandler) UpdateTemplate(c *gin.Context)

UpdateTemplate godoc @Summary 更新通知模板 @Description 管理员更新指定通知模板 @Tags 管理端-通知 @Accept json @Produce json @Security BearerAuth @Param id path int true "模板ID" @Param request body map[string]any true "模板更新信息" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 404 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/notification/templates/{id} [put]

type NotifySettingsRequest

type NotifySettingsRequest struct {
	NotifyExpire  *bool `json:"notify_expire"`
	NotifyTraffic *bool `json:"notify_traffic"`
	NotifyTicket  *bool `json:"notify_ticket"`
}

NotifySettingsRequest 通知设置请求

type Order

type Order struct{}

func (Order) TableName

func (Order) TableName() string

type OrderHandler

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

OrderHandler 用户端订单处理器

func NewOrderHandler

func NewOrderHandler() *OrderHandler

NewOrderHandler 创建订单处理器

func (*OrderHandler) GetOrderDetail

func (h *OrderHandler) GetOrderDetail(c *gin.Context)

GetOrderDetail 获取订单详情: the caller's own order with its plan's id and name. Another user's order is "not found", as an unknown one.

func (*OrderHandler) GetOrders

func (h *OrderHandler) GetOrders(c *gin.Context)

GetOrders 获取用户自己的订单: each with its plan's id and name, none with the buyer. The page size is clamped as on the administrator's list.

func (*OrderHandler) SaveOrder

func (h *OrderHandler) SaveOrder(c *gin.Context)

SaveOrder 保存订单 (下单)

type PaymentGatewayHandler

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

PaymentGatewayHandler 支付网关处理器

func NewPaymentGatewayHandler

func NewPaymentGatewayHandler() *PaymentGatewayHandler

NewPaymentGatewayHandler 创建处理器

func (*PaymentGatewayHandler) CreateGateway

func (h *PaymentGatewayHandler) CreateGateway(c *gin.Context)

CreateGateway godoc @Summary 创建支付网关 @Description 管理员创建新的支付网关 @Tags 管理端-支付 @Accept json @Produce json @Security BearerAuth @Param request body CreateGatewayRequest true "网关信息" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/payment/gateways [post]

func (*PaymentGatewayHandler) CreatePayment

func (h *PaymentGatewayHandler) CreatePayment(c *gin.Context)

CreatePayment godoc @Summary 创建支付订单 @Description 用户创建支付订单 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Param request body CreatePaymentRequest true "支付请求" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /user/payment/create [post]

func (*PaymentGatewayHandler) DeleteGateway

func (h *PaymentGatewayHandler) DeleteGateway(c *gin.Context)

DeleteGateway godoc @Summary 删除支付网关 @Description 管理员删除指定支付网关 @Tags 管理端-支付 @Accept json @Produce json @Security BearerAuth @Param id path int true "网关ID" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/payment/gateways/{id} [delete]

func (*PaymentGatewayHandler) GetChannels

func (h *PaymentGatewayHandler) GetChannels(c *gin.Context)

GetChannels godoc @Summary 获取支付渠道列表 @Description 用户获取可用的支付渠道列表 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /user/payment/channels [get]

func (*PaymentGatewayHandler) GetPaymentStats

func (h *PaymentGatewayHandler) GetPaymentStats(c *gin.Context)

GetPaymentStats godoc @Summary 获取支付统计 @Description 管理员获取支付统计数据,支持日期范围筛选 @Tags 管理端-支付 @Accept json @Produce json @Security BearerAuth @Param start query string false "开始日期 (格式: 2006-01-02)" @Param end query string false "结束日期 (格式: 2006-01-02)" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/payment/stats [get]

func (*PaymentGatewayHandler) GetPaymentStatus

func (h *PaymentGatewayHandler) GetPaymentStatus(c *gin.Context)

GetPaymentStatus godoc @Summary 查询支付状态 @Description 用户查询支付订单状态 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Param trade_no path string true "订单号" @Success 200 {object} map[string]any @Failure 404 {object} map[string]any @Router /user/payment/status/{trade_no} [get]

func (*PaymentGatewayHandler) GetUserRecords

func (h *PaymentGatewayHandler) GetUserRecords(c *gin.Context)

GetUserRecords godoc @Summary 获取用户支付记录 @Description 用户获取自己的支付记录列表 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Param page query int false "页码" default(1) @Param page_size query int false "每页数量" default(20) @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /user/payment/records [get]

func (*PaymentGatewayHandler) ListGateways

func (h *PaymentGatewayHandler) ListGateways(c *gin.Context)

ListGateways godoc @Summary 获取支付网关列表 @Description 管理员获取所有支付网关列表 @Tags 管理端-支付 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/payment/gateways [get]

func (*PaymentGatewayHandler) ListPaymentRecords

func (h *PaymentGatewayHandler) ListPaymentRecords(c *gin.Context)

ListPaymentRecords godoc @Summary 获取支付记录列表 @Description 管理员获取支付记录列表,支持分页和状态筛选 @Tags 管理端-支付 @Accept json @Produce json @Security BearerAuth @Param page query int false "页码" default(1) @Param page_size query int false "每页数量" default(20) @Param status query int false "支付状态" @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/payment/records [get]

func (*PaymentGatewayHandler) PaymentCallback

func (h *PaymentGatewayHandler) PaymentCallback(c *gin.Context)

PaymentCallback godoc @Summary 支付回调 @Description 接收第三方支付平台的回调通知 @Tags 支付回调 @Accept json @Produce plain @Param type path string true "支付类型 (alipay/wechat/epay等)" @Success 200 {string} string "success" @Failure 400 {string} string "fail" @Router /payment/callback/{type} [post]

func (*PaymentGatewayHandler) ToggleGateway

func (h *PaymentGatewayHandler) ToggleGateway(c *gin.Context)

ToggleGateway godoc @Summary 切换网关状态 @Description 管理员启用或禁用指定支付网关 @Tags 管理端-支付 @Accept json @Produce json @Security BearerAuth @Param id path int true "网关ID" @Param request body ToggleRequest true "状态请求" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/payment/gateways/{id}/toggle [post]

func (*PaymentGatewayHandler) UpdateGateway

func (h *PaymentGatewayHandler) UpdateGateway(c *gin.Context)

UpdateGateway godoc @Summary 更新支付网关 @Description 管理员更新指定支付网关的信息 @Tags 管理端-支付 @Accept json @Produce json @Security BearerAuth @Param id path int true "网关ID" @Param request body UpdateGatewayRequest true "网关更新信息" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 404 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/payment/gateways/{id} [put]

type PaymentHandler

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

PaymentHandler 支付处理器

func NewPaymentHandler

func NewPaymentHandler() *PaymentHandler

NewPaymentHandler 创建支付处理器

func (*PaymentHandler) FiatCreatePayment

func (h *PaymentHandler) FiatCreatePayment(c *gin.Context)

FiatCreatePayment 创建法币支付

func (*PaymentHandler) GetPaymentMethods

func (h *PaymentHandler) GetPaymentMethods(c *gin.Context)

GetPaymentMethods 获取可用支付方式

func (*PaymentHandler) GetPaymentStatus

func (h *PaymentHandler) GetPaymentStatus(c *gin.Context)

GetPaymentStatus 查询支付状态

func (*PaymentHandler) PayPalWebhook

func (h *PaymentHandler) PayPalWebhook(c *gin.Context)

PayPalWebhook PayPal 回调

func (*PaymentHandler) StripeWebhook

func (h *PaymentHandler) StripeWebhook(c *gin.Context)

StripeWebhook Stripe 回调

func (*PaymentHandler) X402Callback

func (h *PaymentHandler) X402Callback(c *gin.Context)

X402Callback X402 支付回调

func (*PaymentHandler) X402CheckPayment

func (h *PaymentHandler) X402CheckPayment(c *gin.Context)

X402CheckPayment 查询 X402 支付状态

func (*PaymentHandler) X402CreatePayment

func (h *PaymentHandler) X402CreatePayment(c *gin.Context)

X402CreatePayment 创建 X402 支付

type PublicConfig added in v4.1.0

type PublicConfig struct {
	Edition        string                   `json:"edition"`
	HiddenPackages []string                 `json:"hidden_packages"`
	Registration   PublicRegistrationConfig `json:"registration"`
}

PublicConfig is what the web app reads before anyone signs in: the product edition, the packages the edition hides (their menus and pages are not shown), and whether registration asks for an invite code.

func NewPublicConfig added in v4.1.0

func NewPublicConfig(cfg *config.Config) PublicConfig

NewPublicConfig returns the public configuration of cfg.

type PublicRegistrationConfig added in v4.1.0

type PublicRegistrationConfig struct {
	Enabled       bool `json:"enabled"`
	RequireInvite bool `json:"require_invite"`
}

PublicRegistrationConfig is the public part of the registration policy.

type RouteModeChangeBody added in v4.1.0

type RouteModeChangeBody struct {
	PackageID string   `json:"package_id" binding:"required"`
	Routes    []string `json:"routes"`
	Mode      string   `json:"mode" binding:"required"`
	Reason    string   `json:"reason"`
	Confirm   bool     `json:"confirm"`
}

RouteModeChangeBody switches routes of a package. No routes means the whole package. Switching to native needs confirm and a reason.

type RouteModeHandler added in v4.1.0

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

RouteModeHandler lists and switches the route modes of v2 Control packages (legacy, shadow, native). Any administrator may read them; only a super administrator (service.IsSuperAdmin) may switch them.

func NewRouteModeHandler added in v4.1.0

func NewRouteModeHandler() *RouteModeHandler

NewRouteModeHandler reads the database, the official package trust root and the package hosts' reports on each request.

func (*RouteModeHandler) List added in v4.1.0

func (h *RouteModeHandler) List(c *gin.Context)

List godoc @Summary List package route modes @Description Every v2 Control package's compatibility routes with their configured and effective mode, the modes each may switch to, the running host's native and shadow counters with the mismatch rate, and how many sanitized shadow mismatch samples are stored. can_switch tells whether the caller may switch them. @Tags Kernel route modes @Produce json @Security BearerAuth @Param package_id query string false "Package id" @Success 200 {object} map[string]any @Failure 404 {object} map[string]any @Router /api/v4/kernel/route-modes [get]

func (*RouteModeHandler) Mismatches added in v4.1.0

func (h *RouteModeHandler) Mismatches(c *gin.Context)

Mismatches godoc @Summary List shadow mismatch samples @Description The newest sanitized shadow-mode mismatch samples, of one package or route or of all: the route, method, path template with masked query values, legacy and native status, and a structural diff whose values are masked (tokens, passwords, UUIDs, keys and other secrets fully; e-mail addresses keep their first character and domain, IPv4 addresses two octets, IPv6 addresses two hextets). Samples are kept for 7 days and at most 100 per route. Any administrator may read them. @Tags Kernel route modes @Produce json @Security BearerAuth @Param package_id query string false "Package id" @Param route_id query string false "Route id" @Param limit query int false "At most this many samples (default 50, at most 100)" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Router /api/v4/kernel/route-modes/mismatches [get]

func (*RouteModeHandler) Revisions added in v4.1.0

func (h *RouteModeHandler) Revisions(c *gin.Context)

Revisions godoc @Summary List route mode revisions @Description The latest route mode switches, newest first, of one package or of all. @Tags Kernel route modes @Produce json @Security BearerAuth @Param package_id query string false "Package id" @Param limit query int false "At most this many revisions (default 100, at most 1000)" @Success 200 {object} map[string]any @Router /api/v4/kernel/route-modes/revisions [get]

func (*RouteModeHandler) Rollback added in v4.1.0

func (h *RouteModeHandler) Rollback(c *gin.Context)

Rollback godoc @Summary Roll a package back to legacy route modes @Description Returns every route of a package to legacy in one change, except identity group A, which the identity rollback switches. Super administrators only; no confirmation is needed and the reason is optional. @Tags Kernel route modes @Accept json @Produce json @Security BearerAuth @Param body body RouteModeRollbackBody true "Rollback" @Success 200 {object} map[string]any @Failure 403 {object} map[string]any @Failure 404 {object} map[string]any @Router /api/v4/kernel/route-modes/rollback [post]

func (*RouteModeHandler) Set added in v4.1.0

func (h *RouteModeHandler) Set(c *gin.Context)

Set godoc @Summary Switch package route modes @Description Switches the named routes of a package, or every route that may switch, to legacy, shadow or native. Super administrators only. Switching to native needs confirm: true and a reason. Every switch is audited and recorded in the revision history. @Tags Kernel route modes @Accept json @Produce json @Security BearerAuth @Param body body RouteModeChangeBody true "Route mode change" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 403 {object} map[string]any @Failure 404 {object} map[string]any @Failure 409 {object} map[string]any @Router /api/v4/kernel/route-modes [post]

type RouteModeRollbackBody added in v4.1.0

type RouteModeRollbackBody struct {
	PackageID string `json:"package_id" binding:"required"`
	Reason    string `json:"reason"`
}

RouteModeRollbackBody returns a whole package to legacy.

type SendNotificationRequest

type SendNotificationRequest struct {
	TelegramID int64  `json:"telegram_id" binding:"required"`
	Title      string `json:"title" binding:"omitempty,max=255"`
	Content    string `json:"content" binding:"omitempty,max=4096"`
	Message    string `json:"message" binding:"omitempty,max=4096"`
}

SendNotificationRequest 发送通知请求

type SetWebhookRequest

type SetWebhookRequest struct {
	URL string `json:"url" binding:"omitempty,url,max=512"`
}

SetWebhookRequest 设置Webhook请求

type SpeedLimitHandler

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

func NewSpeedLimitHandler

func NewSpeedLimitHandler() *SpeedLimitHandler

func (*SpeedLimitHandler) CreatePanelSpeedLimit

func (h *SpeedLimitHandler) CreatePanelSpeedLimit(c *gin.Context)

func (*SpeedLimitHandler) DeletePanelSpeedLimit

func (h *SpeedLimitHandler) DeletePanelSpeedLimit(c *gin.Context)

func (*SpeedLimitHandler) ListPanelSpeedLimitTunnels

func (h *SpeedLimitHandler) ListPanelSpeedLimitTunnels(c *gin.Context)

func (*SpeedLimitHandler) ListPanelSpeedLimits

func (h *SpeedLimitHandler) ListPanelSpeedLimits(c *gin.Context)

func (*SpeedLimitHandler) UpdatePanelSpeedLimit

func (h *SpeedLimitHandler) UpdatePanelSpeedLimit(c *gin.Context)

type SubscribeHandler

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

SubscribeHandler 订阅处理器

func NewSubscribeHandler

func NewSubscribeHandler(cfg *config.Config) *SubscribeHandler

NewSubscribeHandler 创建订阅处理器

func (*SubscribeHandler) GetLegacySubscription

func (h *SubscribeHandler) GetLegacySubscription(c *gin.Context)

GetLegacySubscription keeps compatibility with the historical /api/v1/client/subscribe?token=TOKEN entrypoint.

func (*SubscribeHandler) GetSubscription

func (h *SubscribeHandler) GetSubscription(c *gin.Context)

GetSubscription 获取用户订阅 GET /s/:token 支持 URL 参数:

  • type: 指定输出格式 (v2ray, clash, stash, egern, surge, loon, shadowrocket, quantumultx, json, base64json, wireguard) 也支持 type=auto 或 type=ua,强制按 User-Agent 自动识别格式
  • include: 包含节点名关键词 (正则)
  • exclude: 排除节点名关键词 (正则)
  • groups: 指定分组 ID (逗号分隔)

type SubscriptionAdminHandler

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

SubscriptionAdminHandler 订阅管理处理器

func NewSubscriptionAdminHandler

func NewSubscriptionAdminHandler() *SubscriptionAdminHandler

NewSubscriptionAdminHandler 创建订阅管理处理器

func (*SubscriptionAdminHandler) AssignGroupToPlan

func (h *SubscriptionAdminHandler) AssignGroupToPlan(c *gin.Context)

AssignGroupToPlan 为套餐分配订阅分组 POST /api/v2/admin/subscription/plans/:plan_id/groups

func (*SubscriptionAdminHandler) AssignGroupToUser

func (h *SubscriptionAdminHandler) AssignGroupToUser(c *gin.Context)

AssignGroupToUser 为用户分配订阅分组 POST /api/v2/admin/subscription/users/:user_id/groups

func (*SubscriptionAdminHandler) CreateGroup

func (h *SubscriptionAdminHandler) CreateGroup(c *gin.Context)

CreateGroup 创建订阅分组 POST /api/v2/admin/subscription/groups

func (*SubscriptionAdminHandler) CreateTemplate

func (h *SubscriptionAdminHandler) CreateTemplate(c *gin.Context)

CreateTemplate 创建订阅模板 POST /api/v2/admin/subscription/groups/:id/templates

func (*SubscriptionAdminHandler) DeleteGroup

func (h *SubscriptionAdminHandler) DeleteGroup(c *gin.Context)

DeleteGroup 删除订阅分组 DELETE /api/v2/admin/subscription/groups/:id

func (*SubscriptionAdminHandler) DeleteTemplate

func (h *SubscriptionAdminHandler) DeleteTemplate(c *gin.Context)

DeleteTemplate 删除订阅模板 DELETE /api/v2/admin/subscription/templates/:id

func (*SubscriptionAdminHandler) GetAvailableProtocols

func (h *SubscriptionAdminHandler) GetAvailableProtocols(c *gin.Context)

GetAvailableProtocols 获取所有可用的物理节点协议 (Protocol Pool) GET /api/v2/admin/subscription/protocols/available

func (*SubscriptionAdminHandler) GetGroup

func (h *SubscriptionAdminHandler) GetGroup(c *gin.Context)

GetGroup 获取订阅分组详情 GET /api/v2/admin/subscription/groups/:id

func (*SubscriptionAdminHandler) GetGroupProtocols

func (h *SubscriptionAdminHandler) GetGroupProtocols(c *gin.Context)

GetGroupProtocols 获取属于该分组的物理节点协议 GET /api/v2/admin/subscription/groups/:id/protocols

func (*SubscriptionAdminHandler) GetGroupStats

func (h *SubscriptionAdminHandler) GetGroupStats(c *gin.Context)

GetGroupStats 获取订阅分组统计数据 GET /api/v2/admin/subscription/stats

func (*SubscriptionAdminHandler) GetGroups

func (h *SubscriptionAdminHandler) GetGroups(c *gin.Context)

GetGroups 获取所有订阅分组 GET /api/v2/admin/subscription/groups

func (*SubscriptionAdminHandler) GetPlanGroups

func (h *SubscriptionAdminHandler) GetPlanGroups(c *gin.Context)

GetPlanGroups 获取套餐的订阅分组 GET /api/v2/admin/subscription/plans/:plan_id/groups

func (*SubscriptionAdminHandler) GetProtocolTypes

func (h *SubscriptionAdminHandler) GetProtocolTypes(c *gin.Context)

GetProtocolTypes 获取支持的协议类型 GET /api/v2/admin/subscription/protocols

func (*SubscriptionAdminHandler) GetSubscriptionFormats

func (h *SubscriptionAdminHandler) GetSubscriptionFormats(c *gin.Context)

GetSubscriptionFormats 获取支持的订阅格式 GET /api/v2/admin/subscription/formats

func (*SubscriptionAdminHandler) GetTemplate

func (h *SubscriptionAdminHandler) GetTemplate(c *gin.Context)

GetTemplate 获取订阅模板详情 GET /api/v2/admin/subscription/templates/:id

func (*SubscriptionAdminHandler) GetTemplates

func (h *SubscriptionAdminHandler) GetTemplates(c *gin.Context)

GetTemplates 获取分组的模板列表 GET /api/v2/admin/subscription/groups/:id/templates

func (*SubscriptionAdminHandler) GetUserGroups

func (h *SubscriptionAdminHandler) GetUserGroups(c *gin.Context)

GetUserGroups 获取用户的订阅分组 GET /api/v2/admin/subscription/users/:user_id/groups

func (*SubscriptionAdminHandler) PreviewSubscription

func (h *SubscriptionAdminHandler) PreviewSubscription(c *gin.Context)

PreviewSubscription 预览订阅内容 POST /api/v2/admin/subscription/preview

func (*SubscriptionAdminHandler) RemoveGroupFromPlan

func (h *SubscriptionAdminHandler) RemoveGroupFromPlan(c *gin.Context)

RemoveGroupFromPlan 移除套餐的订阅分组 DELETE /api/v2/admin/subscription/plans/:plan_id/groups/:group_id

func (*SubscriptionAdminHandler) RemoveGroupFromUser

func (h *SubscriptionAdminHandler) RemoveGroupFromUser(c *gin.Context)

RemoveGroupFromUser 移除用户的订阅分组 DELETE /api/v2/admin/subscription/users/:user_id/groups/:group_id

func (*SubscriptionAdminHandler) UpdateGroup

func (h *SubscriptionAdminHandler) UpdateGroup(c *gin.Context)

UpdateGroup 更新订阅分组 PUT /api/v2/admin/subscription/groups/:id

func (*SubscriptionAdminHandler) UpdateGroupProtocols

func (h *SubscriptionAdminHandler) UpdateGroupProtocols(c *gin.Context)

UpdateGroupProtocols 更新分组关联的物理节点协议 POST /api/v2/admin/subscription/groups/:id/protocols

func (*SubscriptionAdminHandler) UpdateTemplate

func (h *SubscriptionAdminHandler) UpdateTemplate(c *gin.Context)

UpdateTemplate 更新订阅模板 PUT /api/v2/admin/subscription/templates/:id

type SystemHandler

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

SystemHandler 系统处理器 SystemHandler handles system configuration, backup, and load balancer endpoints.

func NewSystemHandler

func NewSystemHandler() *SystemHandler

NewSystemHandler 创建处理器 NewSystemHandler creates a system handler.

func (*SystemHandler) CreateBackup

func (h *SystemHandler) CreateBackup(c *gin.Context)

CreateBackup godoc @Summary 创建备份 @Description 管理员手动创建系统备份 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Param type query string false "备份类型 (database/full)" default(database) @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/system/backup [post]

func (*SystemHandler) DeleteBackup

func (h *SystemHandler) DeleteBackup(c *gin.Context)

DeleteBackup godoc @Summary 删除备份 @Description 管理员删除指定备份记录 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Param id path int true "备份ID" @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/system/backups/{id} [delete]

func (*SystemHandler) DeleteConfig

func (h *SystemHandler) DeleteConfig(c *gin.Context)

DeleteConfig godoc @Summary 删除系统配置 @Description 管理员删除指定key的系统配置 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Param key path string true "配置键名" @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/system/configs/{key} [delete]

func (*SystemHandler) GetAuditLogs

func (h *SystemHandler) GetAuditLogs(c *gin.Context)

GetAuditLogs godoc @Summary Get system audit logs @Description Admin query for system operation audit logs with optional filters. @Tags Admin System @Accept json @Produce json @Security BearerAuth @Param target_type query string false "Filter by target type" @Param action query string false "Filter by action" @Param page query int false "Page number" default(1) @Param page_size query int false "Page size" default(20) @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/system/audit-logs [get]

func (*SystemHandler) GetBackupConfig

func (h *SystemHandler) GetBackupConfig(c *gin.Context)

GetBackupConfig godoc @Summary 获取备份配置 @Description 管理员获取系统备份配置 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/system/backup/config [get]

func (*SystemHandler) GetBackupStats

func (h *SystemHandler) GetBackupStats(c *gin.Context)

GetBackupStats godoc @Summary 获取备份统计 @Description 管理员获取备份统计数据 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/system/backup/stats [get]

func (*SystemHandler) GetConfig

func (h *SystemHandler) GetConfig(c *gin.Context)

GetConfig godoc @Summary 获取单个系统配置 @Description 管理员获取指定key的系统配置 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Param key path string true "配置键名" @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/system/configs/{key} [get]

func (*SystemHandler) GetConfigs

func (h *SystemHandler) GetConfigs(c *gin.Context)

GetConfigs godoc @Summary 获取系统配置列表 @Description 管理员获取系统配置列表,支持按分组筛选 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Param group query string false "配置分组" @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/system/configs [get]

func (*SystemHandler) GetSubscriptionSettings

func (h *SystemHandler) GetSubscriptionSettings(c *gin.Context)

GetSubscriptionSettings returns current subscription URL settings.

func (*SystemHandler) ListBackups

func (h *SystemHandler) ListBackups(c *gin.Context)

ListBackups godoc @Summary 获取备份列表 @Description 管理员获取备份记录列表 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Param page query int false "页码" default(1) @Param page_size query int false "每页数量" default(20) @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/system/backups [get]

func (*SystemHandler) RestoreBackup

func (h *SystemHandler) RestoreBackup(c *gin.Context)

RestoreBackup godoc @Summary 恢复备份 @Description 管理员从备份恢复系统 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Param id path int true "备份ID" @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/system/backups/{id}/restore [post]

func (*SystemHandler) SetConfig

func (h *SystemHandler) SetConfig(c *gin.Context)

SetConfig godoc @Summary 设置系统配置 @Description 管理员设置系统配置项 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Param key path string true "配置键名" @Param request body map[string]any true "配置值" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/system/configs/{key} [put]

func (*SystemHandler) UpdateBackupConfig

func (h *SystemHandler) UpdateBackupConfig(c *gin.Context)

UpdateBackupConfig godoc @Summary 更新备份配置 @Description 管理员更新系统备份配置 @Tags 管理端-系统 @Accept json @Produce json @Security BearerAuth @Param request body model.BackupConfig true "备份配置" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/system/backup/config [put]

type TelegramHandler

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

TelegramHandler Telegram Bot处理器

func NewTelegramHandler

func NewTelegramHandler() *TelegramHandler

NewTelegramHandler 创建处理器

func (*TelegramHandler) Broadcast

func (h *TelegramHandler) Broadcast(c *gin.Context)

Broadcast godoc @Summary 广播Telegram消息 @Description 管理员通过Telegram广播消息给所有绑定用户 @Tags 管理端-通知 @Accept json @Produce json @Security BearerAuth @Param request body BroadcastRequest true "广播请求" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Router /admin/telegram/broadcast [post]

func (*TelegramHandler) DeleteWebhook

func (h *TelegramHandler) DeleteWebhook(c *gin.Context)

DeleteWebhook godoc @Summary 删除Telegram Webhook @Description 管理员删除Telegram Bot的Webhook配置 @Tags 管理端-通知 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/telegram/webhook [delete]

func (*TelegramHandler) GetBot

func (h *TelegramHandler) GetBot(c *gin.Context)

GetBot godoc @Summary 获取Telegram Bot配置 @Description 管理员获取Telegram Bot的配置信息 @Tags 管理端-通知 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Failure 404 {object} map[string]any @Router /admin/telegram/bot [get]

func (*TelegramHandler) GetTelegramStatus

func (h *TelegramHandler) GetTelegramStatus(c *gin.Context)

GetTelegramStatus godoc @Summary 获取Telegram绑定状态 @Description 用户获取自己的Telegram绑定状态 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Router /user/telegram/status [get]

func (*TelegramHandler) GetUserBindings

func (h *TelegramHandler) GetUserBindings(c *gin.Context)

GetUserBindings godoc @Summary 获取用户绑定列表 @Description 管理员获取Telegram用户绑定列表 @Tags 管理端-通知 @Accept json @Produce json @Security BearerAuth @Param page query int false "页码" default(1) @Param page_size query int false "每页数量" default(20) @Success 200 {object} map[string]any @Router /admin/telegram/users [get]

func (*TelegramHandler) SendNotification

func (h *TelegramHandler) SendNotification(c *gin.Context)

SendNotification godoc @Summary 发送Telegram通知 @Description 管理员通过Telegram发送通知给指定用户 @Tags 管理端-通知 @Accept json @Produce json @Security BearerAuth @Param request body SendNotificationRequest true "通知请求" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/telegram/notify [post]

func (*TelegramHandler) SetWebhook

func (h *TelegramHandler) SetWebhook(c *gin.Context)

SetWebhook godoc @Summary 设置Telegram Webhook @Description 管理员设置Telegram Bot的Webhook地址 @Tags 管理端-通知 @Accept json @Produce json @Security BearerAuth @Param request body SetWebhookRequest true "Webhook配置" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/telegram/webhook [post]

func (*TelegramHandler) TelegramWebhook

func (h *TelegramHandler) TelegramWebhook(c *gin.Context)

TelegramWebhook godoc @Summary Telegram Webhook回调 @Description 接收Telegram Bot的Webhook回调 @Tags Telegram @Accept json @Produce json @Param request body service.TelegramUpdate true "Telegram Update" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Router /telegram/webhook [post]

func (*TelegramHandler) UnbindTelegram

func (h *TelegramHandler) UnbindTelegram(c *gin.Context)

UnbindTelegram godoc @Summary 解绑Telegram @Description 用户解绑自己的Telegram账号 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Router /user/telegram/unbind [post]

func (*TelegramHandler) UpdateBot

func (h *TelegramHandler) UpdateBot(c *gin.Context)

UpdateBot godoc @Summary 更新Telegram Bot配置 @Description 管理员更新Telegram Bot的配置信息 @Tags 管理端-通知 @Accept json @Produce json @Security BearerAuth @Param request body UpdateBotRequest true "Bot配置" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 404 {object} map[string]any @Failure 500 {object} map[string]any @Router /admin/telegram/bot [put]

func (*TelegramHandler) UpdateNotifySettings

func (h *TelegramHandler) UpdateNotifySettings(c *gin.Context)

UpdateNotifySettings godoc @Summary 更新Telegram通知设置 @Description 用户更新自己的Telegram通知设置 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Param request body NotifySettingsRequest true "通知设置" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Router /user/telegram/notify [post]

func (*TelegramHandler) UpdateUserNotify

func (h *TelegramHandler) UpdateUserNotify(c *gin.Context)

UpdateUserNotify godoc @Summary 更新Telegram用户通知设置 @Description 管理员更新指定Telegram用户的通知开关 @Tags 管理端-通知 @Accept json @Produce json @Security BearerAuth @Param id path int true "Telegram绑定ID" @Param request body map[string]any true "通知设置" @Success 200 {object} map[string]any @Failure 400 {object} map[string]any @Failure 404 {object} map[string]any @Router /admin/telegram/users/{id}/notify [put]

type TestGostConnectionRequest

type TestGostConnectionRequest struct {
	Host     string `json:"host" binding:"required"`
	APIPort  int    `json:"api_port" binding:"required"`
	APIToken string `json:"api_token"`
}

TestGostConnectionRequest 测试 gost 连接请求

type TicketHandler

type TicketHandler struct{}

TicketHandler 用户端工单处理器

func NewTicketHandler

func NewTicketHandler() *TicketHandler

NewTicketHandler 创建工单处理器

func (*TicketHandler) CloseTicket

func (h *TicketHandler) CloseTicket(c *gin.Context)

CloseTicket 用户主动关闭工单

func (*TicketHandler) CreateTicket

func (h *TicketHandler) CreateTicket(c *gin.Context)

CreateTicket 提交新工单

func (*TicketHandler) GetTicket

func (h *TicketHandler) GetTicket(c *gin.Context)

GetTicket 获取工单详情及回话

func (*TicketHandler) GetTickets

func (h *TicketHandler) GetTickets(c *gin.Context)

GetTickets 获取用户自己的工单列表

func (*TicketHandler) ReplyTicket

func (h *TicketHandler) ReplyTicket(c *gin.Context)

ReplyTicket 回复自己的工单

type ToggleRequest

type ToggleRequest struct {
	Enabled bool `json:"enabled"`
}

ToggleRequest 切换状态请求

type UniProxyHandler

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

UniProxyHandler handles node polling APIs.

func NewUniProxyHandler

func NewUniProxyHandler() *UniProxyHandler

func (*UniProxyHandler) GetAliveList

func (h *UniProxyHandler) GetAliveList(c *gin.Context)

GetAliveList returns online counts. GET /api/v1/server/UniProxy/alivelist

func (*UniProxyHandler) GetConfig

func (h *UniProxyHandler) GetConfig(c *gin.Context)

GetConfig returns node config. GET /api/v1/server/UniProxy/config

func (*UniProxyHandler) GetUsers

func (h *UniProxyHandler) GetUsers(c *gin.Context)

GetUsers returns active users. GET /api/v1/server/UniProxy/user

func (*UniProxyHandler) PushAlive

func (h *UniProxyHandler) PushAlive(c *gin.Context)

PushAlive receives online IP report. POST /api/v1/server/UniProxy/alive

func (*UniProxyHandler) PushTraffic

func (h *UniProxyHandler) PushTraffic(c *gin.Context)

PushTraffic receives traffic report. POST /api/v1/server/UniProxy/push

type UpdateAnsibleMachineRequest

type UpdateAnsibleMachineRequest struct {
	Name    string `json:"name" binding:"omitempty,min=1,max=255"`
	Host    string `json:"host" binding:"omitempty,min=1,max=255"`
	Port    int    `json:"port" binding:"omitempty,min=1,max=65535"`
	Region  string `json:"region" binding:"omitempty,max=128"`
	ISP     string `json:"isp" binding:"omitempty,max=128"`
	Weight  int    `json:"weight" binding:"omitempty,gte=0"`
	Enabled *bool  `json:"enabled"`
}

type UpdateBotRequest

type UpdateBotRequest struct {
	Name           string `json:"name" binding:"omitempty,max=255"`
	Token          string `json:"token" binding:"omitempty,min=1"`
	WelcomeMsg     string `json:"welcome_msg" binding:"omitempty,max=1024"`
	WelcomeMessage string `json:"welcome_message" binding:"omitempty,max=1024"`
	AdminIDs       any    `json:"admin_ids"`
	AllowBind      *bool  `json:"allow_bind"`
	AllowSub       *bool  `json:"allow_sub"`
	AllowTicket    *bool  `json:"allow_ticket"`
	AllowInfo      *bool  `json:"allow_info"`
}

UpdateBotRequest 更新Bot请求

type UpdateGatewayRequest

type UpdateGatewayRequest struct {
	Name        string   `json:"name"`
	Type        string   `json:"type" binding:"omitempty,oneof=alipay wechat stripe usdt epay"`
	Icon        string   `json:"icon"`
	Config      any      `json:"config"`
	FeeRate     *float64 `json:"fee_rate"`
	FeeFixed    *float64 `json:"fee_fixed"`
	MinAmount   *float64 `json:"min_amount"`
	MaxAmount   *float64 `json:"max_amount"`
	Sort        *int     `json:"sort"`
	Description string   `json:"description"`
}

UpdateGatewayRequest 更新网关请求

type UpdateNodeRequest

type UpdateNodeRequest struct {
	Name        string `json:"name"`
	Type        string `json:"type" binding:"omitempty,oneof=relay exit"`
	Host        string `json:"host"`
	Port        int    `json:"port"`
	APIPort     int    `json:"api_port"`
	APIToken    string `json:"api_token"`
	MetricsPort int    `json:"metrics_port"`
	Region      string `json:"region"`
	ISP         string `json:"isp"`
	Bandwidth   int64  `json:"bandwidth"`
	Weight      int    `json:"weight"`
	MaxConn     int    `json:"max_conn"`
	Enabled     *bool  `json:"enabled"`
}

UpdateNodeRequest 更新节点请求

type UpdateRuleRequest

type UpdateRuleRequest struct {
	Name         string     `json:"name"`
	RelayNodeID  uint       `json:"relay_node_id"`
	ExitNodeID   uint       `json:"exit_node_id"`
	ListenPort   int        `json:"listen_port"`
	Protocol     string     `json:"protocol"`
	TargetHost   string     `json:"target_host"`
	TargetPort   int        `json:"target_port"`
	SpeedLimit   *int64     `json:"speed_limit"`
	TrafficLimit *int64     `json:"traffic_limit"`
	ExpireTime   *time.Time `json:"expire_time"`
	Remark       string     `json:"remark"`
}

UpdateRuleRequest 更新规则请求

type User

type User struct{}

简化的模型定义(用于计数查询)

func (User) TableName

func (User) TableName() string

type UserHandler

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

UserHandler 用户处理器

func NewUserHandler

func NewUserHandler() *UserHandler

NewUserHandler 创建用户处理器

func (*UserHandler) GetDashboard

func (h *UserHandler) GetDashboard(c *gin.Context)

GetDashboard godoc @Summary 获取用户仪表盘 @Description 获取当前登录用户的仪表盘数据,包括订阅信息等 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Failure 401 {object} map[string]any @Failure 500 {object} map[string]any @Router /user/dashboard [get]

func (*UserHandler) GetProfile

func (h *UserHandler) GetProfile(c *gin.Context)

GetProfile godoc @Summary 获取用户基本信息 @Description 获取当前登录用户的基本信息,包括邮箱、UUID、Token等 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Success 200 {object} map[string]any @Failure 401 {object} map[string]any @Failure 404 {object} map[string]any @Router /user/profile [get]

func (*UserHandler) GetSubscription

func (h *UserHandler) GetSubscription(c *gin.Context)

GetSubscription godoc @Summary 获取用户订阅详情 @Description 获取当前登录用户的订阅信息,包括流量、到期时间等 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Param refresh query bool false "是否强制刷新缓存" @Success 200 {object} map[string]any @Failure 401 {object} map[string]any @Failure 500 {object} map[string]any @Router /user/subscription [get]

func (*UserHandler) ResetSubscription added in v4.1.0

func (h *UserHandler) ResetSubscription(c *gin.Context)

ResetSubscription godoc @Summary 重置我的订阅链接 @Description 用户为自己重新生成订阅 token,旧订阅链接立即失效(UUID 不变,与管理员重置相同)。需重新验证身份:未开启两步验证时提交当前密码,已开启时提交验证码或恢复码。每个用户每小时最多尝试 3 次。 @Tags 用户端 @Accept json @Produce json @Security BearerAuth @Param body body subscriptionResetRequest true "password,或 code 与可选的 method(totp / backup)" @Success 200 {object} map[string]any "data.token 为新的订阅 token" @Failure 400 {object} map[string]any @Router /user/subscription/reset [post]

type UserPlanHandler

type UserPlanHandler struct{}

UserPlanHandler 用户端套餐处理器

func NewUserPlanHandler

func NewUserPlanHandler() *UserPlanHandler

NewUserPlanHandler 创建套餐处理器

func (*UserPlanHandler) GetPlans

func (h *UserPlanHandler) GetPlans(c *gin.Context)

GetPlans 获取可购买的套餐列表

Jump to

Keyboard shortcuts

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