基本完成远端配置的通道创建
This commit is contained in:
@@ -19,8 +19,8 @@ type CreateChannelReq struct {
|
||||
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"`
|
||||
ResultType CreateChannelResultType `json:"result_type" validate:"required,oneof=json text"`
|
||||
ResultSeparator CreateChannelResultSeparator `json:"result_separator" validate:"required,oneof=enter line both tab"`
|
||||
}
|
||||
|
||||
func CreateChannel(c *fiber.Ctx) error {
|
||||
@@ -30,12 +30,12 @@ func CreateChannel(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
// 建立连接通道
|
||||
auth, ok := c.Locals("user").(*services.AuthContext)
|
||||
auth, ok := c.Locals("auth").(*services.AuthContext)
|
||||
if !ok {
|
||||
return errors.New("user not found")
|
||||
}
|
||||
|
||||
channels, err := services.Channel.RemoteCreateChannel(
|
||||
assigns, err := services.Channel.RemoteCreateChannel(
|
||||
c.Context(),
|
||||
auth,
|
||||
req.ResourceId,
|
||||
@@ -54,9 +54,13 @@ func CreateChannel(c *fiber.Ctx) error {
|
||||
|
||||
// 返回连接通道列表
|
||||
var result []string
|
||||
for _, channel := range channels {
|
||||
url := fmt.Sprintf("%s://%s:%d", channel.Protocol, channel.UserHost, channel.ProxyPort)
|
||||
result = append(result, url)
|
||||
for _, assign := range assigns {
|
||||
var proxy = assign.Proxy
|
||||
var channels = assign.Channels
|
||||
for _, channel := range channels {
|
||||
url := fmt.Sprintf("%s://%s:%d", channel.Protocol, proxy.Host, channel.ProxyPort)
|
||||
result = append(result, url)
|
||||
}
|
||||
}
|
||||
|
||||
switch req.ResultType {
|
||||
|
||||
Reference in New Issue
Block a user