mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-28 21:46:36 +08:00
反向代理源站可以设置权重
This commit is contained in:
@@ -3,6 +3,7 @@ package origins
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
@@ -39,6 +40,7 @@ func (this *AddPopupAction) RunPost(params struct {
|
||||
OriginType string
|
||||
|
||||
ReverseProxyId int64
|
||||
Weight int32
|
||||
Protocol string
|
||||
Addr string
|
||||
|
||||
@@ -56,7 +58,7 @@ func (this *AddPopupAction) RunPost(params struct {
|
||||
host := addr[:portIndex]
|
||||
port := addr[portIndex+1:]
|
||||
|
||||
resp, err := this.RPC().OriginRPC().CreateOrigin(this.AdminContext(), &pb.CreateOriginRequest{
|
||||
createResp, err := this.RPC().OriginRPC().CreateOrigin(this.AdminContext(), &pb.CreateOriginRequest{
|
||||
Name: "",
|
||||
Addr: &pb.NetworkAddress{
|
||||
Protocol: params.Protocol,
|
||||
@@ -64,12 +66,13 @@ func (this *AddPopupAction) RunPost(params struct {
|
||||
PortRange: port,
|
||||
},
|
||||
Description: "",
|
||||
Weight: params.Weight,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
originId := resp.OriginId
|
||||
originId := createResp.OriginId
|
||||
originRef := &serverconfigs.OriginRef{
|
||||
IsOn: true,
|
||||
OriginId: originId,
|
||||
@@ -128,5 +131,8 @@ func (this *AddPopupAction) RunPost(params struct {
|
||||
return
|
||||
}
|
||||
|
||||
// 日志
|
||||
this.CreateLog(oplogs.LevelInfo, "为反向代理服务 %d 添加源站 %d", params.ReverseProxyId, originId)
|
||||
|
||||
this.Success()
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package origins
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
@@ -81,5 +82,8 @@ func (this *DeleteAction) RunPost(params struct {
|
||||
}
|
||||
}
|
||||
|
||||
// 日志
|
||||
this.CreateLog(oplogs.LevelInfo, "删除反向代理服务 %d 的源站 %d", params.ReverseProxyId, params.OriginId)
|
||||
|
||||
this.Success()
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package origins
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
@@ -57,6 +58,7 @@ func (this *UpdatePopupAction) RunGet(params struct {
|
||||
"id": config.Id,
|
||||
"protocol": config.Addr.Protocol,
|
||||
"addr": config.Addr.Host + ":" + config.Addr.PortRange,
|
||||
"weight": config.Weight,
|
||||
}
|
||||
|
||||
this.Show()
|
||||
@@ -69,6 +71,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
ReverseProxyId int64
|
||||
Protocol string
|
||||
Addr string
|
||||
Weight int32
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
@@ -93,11 +96,15 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
PortRange: port,
|
||||
},
|
||||
Description: "",
|
||||
Weight: params.Weight,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
// 日志
|
||||
this.CreateLog(oplogs.LevelInfo, "修改反向代理服务 %d 的源站 %d", params.ReverseProxyId, params.OriginId)
|
||||
|
||||
this.Success()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user