实现云端控制的动态节点分配逻辑

This commit is contained in:
2025-03-28 10:03:29 +08:00
parent e337a9c08e
commit e61f0bef32
16 changed files with 1313 additions and 138 deletions

View File

@@ -12,11 +12,13 @@ import (
// region CreateChannel
type CreateChannelReq struct {
Region string `json:"region" validate:"required"`
Provider string `json:"provider" validate:"required"`
ResourceId int32 `json:"resource_id" validate:"required"`
Protocol services.ChannelProtocol `json:"protocol" validate:"required,oneof=socks5 http https"`
ResourceId int `json:"resource_id" validate:"required"`
AuthType services.ChannelAuthType `json:"auth_type" validate:"required,oneof=0 1"`
Count int `json:"count" validate:"required"`
Prov string `json:"prov" validate:"required"`
City string `json:"city" validate:"required"`
Isp string `json:"isp" validate:"required"`
ResultType CreateChannelResultType `json:"return_type" validate:"required,oneof=json text"`
ResultSeparator CreateChannelResultSeparator `json:"return_separator" validate:"required,oneof=enter line both tab"`
}
@@ -33,13 +35,18 @@ func CreateChannel(c *fiber.Ctx) error {
return errors.New("user not found")
}
channels, err := services.Channel.CreateChannel(
auth.Payload.Id,
req.Region,
req.Provider,
req.Protocol,
channels, err := services.Channel.RemoteCreateChannel(
c.Context(),
auth,
req.ResourceId,
req.Protocol,
req.AuthType,
req.Count,
services.NodeFilterConfig{
Isp: req.Isp,
Prov: req.Prov,
City: req.City,
},
)
if err != nil {
return err
@@ -48,7 +55,7 @@ func CreateChannel(c *fiber.Ctx) error {
// 返回连接通道列表
var result []string
for _, channel := range channels {
url := fmt.Sprintf("%s://%s:%d", channel.Protocol, channel.UserHost, channel.NodePort)
url := fmt.Sprintf("%s://%s:%d", channel.Protocol, channel.UserHost, channel.ProxyPort)
result = append(result, url)
}