修复通道注册失败问题
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
## TODO
|
||||
|
||||
考虑一个方案限制接口请求速率,无侵入更好
|
||||
|
||||
trade/create 性能问题,缩短事务时间,考虑其他方式实现可靠分布式事务
|
||||
|
||||
jsonb 类型转换问题,考虑一个高效的 any 到 struct 转换工具
|
||||
|
||||
端口资源池的 gc 实现
|
||||
|
||||
考虑一个方案限制接口请求速率,无侵入更好
|
||||
|
||||
标准化生产环境 cors 配置
|
||||
|
||||
|
||||
@@ -503,7 +503,7 @@ create table proxy (
|
||||
secret text,
|
||||
type int not null,
|
||||
status int not null,
|
||||
meta jsonb not null,
|
||||
meta jsonb,
|
||||
created_at timestamptz default current_timestamp,
|
||||
updated_at timestamptz default current_timestamp,
|
||||
deleted_at timestamptz
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"net/netip"
|
||||
"platform/pkg/env"
|
||||
g "platform/web/globals"
|
||||
"platform/web/core"
|
||||
s "platform/web/services"
|
||||
"time"
|
||||
|
||||
@@ -16,18 +15,9 @@ func DebugRegisterProxyBaiYin(c *fiber.Ctx) error {
|
||||
return fiber.ErrNotFound
|
||||
}
|
||||
|
||||
ok, err := g.Redis.SetNX(c.Context(), "debug:channel:register:127.0.0.1", true, 0).Result()
|
||||
err := s.Proxy.RegisterBaiyin("1a:2b:3c:4d:5e:6f", netip.AddrFrom4([4]byte{127, 0, 0, 1}), "test", "test")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
slog.Info("注册代理", "ok", ok)
|
||||
if !ok {
|
||||
return fiber.ErrConflict
|
||||
}
|
||||
|
||||
err = s.Proxy.RegisterBaiyin("1a:2b:3c:4d:5e:6f", netip.AddrFrom4([4]byte{127, 0, 0, 1}), "test", "test")
|
||||
if err != nil {
|
||||
return err
|
||||
return core.NewServErr("注册失败", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -73,11 +73,11 @@ func ApplyRouters(app *fiber.App) {
|
||||
edge.Post("/assign", handlers.AssignEdge)
|
||||
edge.Post("/all", handlers.AllEdgesAvailable)
|
||||
|
||||
callbacks := app.Group("/callback")
|
||||
callbacks.Get("/identify", handlers.IdentifyCallbackNew)
|
||||
|
||||
// 临时
|
||||
debug := app.Group("/debug")
|
||||
debug.Get("/sms/:phone", handlers.DebugGetSmsCode)
|
||||
debug.Get("/proxy/register", handlers.DebugRegisterProxyBaiYin)
|
||||
|
||||
callbacks := app.Group("/callback")
|
||||
callbacks.Get("/identify", handlers.IdentifyCallbackNew)
|
||||
}
|
||||
|
||||
@@ -261,8 +261,12 @@ local free_key = KEYS[1]
|
||||
local all_key = KEYS[2]
|
||||
local chans = ARGV
|
||||
|
||||
redis.call("SADD", free_key, unpack(chans))
|
||||
redis.call("SADD", all_key, unpack(chans))
|
||||
local batch_size = 5000
|
||||
for i = 1, #chans, batch_size do
|
||||
local end_index = math.min(i + batch_size - 1, #chans)
|
||||
redis.call("SADD", free_key, unpack(chans, i, end_index))
|
||||
redis.call("SADD", all_key, unpack(chans, i, end_index))
|
||||
end
|
||||
|
||||
return 1
|
||||
`
|
||||
|
||||
@@ -40,7 +40,7 @@ func (s *proxyService) RegisterBaiyin(Mac string, IP netip.Addr, username, passw
|
||||
}
|
||||
err := addChans(chans)
|
||||
if err != nil {
|
||||
return core.NewServErr("添加通道失败")
|
||||
return core.NewServErr("添加通道失败", err)
|
||||
}
|
||||
|
||||
// 保存代理信息
|
||||
|
||||
Reference in New Issue
Block a user