chore: upgrade dependencies

This commit is contained in:
dushixiang committed 2026-07-08 21:56:14 +08:00
1 parent 26bd90ed90
commit 60678ea1bc
19 files changed
+179 -190

No files matched your search

+9 -9
View File
@@ -5,7 +5,7 @@ import (
"github.com/dushixiang/pika/internal/service"
"github.com/go-orz/orz"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v5"
)
type AccountHandler struct {
@@ -25,7 +25,7 @@ type LoginRequest struct {
}
// Login 用户登录(Basic Auth)
func (r AccountHandler) Login(c echo.Context) error {
func (r AccountHandler) Login(c *echo.Context) error {
var req LoginRequest
if err := c.Bind(&req); err != nil {
return err
@@ -50,7 +50,7 @@ type OIDCLoginRequest struct {
}
// OIDCLogin OIDC 登录回调
func (r AccountHandler) OIDCLogin(c echo.Context) error {
func (r AccountHandler) OIDCLogin(c *echo.Context) error {
var req OIDCLoginRequest
if err := c.Bind(&req); err != nil {
return err
@@ -69,13 +69,13 @@ func (r AccountHandler) OIDCLogin(c echo.Context) error {
}
// GetAuthConfig 获取认证配置
func (r AccountHandler) GetAuthConfig(c echo.Context) error {
func (r AccountHandler) GetAuthConfig(c *echo.Context) error {
config := r.accountService.GetAuthConfig()
return orz.Ok(c, config)
}
// GetOIDCAuthURL 获取 OIDC 认证 URL
func (r AccountHandler) GetOIDCAuthURL(c echo.Context) error {
func (r AccountHandler) GetOIDCAuthURL(c *echo.Context) error {
authURL, err := r.accountService.GetOIDCAuthURL()
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, err.Error())
@@ -84,7 +84,7 @@ func (r AccountHandler) GetOIDCAuthURL(c echo.Context) error {
}
// GetGitHubAuthURL 获取 GitHub 认证 URL
func (r AccountHandler) GetGitHubAuthURL(c echo.Context) error {
func (r AccountHandler) GetGitHubAuthURL(c *echo.Context) error {
authURL, err := r.accountService.GetGitHubAuthURL()
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, err.Error())
@@ -99,7 +99,7 @@ type GitHubLoginRequest struct {
}
// GitHubLogin GitHub 登录回调
func (r AccountHandler) GitHubLogin(c echo.Context) error {
func (r AccountHandler) GitHubLogin(c *echo.Context) error {
var req GitHubLoginRequest
if err := c.Bind(&req); err != nil {
return err
@@ -118,7 +118,7 @@ func (r AccountHandler) GitHubLogin(c echo.Context) error {
}
// Logout 用户登出
func (r AccountHandler) Logout(c echo.Context) error {
func (r AccountHandler) Logout(c *echo.Context) error {
userID := c.Get("userID")
if userID == nil {
return orz.NewError(401, "未登录")
@@ -138,7 +138,7 @@ func (r AccountHandler) ValidateToken(tokenString string) (*service.JWTClaims, e
}
// GetCurrentUser 获取当前登录用户信息
func (r AccountHandler) GetCurrentUser(c echo.Context) error {
func (r AccountHandler) GetCurrentUser(c *echo.Context) error {
// 从 context 中获取用户信息(由 JWT 中间件设置)
userID := c.Get("userID")
username := c.Get("username")
+16 -16
View File
@@ -10,7 +10,7 @@ import (
"github.com/dushixiang/pika/internal/models"
"github.com/dushixiang/pika/internal/protocol"
"github.com/go-orz/orz"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v5"
"go.uber.org/zap"
)
@@ -31,7 +31,7 @@ func SortAgents(agents []models.Agent) {
}
// Paging 探针分页查询(返回完整列表,前端实现过滤)
func (h *AgentHandler) Paging(c echo.Context) error {
func (h *AgentHandler) Paging(c *echo.Context) error {
ctx := c.Request().Context()
// 获取所有探针(管理员接口)
@@ -47,7 +47,7 @@ func (h *AgentHandler) Paging(c echo.Context) error {
}
// GetForAdmin 获取探针详情(管理员接口,显示完整信息)
func (h *AgentHandler) GetForAdmin(c echo.Context) error {
func (h *AgentHandler) GetForAdmin(c *echo.Context) error {
id := c.Param("id")
ctx := c.Request().Context()
@@ -60,7 +60,7 @@ func (h *AgentHandler) GetForAdmin(c echo.Context) error {
}
// GetAdminLatestMetrics 获取探针最新指标(管理员接口,显示完整信息)
func (h *AgentHandler) GetAdminLatestMetrics(c echo.Context) error {
func (h *AgentHandler) GetAdminLatestMetrics(c *echo.Context) error {
id := c.Param("id")
metrics, ok := h.metricService.GetLatestMetrics(id)
@@ -71,7 +71,7 @@ func (h *AgentHandler) GetAdminLatestMetrics(c echo.Context) error {
}
// SendCommand 向探针发送指令
func (h *AgentHandler) SendCommand(c echo.Context) error {
func (h *AgentHandler) SendCommand(c *echo.Context) error {
agentID := c.Param("id")
cmdType := c.QueryParam("type")
@@ -116,7 +116,7 @@ func (h *AgentHandler) SendCommand(c echo.Context) error {
}
// GetAuditResult 获取审计结果(原始数据)
func (h *AgentHandler) GetAuditResult(c echo.Context) error {
func (h *AgentHandler) GetAuditResult(c *echo.Context) error {
agentID := c.Param("id")
ctx := c.Request().Context()
@@ -129,7 +129,7 @@ func (h *AgentHandler) GetAuditResult(c echo.Context) error {
}
// ListAuditResults 获取审计结果列表
func (h *AgentHandler) ListAuditResults(c echo.Context) error {
func (h *AgentHandler) ListAuditResults(c *echo.Context) error {
agentID := c.Param("id")
ctx := c.Request().Context()
@@ -145,7 +145,7 @@ func (h *AgentHandler) ListAuditResults(c echo.Context) error {
}
// UpdateInfo 更新探针信息(名称、标签、到期时间、可见性、权重、备注)
func (h *AgentHandler) UpdateInfo(c echo.Context) error {
func (h *AgentHandler) UpdateInfo(c *echo.Context) error {
agentID := c.Param("id")
var req struct {
@@ -182,7 +182,7 @@ func (h *AgentHandler) UpdateInfo(c echo.Context) error {
}
// GetStatistics 获取探针统计数据
func (h *AgentHandler) GetStatistics(c echo.Context) error {
func (h *AgentHandler) GetStatistics(c *echo.Context) error {
ctx := c.Request().Context()
stats, err := h.agentService.GetStatistics(ctx)
if err != nil {
@@ -193,7 +193,7 @@ func (h *AgentHandler) GetStatistics(c echo.Context) error {
}
// Delete 删除探针
func (h *AgentHandler) Delete(c echo.Context) error {
func (h *AgentHandler) Delete(c *echo.Context) error {
agentID := c.Param("id")
ctx := c.Request().Context()
@@ -246,7 +246,7 @@ func (h *AgentHandler) Delete(c echo.Context) error {
}
// CleanupOrphanedAgentMetrics 手动清除所有已删除探针残留的指标数据
func (h *AgentHandler) CleanupOrphanedAgentMetrics(c echo.Context) error {
func (h *AgentHandler) CleanupOrphanedAgentMetrics(c *echo.Context) error {
ctx := c.Request().Context()
h.logger.Info("开始手动清理残留探针指标数据")
@@ -264,7 +264,7 @@ func (h *AgentHandler) CleanupOrphanedAgentMetrics(c echo.Context) error {
}
// BatchUpdateTags 批量更新探针标签
func (h *AgentHandler) BatchUpdateTags(c echo.Context) error {
func (h *AgentHandler) BatchUpdateTags(c *echo.Context) error {
var req struct {
AgentIDs []string `json:"agentIds"`
Tags []string `json:"tags"`
@@ -300,7 +300,7 @@ func (h *AgentHandler) BatchUpdateTags(c echo.Context) error {
}
// BatchUpdateVisibility 批量更新探针可见性
func (h *AgentHandler) BatchUpdateVisibility(c echo.Context) error {
func (h *AgentHandler) BatchUpdateVisibility(c *echo.Context) error {
var req struct {
AgentIDs []string `json:"agentIds"`
Visibility string `json:"visibility"`
@@ -331,7 +331,7 @@ func (h *AgentHandler) BatchUpdateVisibility(c echo.Context) error {
}
// UpdateTrafficConfig 更新流量配置(管理员)
func (h *AgentHandler) UpdateTrafficConfig(c echo.Context) error {
func (h *AgentHandler) UpdateTrafficConfig(c *echo.Context) error {
agentID := c.Param("id")
var req struct {
@@ -354,7 +354,7 @@ func (h *AgentHandler) UpdateTrafficConfig(c echo.Context) error {
}
// GetTrafficStats 查询流量统计(管理员接口)
func (h *AgentHandler) GetTrafficStats(c echo.Context) error {
func (h *AgentHandler) GetTrafficStats(c *echo.Context) error {
agentID := c.Param("id")
ctx := c.Request().Context()
@@ -367,7 +367,7 @@ func (h *AgentHandler) GetTrafficStats(c echo.Context) error {
}
// ResetAgentTraffic 手动重置流量(管理员)
func (h *AgentHandler) ResetAgentTraffic(c echo.Context) error {
func (h *AgentHandler) ResetAgentTraffic(c *echo.Context) error {
agentID := c.Param("id")
ctx := c.Request().Context()
+6 -6
View File
@@ -9,19 +9,19 @@ import (
"github.com/dushixiang/pika/internal/assets"
"github.com/dushixiang/pika/pkg/version"
"github.com/go-orz/orz"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v5"
"go.uber.org/zap"
)
// GetAgentVersion 获取 Agent 版本信息
func (h *AgentHandler) GetAgentVersion(c echo.Context) error {
func (h *AgentHandler) GetAgentVersion(c *echo.Context) error {
return orz.Ok(c, orz.Map{
"version": version.GetAgentVersion(),
})
}
// DownloadAgent 下载 Agent 二进制文件
func (h *AgentHandler) DownloadAgent(c echo.Context) error {
func (h *AgentHandler) DownloadAgent(c *echo.Context) error {
filename := c.Param("filename")
if filename == "" || strings.ContainsAny(filename, `/\`) {
return orz.NewError(400, "无效的 Agent 文件名")
@@ -63,7 +63,7 @@ func (h *AgentHandler) DownloadAgent(c echo.Context) error {
}
// getServerURL 获取服务器地址(仅从配置读取)
func (h *AgentHandler) getServerURL(c echo.Context) string {
func (h *AgentHandler) getServerURL(c *echo.Context) string {
// 优先读取配置的服务端地址
config, err := h.propertyService.GetAgentInstallConfig(c.Request().Context())
if err == nil && config.ServerURL != "" {
@@ -80,7 +80,7 @@ func bashSingleQuote(value string) string {
return "'" + strings.ReplaceAll(value, "'", "'\"'\"'") + "'"
}
func (h *AgentHandler) GetServerUrl(c echo.Context) error {
func (h *AgentHandler) GetServerUrl(c *echo.Context) error {
serverUrl := h.getServerURL(c)
return orz.Ok(c, orz.Map{
"serverUrl": serverUrl,
@@ -88,7 +88,7 @@ func (h *AgentHandler) GetServerUrl(c echo.Context) error {
}
// GetInstallScript 生成自动安装脚本
func (h *AgentHandler) GetInstallScript(c echo.Context) error {
func (h *AgentHandler) GetInstallScript(c *echo.Context) error {
token := c.QueryParam("token")
if token == "" {
return orz.NewError(400, "token不能为空")
+4 -4
View File
@@ -7,7 +7,7 @@ import (
"github.com/dushixiang/pika/internal/utils"
"github.com/go-orz/orz"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v5"
)
var validMetricTypes = map[string]struct{}{
@@ -93,7 +93,7 @@ func validateMetricType(metricType string) error {
}
// GetMetrics 获取探针聚合指标(公开接口,已登录返回全部,未登录返回公开可见)
func (h *AgentHandler) GetMetrics(c echo.Context) error {
func (h *AgentHandler) GetMetrics(c *echo.Context) error {
shortID := c.Param("id")
ctx := c.Request().Context()
@@ -132,7 +132,7 @@ func (h *AgentHandler) GetMetrics(c echo.Context) error {
}
// GetLatestMetrics 获取探针最新指标(公开接口,已登录返回全部,未登录返回公开可见)
func (h *AgentHandler) GetLatestMetrics(c echo.Context) error {
func (h *AgentHandler) GetLatestMetrics(c *echo.Context) error {
shortID := c.Param("id")
ctx := c.Request().Context()
@@ -156,7 +156,7 @@ func (h *AgentHandler) GetLatestMetrics(c echo.Context) error {
}
// GetAvailableNetworkInterfaces 获取探针的可用网卡列表(公开接口,已登录返回全部,未登录返回公开可见)
func (h *AgentHandler) GetAvailableNetworkInterfaces(c echo.Context) error {
func (h *AgentHandler) GetAvailableNetworkInterfaces(c *echo.Context) error {
shortID := c.Param("id")
ctx := c.Request().Context()
+4 -4
View File
@@ -4,12 +4,12 @@ import (
"github.com/dushixiang/pika/internal/models"
"github.com/dushixiang/pika/internal/utils"
"github.com/go-orz/orz"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v5"
"gorm.io/datatypes"
)
// Get 获取探针详情(公开接口,已登录返回全部,未登录返回公开可见)
func (h *AgentHandler) Get(c echo.Context) error {
func (h *AgentHandler) Get(c *echo.Context) error {
id := c.Param("id")
ctx := c.Request().Context()
@@ -36,7 +36,7 @@ func (h *AgentHandler) Get(c echo.Context) error {
}
// GetAgents 获取探针列表(公开接口,已登录返回全部,未登录返回公开可见)
func (h *AgentHandler) GetAgents(c echo.Context) error {
func (h *AgentHandler) GetAgents(c *echo.Context) error {
ctx := c.Request().Context()
// 根据认证状态返回相应的探针列表
@@ -93,7 +93,7 @@ func (h *AgentHandler) buildAgentListItem(agent models.Agent, isAuthenticated bo
}
// GetTags 获取所有探针的标签
func (h *AgentHandler) GetTags(c echo.Context) error {
func (h *AgentHandler) GetTags(c *echo.Context) error {
ctx := c.Request().Context()
tags, err := h.agentService.GetAllTags(ctx)
+2 -2
View File
@@ -9,12 +9,12 @@ import (
"github.com/dushixiang/pika/internal/protocol"
ws "github.com/dushixiang/pika/internal/websocket"
"github.com/gorilla/websocket"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v5"
"go.uber.org/zap"
)
// HandleWebSocket 处理WebSocket连接
func (h *AgentHandler) HandleWebSocket(c echo.Context) error {
func (h *AgentHandler) HandleWebSocket(c *echo.Context) error {
conn, err := h.upgrader.Upgrade(c.Response(), c.Request(), nil)
if err != nil {
h.logger.Error("failed to upgrade websocket", zap.Error(err))
+3 -3
View File
@@ -3,7 +3,7 @@ package handler
import (
"github.com/dushixiang/pika/internal/service"
"github.com/go-orz/orz"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v5"
"go.uber.org/zap"
)
@@ -20,7 +20,7 @@ func NewAlertHandler(logger *zap.Logger, alertService *service.AlertService) *Al
}
// ListAlertRecords 列出告警记录
func (h *AlertHandler) ListAlertRecords(c echo.Context) error {
func (h *AlertHandler) ListAlertRecords(c *echo.Context) error {
agentID := c.QueryParam("agentId")
pr := orz.GetPageRequest(c, "createdAt", "firedAt")
@@ -43,7 +43,7 @@ func (h *AlertHandler) ListAlertRecords(c echo.Context) error {
}
// ClearAlertRecords 清空告警记录
func (h *AlertHandler) ClearAlertRecords(c echo.Context) error {
func (h *AlertHandler) ClearAlertRecords(c *echo.Context) error {
if err := h.alertService.Clear(c.Request().Context()); err != nil {
h.logger.Error("清空告警记录失败", zap.Error(err))
return orz.NewError(500, "清空告警记录失败")
+10 -10
View File
@@ -5,7 +5,7 @@ import (
"github.com/dushixiang/pika/internal/service"
"github.com/go-orz/orz"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v5"
"go.uber.org/zap"
)
@@ -33,7 +33,7 @@ type UpdateApiKeyNameRequest struct {
}
// Paging API密钥分页查询
func (r ApiKeyHandler) Paging(c echo.Context) error {
func (r ApiKeyHandler) Paging(c *echo.Context) error {
name := c.QueryParam("name")
apiKeyType := c.QueryParam("type")
@@ -62,7 +62,7 @@ func (r ApiKeyHandler) Paging(c echo.Context) error {
}
// Create 生成API密钥(仅限通信密钥 type=agent)
func (r ApiKeyHandler) Create(c echo.Context) error {
func (r ApiKeyHandler) Create(c *echo.Context) error {
// API Key 不能创建其他 API Key
if c.Get("authType") == "api_key" {
return echo.NewHTTPError(http.StatusForbidden, "API Key 不能创建其他 API Key")
@@ -93,7 +93,7 @@ func (r ApiKeyHandler) Create(c echo.Context) error {
}
// CreateAdmin 生成管理 API Key(type=admin,完整 key 仅创建时返回一次)
func (r ApiKeyHandler) CreateAdmin(c echo.Context) error {
func (r ApiKeyHandler) CreateAdmin(c *echo.Context) error {
// API Key 不能创建其他 API Key
if c.Get("authType") == "api_key" {
return echo.NewHTTPError(http.StatusForbidden, "API Key 不能创建其他 API Key")
@@ -120,7 +120,7 @@ func (r ApiKeyHandler) CreateAdmin(c echo.Context) error {
}
// Get 获取API密钥详情
func (r ApiKeyHandler) Get(c echo.Context) error {
func (r ApiKeyHandler) Get(c *echo.Context) error {
// API Key 不能查看其他 API Key 的完整值
if c.Get("authType") == "api_key" {
return echo.NewHTTPError(http.StatusForbidden, "API Key 不能查看其他 API Key")
@@ -141,7 +141,7 @@ func (r ApiKeyHandler) Get(c echo.Context) error {
}
// GetRaw 获取API密钥完整值(仅在生成安装命令等场景使用)
func (r ApiKeyHandler) GetRaw(c echo.Context) error {
func (r ApiKeyHandler) GetRaw(c *echo.Context) error {
// 仅 JWT 认证可用
if c.Get("authType") == "api_key" {
return echo.NewHTTPError(http.StatusForbidden, "API Key 不能查看其他 API Key")
@@ -167,7 +167,7 @@ func (r ApiKeyHandler) GetRaw(c echo.Context) error {
}
// Update 更新API密钥名称
func (r ApiKeyHandler) Update(c echo.Context) error {
func (r ApiKeyHandler) Update(c *echo.Context) error {
// API Key 不能修改其他 API Key
if c.Get("authType") == "api_key" {
return echo.NewHTTPError(http.StatusForbidden, "API Key 不能修改其他 API Key")
@@ -193,7 +193,7 @@ func (r ApiKeyHandler) Update(c echo.Context) error {
}
// Delete 删除API密钥
func (r ApiKeyHandler) Delete(c echo.Context) error {
func (r ApiKeyHandler) Delete(c *echo.Context) error {
// API Key 不能删除其他 API Key
if c.Get("authType") == "api_key" {
return echo.NewHTTPError(http.StatusForbidden, "API Key 不能删除其他 API Key")
@@ -211,7 +211,7 @@ func (r ApiKeyHandler) Delete(c echo.Context) error {
}
// Enable 启用API密钥
func (r ApiKeyHandler) Enable(c echo.Context) error {
func (r ApiKeyHandler) Enable(c *echo.Context) error {
// API Key 不能启用/禁用其他 API Key
if c.Get("authType") == "api_key" {
return echo.NewHTTPError(http.StatusForbidden, "API Key 不能启用/禁用其他 API Key")
@@ -229,7 +229,7 @@ func (r ApiKeyHandler) Enable(c echo.Context) error {
}
// Disable 禁用API密钥
func (r ApiKeyHandler) Disable(c echo.Context) error {
func (r ApiKeyHandler) Disable(c *echo.Context) error {
// API Key 不能启用/禁用其他 API Key
if c.Get("authType") == "api_key" {
return echo.NewHTTPError(http.StatusForbidden, "API Key 不能启用/禁用其他 API Key")
+10 -10
View File
@@ -7,7 +7,7 @@ import (
"github.com/dushixiang/pika/internal/service"
"github.com/go-orz/orz"
"github.com/google/uuid"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v5"
"go.uber.org/zap"
)
@@ -53,7 +53,7 @@ type UpdateConfigRequest struct {
}
// Paging DDNS 配置分页查询
func (h *DDNSHandler) Paging(c echo.Context) error {
func (h *DDNSHandler) Paging(c *echo.Context) error {
agentID := c.QueryParam("agentId")
name := c.QueryParam("name")
@@ -80,7 +80,7 @@ func (h *DDNSHandler) Paging(c echo.Context) error {
}
// Create 创建 DDNS 配置
func (h *DDNSHandler) Create(c echo.Context) error {
func (h *DDNSHandler) Create(c *echo.Context) error {
var req CreateConfigRequest
if err := c.Bind(&req); err != nil {
return err
@@ -144,7 +144,7 @@ func (h *DDNSHandler) Create(c echo.Context) error {
}
// Get 获取 DDNS 配置详情
func (h *DDNSHandler) Get(c echo.Context) error {
func (h *DDNSHandler) Get(c *echo.Context) error {
id := c.Param("id")
ctx := c.Request().Context()
@@ -158,7 +158,7 @@ func (h *DDNSHandler) Get(c echo.Context) error {
}
// Update 更新 DDNS 配置
func (h *DDNSHandler) Update(c echo.Context) error {
func (h *DDNSHandler) Update(c *echo.Context) error {
id := c.Param("id")
var req UpdateConfigRequest
@@ -200,7 +200,7 @@ func (h *DDNSHandler) Update(c echo.Context) error {
}
// Delete 删除 DDNS 配置
func (h *DDNSHandler) Delete(c echo.Context) error {
func (h *DDNSHandler) Delete(c *echo.Context) error {
id := c.Param("id")
ctx := c.Request().Context()
@@ -213,7 +213,7 @@ func (h *DDNSHandler) Delete(c echo.Context) error {
}
// Enable 启用 DDNS 配置
func (h *DDNSHandler) Enable(c echo.Context) error {
func (h *DDNSHandler) Enable(c *echo.Context) error {
id := c.Param("id")
ctx := c.Request().Context()
@@ -226,7 +226,7 @@ func (h *DDNSHandler) Enable(c echo.Context) error {
}
// Disable 禁用 DDNS 配置
func (h *DDNSHandler) Disable(c echo.Context) error {
func (h *DDNSHandler) Disable(c *echo.Context) error {
id := c.Param("id")
ctx := c.Request().Context()
@@ -239,7 +239,7 @@ func (h *DDNSHandler) Disable(c echo.Context) error {
}
// GetRecords 获取 DDNS 更新记录
func (h *DDNSHandler) GetRecords(c echo.Context) error {
func (h *DDNSHandler) GetRecords(c *echo.Context) error {
id := c.Param("id")
ctx := c.Request().Context()
@@ -257,7 +257,7 @@ func (h *DDNSHandler) GetRecords(c echo.Context) error {
}
// TriggerUpdate 手动触发 DDNS 更新
func (h *DDNSHandler) TriggerUpdate(c echo.Context) error {
func (h *DDNSHandler) TriggerUpdate(c *echo.Context) error {
id := c.Param("id")
ctx := c.Request().Context()
+4 -4
View File
@@ -7,7 +7,7 @@ import (
"github.com/dushixiang/pika/internal/models"
"github.com/dushixiang/pika/internal/service"
"github.com/go-orz/orz"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v5"
"go.uber.org/zap"
)
@@ -69,7 +69,7 @@ func maskSensitiveData(config map[string]interface{}) map[string]interface{} {
}
// GetAll 获取所有 DNS Provider 配置(脱敏)
func (h *DNSProviderHandler) GetAll(c echo.Context) error {
func (h *DNSProviderHandler) GetAll(c *echo.Context) error {
ctx := c.Request().Context()
providers, err := h.propertyService.GetDNSProviderConfigs(ctx)
@@ -92,7 +92,7 @@ func (h *DNSProviderHandler) GetAll(c echo.Context) error {
}
// Upsert 创建或更新 DNS Provider 配置
func (h *DNSProviderHandler) Upsert(c echo.Context) error {
func (h *DNSProviderHandler) Upsert(c *echo.Context) error {
ctx := c.Request().Context()
var req DNSProviderRequest
@@ -131,7 +131,7 @@ func (h *DNSProviderHandler) Upsert(c echo.Context) error {
}
// Delete 删除 DNS Provider 配置
func (h *DNSProviderHandler) Delete(c echo.Context) error {
func (h *DNSProviderHandler) Delete(c *echo.Context) error {
ctx := c.Request().Context()
provider := c.Param("provider")
+10 -10
View File
@@ -4,7 +4,7 @@ import (
"github.com/dushixiang/pika/internal/service"
"github.com/dushixiang/pika/internal/utils"
"github.com/go-orz/orz"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v5"
"go.uber.org/zap"
)
@@ -24,7 +24,7 @@ func NewMonitorHandler(logger *zap.Logger, monitorService *service.MonitorServic
}
}
func (h *MonitorHandler) List(c echo.Context) error {
func (h *MonitorHandler) List(c *echo.Context) error {
keyword := c.QueryParam("keyword")
enabled := c.QueryParam("enabled")
@@ -76,7 +76,7 @@ func (h *MonitorHandler) List(c echo.Context) error {
return orz.Ok(c, page)
}
func (h *MonitorHandler) Create(c echo.Context) error {
func (h *MonitorHandler) Create(c *echo.Context) error {
var req service.MonitorTaskRequest
if err := c.Bind(&req); err != nil {
return orz.NewError(400, "请求参数错误")
@@ -91,7 +91,7 @@ func (h *MonitorHandler) Create(c echo.Context) error {
return orz.Ok(c, item)
}
func (h *MonitorHandler) Get(c echo.Context) error {
func (h *MonitorHandler) Get(c *echo.Context) error {
id := c.Param("id")
ctx := c.Request().Context()
@@ -103,7 +103,7 @@ func (h *MonitorHandler) Get(c echo.Context) error {
return orz.Ok(c, item)
}
func (h *MonitorHandler) Update(c echo.Context) error {
func (h *MonitorHandler) Update(c *echo.Context) error {
id := c.Param("id")
var req service.MonitorTaskRequest
@@ -120,7 +120,7 @@ func (h *MonitorHandler) Update(c echo.Context) error {
return orz.Ok(c, item)
}
func (h *MonitorHandler) Delete(c echo.Context) error {
func (h *MonitorHandler) Delete(c *echo.Context) error {
id := c.Param("id")
ctx := c.Request().Context()
@@ -140,7 +140,7 @@ func (h *MonitorHandler) Delete(c echo.Context) error {
}
// GetMonitors 获取所有监控统计数据
func (h *MonitorHandler) GetMonitors(c echo.Context) error {
func (h *MonitorHandler) GetMonitors(c *echo.Context) error {
ctx := c.Request().Context()
stats, err := h.monitorService.ListByAuth(ctx, utils.IsAuthenticated(c))
if err != nil {
@@ -151,7 +151,7 @@ func (h *MonitorHandler) GetMonitors(c echo.Context) error {
}
// GetStatsByID 获取指定监控任务的统计数据(公开接口,已登录返回全部,未登录返回公开可见)
func (h *MonitorHandler) GetStatsByID(c echo.Context) error {
func (h *MonitorHandler) GetStatsByID(c *echo.Context) error {
id := c.Param("id")
ctx := c.Request().Context()
@@ -169,7 +169,7 @@ func (h *MonitorHandler) GetStatsByID(c echo.Context) error {
}
// GetAgentStatsByID 获取指定监控任务各探针的统计数据(公开接口,已登录返回全部,未登录返回公开可见)
func (h *MonitorHandler) GetAgentStatsByID(c echo.Context) error {
func (h *MonitorHandler) GetAgentStatsByID(c *echo.Context) error {
id := c.Param("id")
ctx := c.Request().Context()
@@ -186,7 +186,7 @@ func (h *MonitorHandler) GetAgentStatsByID(c echo.Context) error {
}
// GetHistoryByID 获取指定监控任务的历史响应时间数据(公开接口,已登录返回全部,未登录返回公开可见)
func (h *MonitorHandler) GetHistoryByID(c echo.Context) error {
func (h *MonitorHandler) GetHistoryByID(c *echo.Context) error {
id := c.Param("id")
ctx := c.Request().Context()
+5 -5
View File
@@ -9,7 +9,7 @@ import (
"github.com/dushixiang/pika/internal/models"
"github.com/dushixiang/pika/internal/service"
"github.com/go-orz/orz"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v5"
"go.uber.org/zap"
)
@@ -28,7 +28,7 @@ func NewPropertyHandler(logger *zap.Logger, service *service.PropertyService, no
}
// GetProperty 获取属性(返回 JSON 值)
func (h *PropertyHandler) GetProperty(c echo.Context) error {
func (h *PropertyHandler) GetProperty(c *echo.Context) error {
id := c.Param("id")
property, err := h.service.Get(c.Request().Context(), id)
@@ -54,7 +54,7 @@ func (h *PropertyHandler) GetProperty(c echo.Context) error {
}
// SetProperty 设置属性
func (h *PropertyHandler) SetProperty(c echo.Context) error {
func (h *PropertyHandler) SetProperty(c *echo.Context) error {
id := c.Param("id")
var req struct {
@@ -100,7 +100,7 @@ func (h *PropertyHandler) SetProperty(c echo.Context) error {
}
// GetLogo 获取系统 Logo(公开访问,返回图片文件流)
func (h *PropertyHandler) GetLogo(c echo.Context) error {
func (h *PropertyHandler) GetLogo(c *echo.Context) error {
sysConfig, err := h.service.GetSystemConfig(c.Request().Context())
if err != nil {
// 如果配置不存在,返回 404
@@ -168,7 +168,7 @@ func (h *PropertyHandler) GetLogo(c echo.Context) error {
}
// TestNotificationChannel 测试通知渠道(从数据库读取配置)
func (h *PropertyHandler) TestNotificationChannel(c echo.Context) error {
func (h *PropertyHandler) TestNotificationChannel(c *echo.Context) error {
channelType := c.Param("type")
if channelType == "" {
return orz.NewError(400, "缺少渠道类型参数")
+6 -6
View File
@@ -4,7 +4,7 @@ import (
"github.com/dushixiang/pika/internal/models"
"github.com/dushixiang/pika/internal/service"
"github.com/go-orz/orz"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v5"
"go.uber.org/zap"
)
@@ -24,7 +24,7 @@ func NewSSHLoginHandler(logger *zap.Logger, service *service.SSHLoginService) *S
// GetConfig 获取SSH登录监控配置
// GET /api/agents/:id/ssh-login/config
func (h *SSHLoginHandler) GetConfig(c echo.Context) error {
func (h *SSHLoginHandler) GetConfig(c *echo.Context) error {
agentID := c.Param("id")
if agentID == "" {
return orz.NewError(400, "探针ID不能为空")
@@ -41,7 +41,7 @@ func (h *SSHLoginHandler) GetConfig(c echo.Context) error {
// UpdateConfig 更新SSH登录监控配置
// POST /api/agents/:id/ssh-login/config
func (h *SSHLoginHandler) UpdateConfig(c echo.Context) error {
func (h *SSHLoginHandler) UpdateConfig(c *echo.Context) error {
agentID := c.Param("id")
var req models.SSHLoginConfigData
@@ -60,7 +60,7 @@ func (h *SSHLoginHandler) UpdateConfig(c echo.Context) error {
// ListEvents 查询SSH登录事件
// GET /api/agents/:id/ssh-login/events
func (h *SSHLoginHandler) ListEvents(c echo.Context) error {
func (h *SSHLoginHandler) ListEvents(c *echo.Context) error {
agentID := c.Param("id")
// 获取分页参数
@@ -83,7 +83,7 @@ func (h *SSHLoginHandler) ListEvents(c echo.Context) error {
// GetEvent 获取单个SSH登录事件
// GET /api/ssh-login/events/:id
func (h *SSHLoginHandler) GetEvent(c echo.Context) error {
func (h *SSHLoginHandler) GetEvent(c *echo.Context) error {
eventID := c.Param("id")
if eventID == "" {
return orz.NewError(400, "事件ID不能为空")
@@ -105,7 +105,7 @@ func (h *SSHLoginHandler) GetEvent(c echo.Context) error {
// DeleteEvents 删除探针的所有SSH登录事件
// DELETE /api/agents/:id/ssh-login/events
func (h *SSHLoginHandler) DeleteEvents(c echo.Context) error {
func (h *SSHLoginHandler) DeleteEvents(c *echo.Context) error {
agentID := c.Param("id")
ctx := c.Request().Context()
+5 -5
View File
@@ -4,7 +4,7 @@ import (
"github.com/dushixiang/pika/internal/models"
"github.com/dushixiang/pika/internal/service"
"github.com/go-orz/orz"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v5"
"go.uber.org/zap"
)
@@ -22,7 +22,7 @@ func NewTamperHandler(logger *zap.Logger, tamperService *service.TamperService)
// UpdateConfig 更新探针的防篡改配置
// POST /api/agents/:id/tamper/config
func (h *TamperHandler) UpdateConfig(c echo.Context) error {
func (h *TamperHandler) UpdateConfig(c *echo.Context) error {
agentID := c.Param("id")
var req models.TamperProtectConfigData
@@ -42,7 +42,7 @@ func (h *TamperHandler) UpdateConfig(c echo.Context) error {
// GetConfig 获取探针的防篡改配置
// GET /api/agents/:id/tamper/config
func (h *TamperHandler) GetConfig(c echo.Context) error {
func (h *TamperHandler) GetConfig(c *echo.Context) error {
agentID := c.Param("id")
config, err := h.tamperService.GetConfigByAgentID(c.Request().Context(), agentID)
@@ -56,7 +56,7 @@ func (h *TamperHandler) GetConfig(c echo.Context) error {
// ListEvents 获取探针的防篡改事件
// GET /api/agents/:id/tamper/events
func (h *TamperHandler) ListEvents(c echo.Context) error {
func (h *TamperHandler) ListEvents(c *echo.Context) error {
agentID := c.Param("id")
// 获取分页参数
@@ -77,7 +77,7 @@ func (h *TamperHandler) ListEvents(c echo.Context) error {
return orz.Ok(c, page)
}
func (h *TamperHandler) DeleteEvents(c echo.Context) error {
func (h *TamperHandler) DeleteEvents(c *echo.Context) error {
agentID := c.Param("id")
err := h.tamperService.DeleteEventsByAgentID(c.Request().Context(), agentID)
if err != nil {