完善数据填充脚本 & 移除 cron 任务 & 兼容旧事件
This commit is contained in:
@@ -136,7 +136,12 @@ func (s *channelServer) RemoveChannels(batch string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := s.provider.removeRemote(batch, usedBatch); err != nil {
|
||||
provider, err := channelProviderByProxyID(usedBatch.ProxyID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := provider.removeRemote(batch, usedBatch); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := freeChans(usedBatch.ProxyID, batch); err != nil {
|
||||
@@ -407,6 +412,22 @@ func selectProxyByType(proxyType m.ProxyType, count int) (*m.Proxy, error) {
|
||||
return bestProxy, nil
|
||||
}
|
||||
|
||||
func channelProviderByProxyID(proxyID int32) (channelProvider, error) {
|
||||
proxy, err := q.Proxy.Where(q.Proxy.ID.Eq(proxyID)).Take()
|
||||
if err != nil {
|
||||
return nil, core.NewServErr("获取代理数据失败", err)
|
||||
}
|
||||
|
||||
switch proxy.Type {
|
||||
case m.ProxyTypeGost:
|
||||
return &channelGostProvider{}, nil
|
||||
case m.ProxyTypeBaiYin:
|
||||
return &channelBaiyinProvider{}, nil
|
||||
default:
|
||||
return nil, core.NewBizErr(fmt.Sprintf("不支持的代理类型: %d", proxy.Type))
|
||||
}
|
||||
}
|
||||
|
||||
func (s *channelServer) RefreshEdges() error {
|
||||
|
||||
// 仅白银网关支持边缘节点刷新,GOST 不参与此流程。
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"platform/web/core"
|
||||
g "platform/web/globals"
|
||||
m "platform/web/models"
|
||||
q "platform/web/queries"
|
||||
)
|
||||
|
||||
type channelBaiyinProvider struct{}
|
||||
@@ -68,30 +67,31 @@ func (s *channelBaiyinProvider) prepareCreate(ctx *channelCreateContext) (*chann
|
||||
}
|
||||
|
||||
func (s *channelBaiyinProvider) removeRemote(_ string, batch *usedChanBatch) error {
|
||||
configs := make([]*g.PortConfigsReq, len(batch.Chans))
|
||||
for i, ch := range batch.Chans {
|
||||
configs[i] = &g.PortConfigsReq{
|
||||
Port: int(ch.Port()),
|
||||
Edge: &[]string{},
|
||||
AutoEdgeConfig: &g.AutoEdgeConfig{Count: u.P(0)},
|
||||
Status: false,
|
||||
}
|
||||
}
|
||||
|
||||
proxy, err := q.Proxy.Where(q.Proxy.ID.Eq(batch.ProxyID)).Take()
|
||||
if err != nil {
|
||||
return core.NewServErr("获取代理数据失败", err)
|
||||
}
|
||||
|
||||
gateway, err := proxyGateway(proxy)
|
||||
if err != nil {
|
||||
return core.NewServErr("创建代理网关失败", err)
|
||||
}
|
||||
|
||||
if err = gateway.GatewayPortConfigs(configs); err != nil {
|
||||
return core.NewServErr(fmt.Sprintf("清空代理 %s 端口配置失败", proxy.IP.String()), err)
|
||||
}
|
||||
return nil
|
||||
// configs := make([]*g.PortConfigsReq, len(batch.Chans))
|
||||
// for i, ch := range batch.Chans {
|
||||
// configs[i] = &g.PortConfigsReq{
|
||||
// Port: int(ch.Port()),
|
||||
// Edge: &[]string{},
|
||||
// AutoEdgeConfig: &g.AutoEdgeConfig{Count: u.P(0)},
|
||||
// Status: false,
|
||||
// }
|
||||
// }
|
||||
|
||||
// proxy, err := q.Proxy.Where(q.Proxy.ID.Eq(batch.ProxyID)).Take()
|
||||
// if err != nil {
|
||||
// return core.NewServErr("获取代理数据失败", err)
|
||||
// }
|
||||
|
||||
// gateway, err := proxyGateway(proxy)
|
||||
// if err != nil {
|
||||
// return core.NewServErr("创建代理网关失败", err)
|
||||
// }
|
||||
|
||||
// if err = gateway.GatewayPortConfigs(configs); err != nil {
|
||||
// return core.NewServErr(fmt.Sprintf("清空代理 %s 端口配置失败", proxy.IP.String()), err)
|
||||
// }
|
||||
// return nil
|
||||
}
|
||||
|
||||
// ensureEdges 检查本地节点是否足够,如果不足从云端连入
|
||||
|
||||
Reference in New Issue
Block a user