From 9043dd779b2c12e06605c470f05e2462709f8665 Mon Sep 17 00:00:00 2001 From: luorijun Date: Thu, 15 May 2025 15:59:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AC=E5=8F=91=E6=9C=8D=E5=8A=A1=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E5=90=8E=E6=8F=90=E4=BE=9B=E4=B8=80=E4=B8=AA=E5=AF=86?= =?UTF-8?q?=E9=92=A5=E7=94=A8=E4=BA=8E=E5=AE=89=E5=85=A8=E9=80=9A=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/handlers/proxy.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/web/handlers/proxy.go b/web/handlers/proxy.go index dc42c4c..a13c0e7 100644 --- a/web/handlers/proxy.go +++ b/web/handlers/proxy.go @@ -1,6 +1,7 @@ package handlers import ( + "crypto/rand" "github.com/gofiber/fiber/v2" "log/slog" auth2 "platform/web/auth" @@ -20,7 +21,8 @@ type OnlineProxyReq struct { } type OnlineProxyResp struct { - Id int32 `json:"id"` + Id int32 `json:"id"` + Secret string `json:"secret"` } func OnlineProxy(c *fiber.Ctx) (err error) { @@ -41,12 +43,14 @@ func OnlineProxy(c *fiber.Ctx) (err error) { } // 创建代理 - ip := c.Context().RemoteIP() + var ip = c.Context().RemoteIP() + var secret = rand.Text() var proxy = &m.Proxy{ Name: req.Name, Version: int32(req.Version), - Host: ip.String(), Type: int32(proxy2.TypeSelfHosted), + Host: ip.String(), + Secret: secret, Status: 1, } err = q.Proxy. @@ -63,7 +67,8 @@ func OnlineProxy(c *fiber.Ctx) (err error) { slog.Debug("注册转发服务", "ip", ip, "id", proxy.ID) return c.JSON(&OnlineProxyResp{ - Id: proxy.ID, + Id: proxy.ID, + Secret: secret, }) }