修复一些边界问题

This commit is contained in:
2026-04-17 16:27:29 +08:00
parent fd475d3e63
commit 6db3caaecb
6 changed files with 34 additions and 30 deletions

View File

@@ -23,10 +23,9 @@ import (
type channelBaiyinProvider struct{}
func (s *channelBaiyinProvider) CreateChannels(source netip.Addr, resourceId int32, authWhitelist bool, authPassword bool, count int, edgeFilter ...EdgeFilter) ([]*m.Channel, error) {
var filter *EdgeFilter = nil
if len(edgeFilter) > 0 {
filter = &edgeFilter[0]
func (s *channelBaiyinProvider) CreateChannels(source netip.Addr, resourceId int32, authWhitelist bool, authPassword bool, count int, filter *EdgeFilter) ([]*m.Channel, error) {
if filter == nil {
return nil, core.NewBizErr("缺少节点过滤条件")
}
now := time.Now()
@@ -86,7 +85,7 @@ func (s *channelBaiyinProvider) CreateChannels(source netip.Addr, resourceId int
return nil, core.NewBizErr("获取可用节点失败", err)
}
if edgesResp.Total != count && len(edgesResp.Edges) != count {
return nil, core.NewBizErr("地区可用节点数量不足 [%s, %s] [%s]")
return nil, core.NewBizErr("地区可用节点数量不足")
}
edges := edgesResp.Edges
@@ -98,10 +97,6 @@ func (s *channelBaiyinProvider) CreateChannels(source netip.Addr, resourceId int
ch := chans[i]
edge := edges[i]
if err != nil {
return nil, core.NewBizErr("解析通道地址失败", err)
}
// 通道数据
channels[i] = &m.Channel{
UserID: user.ID,
@@ -301,7 +296,7 @@ func (s *channelBaiyinProvider) RemoveChannels(batch string) error {
})
// 清空通道配置
secret := strings.Split(*proxy.Secret, ":")
secret := strings.Split(u.Z(proxy.Secret), ":")
gateway := g.NewGateway(proxy.IP.String(), secret[0], secret[1])
err := gateway.GatewayPortConfigs(configs)
if err != nil {
@@ -321,6 +316,6 @@ func (s *channelBaiyinProvider) RemoveChannels(batch string) error {
return err
}
slog.Debug("清除代理端口配置", "time", time.Since(start).String())
slog.Debug("清除代理端口配置", "duration", time.Since(start).String())
return nil
}