From 41dcc14f5f6bb7db93ed1f687eccb10ca35df385 Mon Sep 17 00:00:00 2001 From: luorijun Date: Wed, 28 May 2025 16:03:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E8=BE=B9=E7=BC=98=E8=8A=82=E7=82=B9=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=8D=E5=AE=8C=E5=85=A8=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++++- web/handlers/proxy.go | 21 ++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 15ff1c4..2d219ad 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,11 @@ ## TODO +### 长期 + 模型字段修改,特定枚举字段使用自定义类型代替通用 int32 +更新接口可以传输更结构化的数据,直接区分不同类型以加快更新速度 + ## 业务逻辑 ### 代理服务与节点的增量更新 @@ -19,7 +23,7 @@ | 0 | 保留位,预留扩展 | | 1 | 空,固定为 0 | | 2 | 空,固定为 0 | -| 3 | 端口 | +| 3 | 端口 | | 4 | 省份 | | 5 | 城市 | | 6 | 运营商 | diff --git a/web/handlers/proxy.go b/web/handlers/proxy.go index deded4f..7cdfaa2 100644 --- a/web/handlers/proxy.go +++ b/web/handlers/proxy.go @@ -217,12 +217,6 @@ func ProxyReportUpdate(c *fiber.Ctx) (err error) { var otherEdges = make([]*ProxyEdge, 0, len(req.Edges)) for _, edge := range req.Edges { - // 跳过不方便批量操作的边缘节点 - if edge.Port != nil || edge.Prov != nil || edge.City != nil { - otherEdges = append(otherEdges, edge) - continue - } - // 检查更新ISP if edge.Isp != nil { switch edge2.ISPFromStr(*edge.Isp) { @@ -245,15 +239,21 @@ func ProxyReportUpdate(c *fiber.Ctx) (err error) { idsInactive = append(idsInactive, edge.Id) } } + + // 无法分类更新 + if edge.Host != nil || edge.Port != nil || edge.Prov != nil || edge.City != nil { + otherEdges = append(otherEdges, edge) + continue + } } slog.Debug("更新边缘节点信息", "active", len(idsActive), "inactive", len(idsInactive), "isp_unknown", len(idsIspUnknown), - "isp_china_telecom", len(idsIspTelecom), - "isp_china_unicom", len(idsIspUnicom), - "isp_china_mobile", len(idsIspMobile), + "isp_telecom", len(idsIspTelecom), + "isp_unicom", len(idsIspUnicom), + "isp_mobile", len(idsIspMobile), "other_edges", len(otherEdges), ) @@ -319,6 +319,9 @@ func ProxyReportUpdate(c *fiber.Ctx) (err error) { do := q.Edge.Debug().Where(q.Edge.ID.Eq(edge.Id)) var assigns = make([]field.AssignExpr, 0, 5) + if edge.Host != nil { + assigns = append(assigns, q.Edge.Host.Value(*edge.Host)) + } if edge.Port != nil { assigns = append(assigns, q.Edge.ProxyPort.Value(*edge.Port)) }