mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 13:10:26 +08:00 
			
		
		
		
	实现路径规则各项数据修改
This commit is contained in:
		@@ -25,7 +25,7 @@ type RPCClient struct {
 | 
				
			|||||||
	nodeIPAddressClients       []pb.NodeIPAddressServiceClient
 | 
						nodeIPAddressClients       []pb.NodeIPAddressServiceClient
 | 
				
			||||||
	serverClients              []pb.ServerServiceClient
 | 
						serverClients              []pb.ServerServiceClient
 | 
				
			||||||
	apiNodeClients             []pb.APINodeServiceClient
 | 
						apiNodeClients             []pb.APINodeServiceClient
 | 
				
			||||||
	originNodeClients          []pb.OriginServerServiceClient
 | 
						originClients              []pb.OriginServiceClient
 | 
				
			||||||
	httpWebClients             []pb.HTTPWebServiceClient
 | 
						httpWebClients             []pb.HTTPWebServiceClient
 | 
				
			||||||
	reverseProxyClients        []pb.ReverseProxyServiceClient
 | 
						reverseProxyClients        []pb.ReverseProxyServiceClient
 | 
				
			||||||
	httpGzipClients            []pb.HTTPGzipServiceClient
 | 
						httpGzipClients            []pb.HTTPGzipServiceClient
 | 
				
			||||||
@@ -50,7 +50,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
 | 
				
			|||||||
	nodeIPAddressClients := []pb.NodeIPAddressServiceClient{}
 | 
						nodeIPAddressClients := []pb.NodeIPAddressServiceClient{}
 | 
				
			||||||
	serverClients := []pb.ServerServiceClient{}
 | 
						serverClients := []pb.ServerServiceClient{}
 | 
				
			||||||
	apiNodeClients := []pb.APINodeServiceClient{}
 | 
						apiNodeClients := []pb.APINodeServiceClient{}
 | 
				
			||||||
	originNodeClients := []pb.OriginServerServiceClient{}
 | 
						originClients := []pb.OriginServiceClient{}
 | 
				
			||||||
	httpWebClients := []pb.HTTPWebServiceClient{}
 | 
						httpWebClients := []pb.HTTPWebServiceClient{}
 | 
				
			||||||
	reverseProxyClients := []pb.ReverseProxyServiceClient{}
 | 
						reverseProxyClients := []pb.ReverseProxyServiceClient{}
 | 
				
			||||||
	httpGzipClients := []pb.HTTPGzipServiceClient{}
 | 
						httpGzipClients := []pb.HTTPGzipServiceClient{}
 | 
				
			||||||
@@ -83,7 +83,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
 | 
				
			|||||||
		nodeIPAddressClients = append(nodeIPAddressClients, pb.NewNodeIPAddressServiceClient(conn))
 | 
							nodeIPAddressClients = append(nodeIPAddressClients, pb.NewNodeIPAddressServiceClient(conn))
 | 
				
			||||||
		serverClients = append(serverClients, pb.NewServerServiceClient(conn))
 | 
							serverClients = append(serverClients, pb.NewServerServiceClient(conn))
 | 
				
			||||||
		apiNodeClients = append(apiNodeClients, pb.NewAPINodeServiceClient(conn))
 | 
							apiNodeClients = append(apiNodeClients, pb.NewAPINodeServiceClient(conn))
 | 
				
			||||||
		originNodeClients = append(originNodeClients, pb.NewOriginServerServiceClient(conn))
 | 
							originClients = append(originClients, pb.NewOriginServiceClient(conn))
 | 
				
			||||||
		httpWebClients = append(httpWebClients, pb.NewHTTPWebServiceClient(conn))
 | 
							httpWebClients = append(httpWebClients, pb.NewHTTPWebServiceClient(conn))
 | 
				
			||||||
		reverseProxyClients = append(reverseProxyClients, pb.NewReverseProxyServiceClient(conn))
 | 
							reverseProxyClients = append(reverseProxyClients, pb.NewReverseProxyServiceClient(conn))
 | 
				
			||||||
		httpGzipClients = append(httpGzipClients, pb.NewHTTPGzipServiceClient(conn))
 | 
							httpGzipClients = append(httpGzipClients, pb.NewHTTPGzipServiceClient(conn))
 | 
				
			||||||
@@ -105,7 +105,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
 | 
				
			|||||||
		nodeIPAddressClients:       nodeIPAddressClients,
 | 
							nodeIPAddressClients:       nodeIPAddressClients,
 | 
				
			||||||
		serverClients:              serverClients,
 | 
							serverClients:              serverClients,
 | 
				
			||||||
		apiNodeClients:             apiNodeClients,
 | 
							apiNodeClients:             apiNodeClients,
 | 
				
			||||||
		originNodeClients:          originNodeClients,
 | 
							originClients:              originClients,
 | 
				
			||||||
		httpWebClients:             httpWebClients,
 | 
							httpWebClients:             httpWebClients,
 | 
				
			||||||
		reverseProxyClients:        reverseProxyClients,
 | 
							reverseProxyClients:        reverseProxyClients,
 | 
				
			||||||
		httpGzipClients:            httpGzipClients,
 | 
							httpGzipClients:            httpGzipClients,
 | 
				
			||||||
@@ -168,9 +168,9 @@ func (this *RPCClient) APINodeRPC() pb.APINodeServiceClient {
 | 
				
			|||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *RPCClient) OriginServerRPC() pb.OriginServerServiceClient {
 | 
					func (this *RPCClient) OriginRPC() pb.OriginServiceClient {
 | 
				
			||||||
	if len(this.originNodeClients) > 0 {
 | 
						if len(this.originClients) > 0 {
 | 
				
			||||||
		return this.originNodeClients[rands.Int(0, len(this.originNodeClients)-1)]
 | 
							return this.originClients[rands.Int(0, len(this.originClients)-1)]
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -43,7 +43,7 @@ func (this *AddOriginPopupAction) RunPost(params struct {
 | 
				
			|||||||
	host := addr[:portIndex]
 | 
						host := addr[:portIndex]
 | 
				
			||||||
	port := addr[portIndex+1:]
 | 
						port := addr[portIndex+1:]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp, err := this.RPC().OriginServerRPC().CreateOriginServer(this.AdminContext(), &pb.CreateOriginServerRequest{
 | 
						resp, err := this.RPC().OriginRPC().CreateOrigin(this.AdminContext(), &pb.CreateOriginRequest{
 | 
				
			||||||
		Name: "",
 | 
							Name: "",
 | 
				
			||||||
		Addr: &pb.NetworkAddress{
 | 
							Addr: &pb.NetworkAddress{
 | 
				
			||||||
			Protocol:  params.Protocol,
 | 
								Protocol:  params.Protocol,
 | 
				
			||||||
@@ -57,7 +57,7 @@ func (this *AddOriginPopupAction) RunPost(params struct {
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	origin := &serverconfigs.OriginServerConfig{
 | 
						origin := &serverconfigs.OriginConfig{
 | 
				
			||||||
		Id:   resp.OriginId,
 | 
							Id:   resp.OriginId,
 | 
				
			||||||
		IsOn: true,
 | 
							IsOn: true,
 | 
				
			||||||
		Addr: &serverconfigs.NetworkAddressConfig{
 | 
							Addr: &serverconfigs.NetworkAddressConfig{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -159,7 +159,7 @@ func (this *CreateAction) RunPost(params struct {
 | 
				
			|||||||
	reverseProxyRefJSON := []byte{}
 | 
						reverseProxyRefJSON := []byte{}
 | 
				
			||||||
	switch params.ServerType {
 | 
						switch params.ServerType {
 | 
				
			||||||
	case serverconfigs.ServerTypeHTTPProxy, serverconfigs.ServerTypeTCPProxy:
 | 
						case serverconfigs.ServerTypeHTTPProxy, serverconfigs.ServerTypeTCPProxy:
 | 
				
			||||||
		origins := []*serverconfigs.OriginServerConfig{}
 | 
							origins := []*serverconfigs.OriginConfig{}
 | 
				
			||||||
		err := json.Unmarshal([]byte(params.Origins), &origins)
 | 
							err := json.Unmarshal([]byte(params.Origins), &origins)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			this.Fail("源站地址解析失败:" + err.Error())
 | 
								this.Fail("源站地址解析失败:" + err.Error())
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					package access
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type IndexAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) Init() {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunGet(params struct {
 | 
				
			||||||
 | 
						ServerId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						// TODO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					package access
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/locationutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func init() {
 | 
				
			||||||
 | 
						TeaGo.BeforeStart(func(server *TeaGo.Server) {
 | 
				
			||||||
 | 
							server.
 | 
				
			||||||
 | 
								Helper(helpers.NewUserMustAuth()).
 | 
				
			||||||
 | 
								Helper(locationutils.NewLocationHelper()).
 | 
				
			||||||
 | 
								Helper(serverutils.NewServerHelper()).
 | 
				
			||||||
 | 
								Data("tinyMenuItem", "access").
 | 
				
			||||||
 | 
								Prefix("/servers/server/settings/locations/access").
 | 
				
			||||||
 | 
								Get("", new(IndexAction)).
 | 
				
			||||||
 | 
								EndAll()
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,72 @@
 | 
				
			|||||||
 | 
					package accessLog
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/actions"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type IndexAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) Init() {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunGet(params struct {
 | 
				
			||||||
 | 
						LocationId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						// 获取配置
 | 
				
			||||||
 | 
						webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						this.Data["webId"] = webConfig.Id
 | 
				
			||||||
 | 
						this.Data["accessLogConfig"] = webConfig.AccessLogRef
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 可选的缓存策略
 | 
				
			||||||
 | 
						policiesResp, err := this.RPC().HTTPAccessLogPolicyRPC().FindAllEnabledHTTPAccessLogPolicies(this.AdminContext(), &pb.FindAllEnabledHTTPAccessLogPoliciesRequest{})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						policyMaps := []maps.Map{}
 | 
				
			||||||
 | 
						for _, policy := range policiesResp.AccessLogPolicies {
 | 
				
			||||||
 | 
							policyMaps = append(policyMaps, maps.Map{
 | 
				
			||||||
 | 
								"id":   policy.Id,
 | 
				
			||||||
 | 
								"name": policy.Name,
 | 
				
			||||||
 | 
								"isOn": policy.IsOn, // TODO 这里界面上显示是否开启状态
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						this.Data["accessLogPolicies"] = policyMaps
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 通用变量
 | 
				
			||||||
 | 
						this.Data["fields"] = serverconfigs.HTTPAccessLogFields
 | 
				
			||||||
 | 
						this.Data["defaultFieldCodes"] = serverconfigs.HTTPAccessLogDefaultFieldsCodes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunPost(params struct {
 | 
				
			||||||
 | 
						WebId         int64
 | 
				
			||||||
 | 
						AccessLogJSON []byte
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Must *actions.Must
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						// TODO 检查参数
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebAccessLog(this.AdminContext(), &pb.UpdateHTTPWebAccessLogRequest{
 | 
				
			||||||
 | 
							WebId:         params.WebId,
 | 
				
			||||||
 | 
							AccessLogJSON: params.AccessLogJSON,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Success()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					package accessLog
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/locationutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func init() {
 | 
				
			||||||
 | 
						TeaGo.BeforeStart(func(server *TeaGo.Server) {
 | 
				
			||||||
 | 
							server.
 | 
				
			||||||
 | 
								Helper(helpers.NewUserMustAuth()).
 | 
				
			||||||
 | 
								Helper(locationutils.NewLocationHelper()).
 | 
				
			||||||
 | 
								Helper(serverutils.NewServerHelper()).
 | 
				
			||||||
 | 
								Data("tinyMenuItem", "accessLog").
 | 
				
			||||||
 | 
								Prefix("/servers/server/settings/locations/accessLog").
 | 
				
			||||||
 | 
								GetPost("", new(IndexAction)).
 | 
				
			||||||
 | 
								EndAll()
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										67
									
								
								internal/web/actions/default/servers/server/settings/locations/cache/index.go
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								internal/web/actions/default/servers/server/settings/locations/cache/index.go
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,67 @@
 | 
				
			|||||||
 | 
					package cache
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/actions"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type IndexAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) Init() {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunGet(params struct {
 | 
				
			||||||
 | 
						LocationId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Data["webId"] = webConfig.Id
 | 
				
			||||||
 | 
						this.Data["cacheConfig"] = webConfig.CacheRef
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 所有缓存策略
 | 
				
			||||||
 | 
						cachePoliciesResp, err := this.RPC().HTTPCachePolicyRPC().FindAllEnabledHTTPCachePolicies(this.AdminContext(), &pb.FindAllEnabledHTTPCachePoliciesRequest{})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						policyMaps := []maps.Map{}
 | 
				
			||||||
 | 
						for _, policy := range cachePoliciesResp.CachePolicies {
 | 
				
			||||||
 | 
							policyMaps = append(policyMaps, maps.Map{
 | 
				
			||||||
 | 
								"id":   policy.Id,
 | 
				
			||||||
 | 
								"name": policy.Name,
 | 
				
			||||||
 | 
								"isOn": policy.IsOn,
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						this.Data["policies"] = policyMaps
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunPost(params struct {
 | 
				
			||||||
 | 
						WebId     int64
 | 
				
			||||||
 | 
						CacheJSON []byte
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Must *actions.Must
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						// TODO 校验配置
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebCache(this.AdminContext(), &pb.UpdateHTTPWebCacheRequest{
 | 
				
			||||||
 | 
							WebId:     params.WebId,
 | 
				
			||||||
 | 
							CacheJSON: params.CacheJSON,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Success()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										21
									
								
								internal/web/actions/default/servers/server/settings/locations/cache/init.go
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								internal/web/actions/default/servers/server/settings/locations/cache/init.go
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					package cache
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/locationutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func init() {
 | 
				
			||||||
 | 
						TeaGo.BeforeStart(func(server *TeaGo.Server) {
 | 
				
			||||||
 | 
							server.
 | 
				
			||||||
 | 
								Helper(helpers.NewUserMustAuth()).
 | 
				
			||||||
 | 
								Helper(locationutils.NewLocationHelper()).
 | 
				
			||||||
 | 
								Helper(serverutils.NewServerHelper()).
 | 
				
			||||||
 | 
								Data("tinyMenuItem", "cache").
 | 
				
			||||||
 | 
								Prefix("/servers/server/settings/locations/cache").
 | 
				
			||||||
 | 
								GetPost("", new(IndexAction)).
 | 
				
			||||||
 | 
								EndAll()
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,52 @@
 | 
				
			|||||||
 | 
					package charset
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/configutils"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/actions"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type IndexAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) Init() {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunGet(params struct {
 | 
				
			||||||
 | 
						LocationId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Data["webId"] = webConfig.Id
 | 
				
			||||||
 | 
						this.Data["charset"] = webConfig.Charset
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Data["usualCharsets"] = configutils.UsualCharsets
 | 
				
			||||||
 | 
						this.Data["allCharsets"] = configutils.AllCharsets
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunPost(params struct {
 | 
				
			||||||
 | 
						WebId   int64
 | 
				
			||||||
 | 
						Charset string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Must *actions.Must
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebCharset(this.AdminContext(), &pb.UpdateHTTPWebCharsetRequest{
 | 
				
			||||||
 | 
							WebId:   params.WebId,
 | 
				
			||||||
 | 
							Charset: params.Charset,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Success()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					package charset
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/locationutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func init() {
 | 
				
			||||||
 | 
						TeaGo.BeforeStart(func(server *TeaGo.Server) {
 | 
				
			||||||
 | 
							server.
 | 
				
			||||||
 | 
								Helper(helpers.NewUserMustAuth()).
 | 
				
			||||||
 | 
								Helper(locationutils.NewLocationHelper()).
 | 
				
			||||||
 | 
								Helper(serverutils.NewServerHelper()).
 | 
				
			||||||
 | 
								Data("tinyMenuItem", "charset").
 | 
				
			||||||
 | 
								Prefix("/servers/server/settings/locations/charset").
 | 
				
			||||||
 | 
								GetPost("", new(IndexAction)).
 | 
				
			||||||
 | 
								EndAll()
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,133 @@
 | 
				
			|||||||
 | 
					package gzip
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"encoding/json"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/actions"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/types"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type IndexAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) Init() {
 | 
				
			||||||
 | 
						this.Nav("", "setting", "index")
 | 
				
			||||||
 | 
						this.SecondMenu("gzip")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunGet(params struct {
 | 
				
			||||||
 | 
						LocationId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Data["webId"] = webConfig.Id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						gzipId := int64(0)
 | 
				
			||||||
 | 
						if webConfig.GzipRef != nil {
 | 
				
			||||||
 | 
							gzipId = webConfig.GzipRef.GzipId
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						gzipConfig := &serverconfigs.HTTPGzipConfig{
 | 
				
			||||||
 | 
							Id:   0,
 | 
				
			||||||
 | 
							IsOn: true,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if gzipId > 0 {
 | 
				
			||||||
 | 
							resp, err := this.RPC().HTTPGzipRPC().FindEnabledHTTPGzipConfig(this.AdminContext(), &pb.FindEnabledGzipConfigRequest{GzipId: gzipId})
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								this.ErrorPage(err)
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							err = json.Unmarshal(resp.GzipJSON, gzipConfig)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								this.ErrorPage(err)
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Data["gzipConfig"] = gzipConfig
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunPost(params struct {
 | 
				
			||||||
 | 
						WebId     int64
 | 
				
			||||||
 | 
						GzipId    int64
 | 
				
			||||||
 | 
						Level     int
 | 
				
			||||||
 | 
						MinLength string
 | 
				
			||||||
 | 
						MaxLength string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Must *actions.Must
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						if params.Level < 0 || params.Level > 9 {
 | 
				
			||||||
 | 
							this.Fail("请选择正确的压缩级别")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						minLength := &pb.SizeCapacity{Count: -1}
 | 
				
			||||||
 | 
						if len(params.MinLength) > 0 {
 | 
				
			||||||
 | 
							err := json.Unmarshal([]byte(params.MinLength), minLength)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								this.ErrorPage(err)
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						maxLength := &pb.SizeCapacity{Count: -1}
 | 
				
			||||||
 | 
						if len(params.MaxLength) > 0 {
 | 
				
			||||||
 | 
							err := json.Unmarshal([]byte(params.MaxLength), maxLength)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								this.ErrorPage(err)
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if params.GzipId > 0 {
 | 
				
			||||||
 | 
							_, err := this.RPC().HTTPGzipRPC().UpdateHTTPGzip(this.AdminContext(), &pb.UpdateHTTPGzipRequest{
 | 
				
			||||||
 | 
								GzipId:    params.GzipId,
 | 
				
			||||||
 | 
								Level:     types.Int32(params.Level),
 | 
				
			||||||
 | 
								MinLength: minLength,
 | 
				
			||||||
 | 
								MaxLength: maxLength,
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								this.ErrorPage(err)
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							resp, err := this.RPC().HTTPGzipRPC().CreateHTTPGzip(this.AdminContext(), &pb.CreateHTTPGzipRequest{
 | 
				
			||||||
 | 
								Level:     types.Int32(params.Level),
 | 
				
			||||||
 | 
								MinLength: minLength,
 | 
				
			||||||
 | 
								MaxLength: maxLength,
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								this.ErrorPage(err)
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							gzipId := resp.GzipId
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							gzipRef := &serverconfigs.HTTPGzipRef{
 | 
				
			||||||
 | 
								IsOn:   true,
 | 
				
			||||||
 | 
								GzipId: gzipId,
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							gzipRefJSON, err := json.Marshal(gzipRef)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								this.ErrorPage(err)
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebGzip(this.AdminContext(), &pb.UpdateHTTPWebGzipRequest{
 | 
				
			||||||
 | 
								WebId:    params.WebId,
 | 
				
			||||||
 | 
								GzipJSON: gzipRefJSON,
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								this.ErrorPage(err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Success()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					package gzip
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/locationutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func init() {
 | 
				
			||||||
 | 
						TeaGo.BeforeStart(func(server *TeaGo.Server) {
 | 
				
			||||||
 | 
							server.
 | 
				
			||||||
 | 
								Helper(helpers.NewUserMustAuth()).
 | 
				
			||||||
 | 
								Helper(locationutils.NewLocationHelper()).
 | 
				
			||||||
 | 
								Helper(serverutils.NewServerHelper()).
 | 
				
			||||||
 | 
								Data("tinyMenuItem", "gzip").
 | 
				
			||||||
 | 
								Prefix("/servers/server/settings/locations/gzip").
 | 
				
			||||||
 | 
								GetPost("", new(IndexAction)).
 | 
				
			||||||
 | 
								EndAll()
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,78 @@
 | 
				
			|||||||
 | 
					package headers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"errors"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type IndexAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) Init() {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunGet(params struct {
 | 
				
			||||||
 | 
						LocationId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 初始化Header
 | 
				
			||||||
 | 
						webResp, err := this.RPC().HTTPWebRPC().FindEnabledHTTPWeb(this.AdminContext(), &pb.FindEnabledHTTPWebRequest{WebId: webConfig.Id})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						web := webResp.Web
 | 
				
			||||||
 | 
						if web == nil {
 | 
				
			||||||
 | 
							this.ErrorPage(errors.New("web should not be nil"))
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						isChanged := false
 | 
				
			||||||
 | 
						if web.RequestHeaderPolicyId <= 0 {
 | 
				
			||||||
 | 
							createHeaderPolicyResp, err := this.RPC().HTTPHeaderPolicyRPC().CreateHTTPHeaderPolicy(this.AdminContext(), &pb.CreateHTTPHeaderPolicyRequest{})
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								this.ErrorPage(err)
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							headerPolicyId := createHeaderPolicyResp.HeaderPolicyId
 | 
				
			||||||
 | 
							_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebRequestHeaderPolicy(this.AdminContext(), &pb.UpdateHTTPWebRequestHeaderPolicyRequest{
 | 
				
			||||||
 | 
								WebId:          web.Id,
 | 
				
			||||||
 | 
								HeaderPolicyId: headerPolicyId,
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
							isChanged = true
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if web.ResponseHeaderPolicyId <= 0 {
 | 
				
			||||||
 | 
							createHeaderPolicyResp, err := this.RPC().HTTPHeaderPolicyRPC().CreateHTTPHeaderPolicy(this.AdminContext(), &pb.CreateHTTPHeaderPolicyRequest{})
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								this.ErrorPage(err)
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							headerPolicyId := createHeaderPolicyResp.HeaderPolicyId
 | 
				
			||||||
 | 
							_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebResponseHeaderPolicy(this.AdminContext(), &pb.UpdateHTTPWebResponseHeaderPolicyRequest{
 | 
				
			||||||
 | 
								WebId:          web.Id,
 | 
				
			||||||
 | 
								HeaderPolicyId: headerPolicyId,
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
							isChanged = true
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 重新获取配置
 | 
				
			||||||
 | 
						if isChanged {
 | 
				
			||||||
 | 
							webConfig, err = webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								this.ErrorPage(err)
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Data["requestHeaderPolicy"] = webConfig.RequestHeaders
 | 
				
			||||||
 | 
						this.Data["responseHeaderPolicy"] = webConfig.ResponseHeaders
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					package headers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/locationutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func init() {
 | 
				
			||||||
 | 
						TeaGo.BeforeStart(func(server *TeaGo.Server) {
 | 
				
			||||||
 | 
							server.
 | 
				
			||||||
 | 
								Helper(helpers.NewUserMustAuth()).
 | 
				
			||||||
 | 
								Helper(locationutils.NewLocationHelper()).
 | 
				
			||||||
 | 
								Helper(serverutils.NewServerHelper()).
 | 
				
			||||||
 | 
								Data("tinyMenuItem", "header").
 | 
				
			||||||
 | 
								Prefix("/servers/server/settings/locations/headers").
 | 
				
			||||||
 | 
								Get("", new(IndexAction)).
 | 
				
			||||||
 | 
								EndAll()
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,10 +1,12 @@
 | 
				
			|||||||
package location
 | 
					package location
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"encoding/json"
 | 
					 | 
				
			||||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/actions"
 | 
				
			||||||
 | 
						"regexp"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 路径规则详情
 | 
					// 路径规则详情
 | 
				
			||||||
@@ -13,26 +15,70 @@ type IndexAction struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *IndexAction) Init() {
 | 
					func (this *IndexAction) Init() {
 | 
				
			||||||
	this.TinyMenu("basic")
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *IndexAction) RunGet(params struct {
 | 
					func (this *IndexAction) RunGet(params struct {
 | 
				
			||||||
	LocationId int64
 | 
						LocationId int64
 | 
				
			||||||
}) {
 | 
					}) {
 | 
				
			||||||
	locationConfigResp, err := this.RPC().HTTPLocationRPC().FindEnabledHTTPLocationConfig(this.AdminContext(), &pb.FindEnabledHTTPLocationConfigRequest{LocationId: params.LocationId})
 | 
						locationConfig := this.Data.Get("locationConfig").(*serverconfigs.HTTPLocationConfig)
 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		this.ErrorPage(err)
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	locationConfig := &serverconfigs.HTTPLocationConfig{}
 | 
					 | 
				
			||||||
	err = json.Unmarshal(locationConfigResp.LocationJSON, locationConfig)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		this.ErrorPage(err)
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this.Data["locationId"] = locationConfig.Id
 | 
						this.Data["patternTypes"] = serverconfigs.AllLocationPatternTypes()
 | 
				
			||||||
	this.Data["locationConfig"] = locationConfig
 | 
					
 | 
				
			||||||
 | 
						this.Data["pattern"] = locationConfig.PatternString()
 | 
				
			||||||
 | 
						this.Data["type"] = locationConfig.PatternType()
 | 
				
			||||||
 | 
						this.Data["isReverse"] = locationConfig.IsReverse()
 | 
				
			||||||
 | 
						this.Data["isCaseInsensitive"] = locationConfig.IsCaseInsensitive()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this.Show()
 | 
						this.Show()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunPost(params struct {
 | 
				
			||||||
 | 
						LocationId int64
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Name        string
 | 
				
			||||||
 | 
						Pattern     string
 | 
				
			||||||
 | 
						PatternType int
 | 
				
			||||||
 | 
						Description string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						IsBreak           bool
 | 
				
			||||||
 | 
						IsCaseInsensitive bool
 | 
				
			||||||
 | 
						IsReverse         bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Must *actions.Must
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						params.Must.
 | 
				
			||||||
 | 
							Field("pattern", params.Pattern).
 | 
				
			||||||
 | 
							Require("请输入路径匹配规则")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 校验正则
 | 
				
			||||||
 | 
						if params.PatternType == serverconfigs.HTTPLocationPatternTypeRegexp {
 | 
				
			||||||
 | 
							_, err := regexp.Compile(params.Pattern)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								this.Fail("正则表达式校验失败:" + err.Error())
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 自动加上前缀斜杠
 | 
				
			||||||
 | 
						if params.PatternType == serverconfigs.HTTPLocationPatternTypePrefix ||
 | 
				
			||||||
 | 
							params.PatternType == serverconfigs.HTTPLocationPatternTypeExact {
 | 
				
			||||||
 | 
							params.Pattern = "/" + strings.TrimLeft(params.Pattern, "/")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						location := &serverconfigs.HTTPLocationConfig{}
 | 
				
			||||||
 | 
						location.SetPattern(params.Pattern, params.PatternType, params.IsCaseInsensitive, params.IsReverse)
 | 
				
			||||||
 | 
						resultPattern := location.Pattern
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err := this.RPC().HTTPLocationRPC().UpdateHTTPLocation(this.AdminContext(), &pb.UpdateHTTPLocationRequest{
 | 
				
			||||||
 | 
							LocationId:  params.LocationId,
 | 
				
			||||||
 | 
							Name:        params.Name,
 | 
				
			||||||
 | 
							Description: params.Description,
 | 
				
			||||||
 | 
							Pattern:     resultPattern,
 | 
				
			||||||
 | 
							IsBreak:     params.IsBreak,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Success()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,6 +13,7 @@ func init() {
 | 
				
			|||||||
			Helper(helpers.NewUserMustAuth()).
 | 
								Helper(helpers.NewUserMustAuth()).
 | 
				
			||||||
			Helper(locationutils.NewLocationHelper()).
 | 
								Helper(locationutils.NewLocationHelper()).
 | 
				
			||||||
			Helper(serverutils.NewServerHelper()).
 | 
								Helper(serverutils.NewServerHelper()).
 | 
				
			||||||
 | 
								Data("tinyMenuItem", "basic").
 | 
				
			||||||
			Prefix("/servers/server/settings/locations/location").
 | 
								Prefix("/servers/server/settings/locations/location").
 | 
				
			||||||
			GetPost("", new(IndexAction)).
 | 
								GetPost("", new(IndexAction)).
 | 
				
			||||||
			EndAll()
 | 
								EndAll()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,9 +1,11 @@
 | 
				
			|||||||
package locationutils
 | 
					package locationutils
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
	"github.com/iwind/TeaGo/actions"
 | 
						"github.com/iwind/TeaGo/actions"
 | 
				
			||||||
	"github.com/iwind/TeaGo/maps"
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
 | 
						"reflect"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type LocationHelper struct {
 | 
					type LocationHelper struct {
 | 
				
			||||||
@@ -13,7 +15,8 @@ func NewLocationHelper() *LocationHelper {
 | 
				
			|||||||
	return &LocationHelper{}
 | 
						return &LocationHelper{}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *LocationHelper) BeforeAction(action *actions.ActionObject) {
 | 
					func (this *LocationHelper) BeforeAction(actionPtr actions.ActionWrapper) {
 | 
				
			||||||
 | 
						action := actionPtr.Object()
 | 
				
			||||||
	if action.Request.Method != http.MethodGet {
 | 
						if action.Request.Method != http.MethodGet {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -26,6 +29,21 @@ func (this *LocationHelper) BeforeAction(action *actions.ActionObject) {
 | 
				
			|||||||
	action.Data["mainTab"] = "setting"
 | 
						action.Data["mainTab"] = "setting"
 | 
				
			||||||
	action.Data["secondMenuItem"] = "locations"
 | 
						action.Data["secondMenuItem"] = "locations"
 | 
				
			||||||
	action.Data["tinyLeftMenuItems"] = this.createMenus(serverIdString, locationIdString, action.Data.GetString("tinyMenuItem"))
 | 
						action.Data["tinyLeftMenuItems"] = this.createMenus(serverIdString, locationIdString, action.Data.GetString("tinyMenuItem"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 路径信息
 | 
				
			||||||
 | 
						parentActionValue := reflect.ValueOf(actionPtr).Elem().FieldByName("ParentAction")
 | 
				
			||||||
 | 
						if parentActionValue.IsValid() {
 | 
				
			||||||
 | 
							parentAction, isOk := parentActionValue.Interface().(actionutils.ParentAction)
 | 
				
			||||||
 | 
							if isOk {
 | 
				
			||||||
 | 
								locationId := action.ParamInt64("locationId")
 | 
				
			||||||
 | 
								locationConfig, isOk := FindLocationConfig(&parentAction, locationId)
 | 
				
			||||||
 | 
								if !isOk {
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								action.Data["locationId"] = locationId
 | 
				
			||||||
 | 
								action.Data["locationConfig"] = locationConfig
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *LocationHelper) createMenus(serverIdString string, locationIdString string, secondMenuItem string) []maps.Map {
 | 
					func (this *LocationHelper) createMenus(serverIdString string, locationIdString string, secondMenuItem string) []maps.Map {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					package locationutils
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"encoding/json"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 查找路径规则配置
 | 
				
			||||||
 | 
					func FindLocationConfig(parentAction *actionutils.ParentAction, locationId int64) (locationConfig *serverconfigs.HTTPLocationConfig, isOk bool) {
 | 
				
			||||||
 | 
						locationConfigResp, err := parentAction.RPC().HTTPLocationRPC().FindEnabledHTTPLocationConfig(parentAction.AdminContext(), &pb.FindEnabledHTTPLocationConfigRequest{LocationId: locationId})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							parentAction.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						locationConfig = &serverconfigs.HTTPLocationConfig{}
 | 
				
			||||||
 | 
						err = json.Unmarshal(locationConfigResp.LocationJSON, locationConfig)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							parentAction.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						err = locationConfig.Init()
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							parentAction.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						isOk = true
 | 
				
			||||||
 | 
						return
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,60 @@
 | 
				
			|||||||
 | 
					package pages
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/actions"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type IndexAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) Init() {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunGet(params struct {
 | 
				
			||||||
 | 
						LocationId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Data["webId"] = webConfig.Id
 | 
				
			||||||
 | 
						this.Data["pages"] = webConfig.Pages
 | 
				
			||||||
 | 
						this.Data["shutdownConfig"] = webConfig.Shutdown
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunPost(params struct {
 | 
				
			||||||
 | 
						WebId        int64
 | 
				
			||||||
 | 
						PagesJSON    string
 | 
				
			||||||
 | 
						ShutdownJSON string
 | 
				
			||||||
 | 
						Must         *actions.Must
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						// TODO 检查配置
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebPages(this.AdminContext(), &pb.UpdateHTTPWebPagesRequest{
 | 
				
			||||||
 | 
							WebId:     params.WebId,
 | 
				
			||||||
 | 
							PagesJSON: []byte(params.PagesJSON),
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebShutdown(this.AdminContext(), &pb.UpdateHTTPWebShutdownRequest{
 | 
				
			||||||
 | 
							WebId:        params.WebId,
 | 
				
			||||||
 | 
							ShutdownJSON: []byte(params.ShutdownJSON),
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Success()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					package pages
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/locationutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func init() {
 | 
				
			||||||
 | 
						TeaGo.BeforeStart(func(server *TeaGo.Server) {
 | 
				
			||||||
 | 
							server.
 | 
				
			||||||
 | 
								Helper(helpers.NewUserMustAuth()).
 | 
				
			||||||
 | 
								Helper(locationutils.NewLocationHelper()).
 | 
				
			||||||
 | 
								Helper(serverutils.NewServerHelper()).
 | 
				
			||||||
 | 
								Data("tinyMenuItem", "pages").
 | 
				
			||||||
 | 
								Prefix("/servers/server/settings/locations/pages").
 | 
				
			||||||
 | 
								GetPost("", new(IndexAction)).
 | 
				
			||||||
 | 
								EndAll()
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,97 @@
 | 
				
			|||||||
 | 
					package reverseProxy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"encoding/json"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/actions"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 源站列表
 | 
				
			||||||
 | 
					type IndexAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) Init() {
 | 
				
			||||||
 | 
						this.FirstMenu("index")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunGet(params struct {
 | 
				
			||||||
 | 
						ServerId   int64
 | 
				
			||||||
 | 
						LocationId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						serverTypeResp, err := this.RPC().ServerRPC().FindEnabledServerType(this.AdminContext(), &pb.FindEnabledServerTypeRequest{ServerId: params.ServerId})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						serverType := serverTypeResp.Type
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						reverseProxyResp, err := this.RPC().HTTPLocationRPC().FindAndInitHTTPLocationReverseProxyConfig(this.AdminContext(), &pb.FindAndInitHTTPLocationReverseProxyConfigRequest{LocationId: params.LocationId})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						reverseProxyRef := &serverconfigs.ReverseProxyRef{}
 | 
				
			||||||
 | 
						err = json.Unmarshal(reverseProxyResp.ReverseProxyRefJSON, reverseProxyRef)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						reverseProxy := &serverconfigs.ReverseProxyConfig{}
 | 
				
			||||||
 | 
						err = json.Unmarshal(reverseProxyResp.ReverseProxyJSON, reverseProxy)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Data["serverType"] = serverType
 | 
				
			||||||
 | 
						this.Data["reverseProxyRef"] = reverseProxyRef
 | 
				
			||||||
 | 
						this.Data["reverseProxyConfig"] = reverseProxy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						primaryOriginMaps := []maps.Map{}
 | 
				
			||||||
 | 
						backupOriginMaps := []maps.Map{}
 | 
				
			||||||
 | 
						for _, originConfig := range reverseProxy.PrimaryOrigins {
 | 
				
			||||||
 | 
							m := maps.Map{
 | 
				
			||||||
 | 
								"id":     originConfig.Id,
 | 
				
			||||||
 | 
								"weight": originConfig.Weight,
 | 
				
			||||||
 | 
								"addr":   originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							primaryOriginMaps = append(primaryOriginMaps, m)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						for _, originConfig := range reverseProxy.BackupOrigins {
 | 
				
			||||||
 | 
							m := maps.Map{
 | 
				
			||||||
 | 
								"id":     originConfig.Id,
 | 
				
			||||||
 | 
								"weight": originConfig.Weight,
 | 
				
			||||||
 | 
								"addr":   originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							backupOriginMaps = append(backupOriginMaps, m)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						this.Data["primaryOrigins"] = primaryOriginMaps
 | 
				
			||||||
 | 
						this.Data["backupOrigins"] = backupOriginMaps
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunPost(params struct {
 | 
				
			||||||
 | 
						LocationId          int64
 | 
				
			||||||
 | 
						ReverseProxyRefJSON []byte
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Must *actions.Must
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						// TODO 校验配置
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err := this.RPC().HTTPLocationRPC().UpdateHTTPLocationReverseProxy(this.AdminContext(), &pb.UpdateHTTPLocationReverseProxyRequest{
 | 
				
			||||||
 | 
							LocationId:       params.LocationId,
 | 
				
			||||||
 | 
							ReverseProxyJSON: params.ReverseProxyRefJSON,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Success()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					package reverseProxy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/locationutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func init() {
 | 
				
			||||||
 | 
						TeaGo.BeforeStart(func(server *TeaGo.Server) {
 | 
				
			||||||
 | 
							server.
 | 
				
			||||||
 | 
								Helper(helpers.NewUserMustAuth()).
 | 
				
			||||||
 | 
								Helper(locationutils.NewLocationHelper()).
 | 
				
			||||||
 | 
								Helper(serverutils.NewServerHelper()).
 | 
				
			||||||
 | 
								Data("mainTab", "setting").
 | 
				
			||||||
 | 
								Data("tinyMenuItem", "reverseProxy").
 | 
				
			||||||
 | 
								Prefix("/servers/server/settings/locations/reverseProxy").
 | 
				
			||||||
 | 
								GetPost("", new(IndexAction)).
 | 
				
			||||||
 | 
								GetPost("/scheduling", new(SchedulingAction)).
 | 
				
			||||||
 | 
								EndAll()
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,46 @@
 | 
				
			|||||||
 | 
					package reverseProxy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"encoding/json"
 | 
				
			||||||
 | 
						"errors"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/schedulingconfigs"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type SchedulingAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *SchedulingAction) Init() {
 | 
				
			||||||
 | 
						this.FirstMenu("scheduling")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *SchedulingAction) RunGet(params struct {
 | 
				
			||||||
 | 
						ServerId int64
 | 
				
			||||||
 | 
						LocationId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						reverseProxyResp, err := this.RPC().HTTPLocationRPC().FindAndInitHTTPLocationReverseProxyConfig(this.AdminContext(), &pb.FindAndInitHTTPLocationReverseProxyConfigRequest{LocationId: params.LocationId})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						reverseProxy := &serverconfigs.ReverseProxyConfig{}
 | 
				
			||||||
 | 
						err = json.Unmarshal(reverseProxyResp.ReverseProxyJSON, reverseProxy)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						this.Data["reverseProxyId"] = reverseProxy.Id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						schedulingCode := reverseProxy.FindSchedulingConfig().Code
 | 
				
			||||||
 | 
						schedulingMap := schedulingconfigs.FindSchedulingType(schedulingCode)
 | 
				
			||||||
 | 
						if schedulingMap == nil {
 | 
				
			||||||
 | 
							this.ErrorPage(errors.New("invalid scheduling code '" + schedulingCode + "'"))
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						this.Data["scheduling"] = schedulingMap
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,49 @@
 | 
				
			|||||||
 | 
					package stat
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/actions"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type IndexAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) Init() {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunGet(params struct {
 | 
				
			||||||
 | 
						LocationId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Data["webId"] = webConfig.Id
 | 
				
			||||||
 | 
						this.Data["statConfig"] = webConfig.StatRef
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunPost(params struct {
 | 
				
			||||||
 | 
						WebId    int64
 | 
				
			||||||
 | 
						StatJSON []byte
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Must *actions.Must
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						// TODO 校验配置
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebStat(this.AdminContext(), &pb.UpdateHTTPWebStatRequest{
 | 
				
			||||||
 | 
							WebId:    params.WebId,
 | 
				
			||||||
 | 
							StatJSON: params.StatJSON,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						this.Success()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					package stat
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/locationutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func init() {
 | 
				
			||||||
 | 
						TeaGo.BeforeStart(func(server *TeaGo.Server) {
 | 
				
			||||||
 | 
							server.
 | 
				
			||||||
 | 
								Helper(helpers.NewUserMustAuth()).
 | 
				
			||||||
 | 
								Helper(locationutils.NewLocationHelper()).
 | 
				
			||||||
 | 
								Helper(serverutils.NewServerHelper()).
 | 
				
			||||||
 | 
								Data("tinyMenuItem", "stat").
 | 
				
			||||||
 | 
								Prefix("/servers/server/settings/locations/stat").
 | 
				
			||||||
 | 
								GetPost("", new(IndexAction)).
 | 
				
			||||||
 | 
								EndAll()
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,67 @@
 | 
				
			|||||||
 | 
					package waf
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/actions"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type IndexAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) Init() {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunGet(params struct {
 | 
				
			||||||
 | 
						LocationId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Data["webId"] = webConfig.Id
 | 
				
			||||||
 | 
						this.Data["firewallConfig"] = webConfig.FirewallRef
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 当前已有策略
 | 
				
			||||||
 | 
						policiesResp, err := this.RPC().HTTPFirewallPolicyRPC().FindAllEnabledHTTPFirewallPolicies(this.AdminContext(), &pb.FindAllEnabledHTTPFirewallPoliciesRequest{})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						policyMaps := []maps.Map{}
 | 
				
			||||||
 | 
						for _, p := range policiesResp.FirewallPolicies {
 | 
				
			||||||
 | 
							policyMaps = append(policyMaps, maps.Map{
 | 
				
			||||||
 | 
								"id":   p.Id,
 | 
				
			||||||
 | 
								"name": p.Name,
 | 
				
			||||||
 | 
								"isOn": p.IsOn,
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						this.Data["firewallPolicies"] = policyMaps
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunPost(params struct {
 | 
				
			||||||
 | 
						WebId        int64
 | 
				
			||||||
 | 
						FirewallJSON []byte
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Must *actions.Must
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						// TODO 检查配置
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebFirewall(this.AdminContext(), &pb.UpdateHTTPWebFirewallRequest{
 | 
				
			||||||
 | 
							WebId:        params.WebId,
 | 
				
			||||||
 | 
							FirewallJSON: params.FirewallJSON,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Success()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					package waf
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/locationutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func init() {
 | 
				
			||||||
 | 
						TeaGo.BeforeStart(func(server *TeaGo.Server) {
 | 
				
			||||||
 | 
							server.
 | 
				
			||||||
 | 
								Helper(helpers.NewUserMustAuth()).
 | 
				
			||||||
 | 
								Helper(locationutils.NewLocationHelper()).
 | 
				
			||||||
 | 
								Helper(serverutils.NewServerHelper()).
 | 
				
			||||||
 | 
								Data("tinyMenuItem", "waf").
 | 
				
			||||||
 | 
								Prefix("/servers/server/settings/locations/waf").
 | 
				
			||||||
 | 
								GetPost("", new(IndexAction)).
 | 
				
			||||||
 | 
								EndAll()
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,48 @@
 | 
				
			|||||||
 | 
					package web
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/actions"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type IndexAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) Init() {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunGet(params struct {
 | 
				
			||||||
 | 
						LocationId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Data["webConfig"] = webConfig
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunPost(params struct {
 | 
				
			||||||
 | 
						WebId int64
 | 
				
			||||||
 | 
						Root  string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Must *actions.Must
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err := this.RPC().HTTPWebRPC().UpdateHTTPWeb(this.AdminContext(), &pb.UpdateHTTPWebRequest{
 | 
				
			||||||
 | 
							WebId: params.WebId,
 | 
				
			||||||
 | 
							Root:  params.Root,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Success()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					package web
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/locationutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func init() {
 | 
				
			||||||
 | 
						TeaGo.BeforeStart(func(server *TeaGo.Server) {
 | 
				
			||||||
 | 
							server.
 | 
				
			||||||
 | 
								Helper(helpers.NewUserMustAuth()).
 | 
				
			||||||
 | 
								Helper(locationutils.NewLocationHelper()).
 | 
				
			||||||
 | 
								Helper(serverutils.NewServerHelper()).
 | 
				
			||||||
 | 
								Data("tinyMenuItem", "web").
 | 
				
			||||||
 | 
								Prefix("/servers/server/settings/locations/web").
 | 
				
			||||||
 | 
								GetPost("", new(IndexAction)).
 | 
				
			||||||
 | 
								EndAll()
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -56,7 +56,7 @@ func (this *AddPopupAction) RunPost(params struct {
 | 
				
			|||||||
	host := addr[:portIndex]
 | 
						host := addr[:portIndex]
 | 
				
			||||||
	port := addr[portIndex+1:]
 | 
						port := addr[portIndex+1:]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp, err := this.RPC().OriginServerRPC().CreateOriginServer(this.AdminContext(), &pb.CreateOriginServerRequest{
 | 
						resp, err := this.RPC().OriginRPC().CreateOrigin(this.AdminContext(), &pb.CreateOriginRequest{
 | 
				
			||||||
		Name: "",
 | 
							Name: "",
 | 
				
			||||||
		Addr: &pb.NetworkAddress{
 | 
							Addr: &pb.NetworkAddress{
 | 
				
			||||||
			Protocol:  params.Protocol,
 | 
								Protocol:  params.Protocol,
 | 
				
			||||||
@@ -70,17 +70,9 @@ func (this *AddPopupAction) RunPost(params struct {
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	originId := resp.OriginId
 | 
						originId := resp.OriginId
 | 
				
			||||||
	originConfigResp, err := this.RPC().OriginServerRPC().FindEnabledOriginServerConfig(this.AdminContext(), &pb.FindEnabledOriginServerConfigRequest{OriginId: originId})
 | 
						originRef := &serverconfigs.OriginRef{
 | 
				
			||||||
	if err != nil {
 | 
							IsOn:     true,
 | 
				
			||||||
		this.ErrorPage(err)
 | 
							OriginId: originId,
 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	originConfigData := originConfigResp.OriginJSON
 | 
					 | 
				
			||||||
	var originConfig = &serverconfigs.OriginServerConfig{}
 | 
					 | 
				
			||||||
	err = json.Unmarshal(originConfigData, originConfig)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		this.ErrorPage(err)
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	reverseProxyResp, err := this.RPC().ReverseProxyRPC().FindEnabledReverseProxy(this.AdminContext(), &pb.FindEnabledReverseProxyRequest{ReverseProxyId: params.ReverseProxyId})
 | 
						reverseProxyResp, err := this.RPC().ReverseProxyRPC().FindEnabledReverseProxy(this.AdminContext(), &pb.FindEnabledReverseProxyRequest{ReverseProxyId: params.ReverseProxyId})
 | 
				
			||||||
@@ -94,7 +86,7 @@ func (this *AddPopupAction) RunPost(params struct {
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	origins := []*serverconfigs.OriginServerConfig{}
 | 
						origins := []*serverconfigs.OriginRef{}
 | 
				
			||||||
	switch params.OriginType {
 | 
						switch params.OriginType {
 | 
				
			||||||
	case "primary":
 | 
						case "primary":
 | 
				
			||||||
		if len(reverseProxy.PrimaryOriginsJSON) > 0 {
 | 
							if len(reverseProxy.PrimaryOriginsJSON) > 0 {
 | 
				
			||||||
@@ -113,7 +105,7 @@ func (this *AddPopupAction) RunPost(params struct {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	origins = append(origins, originConfig)
 | 
						origins = append(origins, originRef)
 | 
				
			||||||
	originsData, err := json.Marshal(origins)
 | 
						originsData, err := json.Marshal(origins)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		this.ErrorPage(err)
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,7 +28,7 @@ func (this *DeleteAction) RunPost(params struct {
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	origins := []*serverconfigs.OriginServerConfig{}
 | 
						origins := []*serverconfigs.OriginRef{}
 | 
				
			||||||
	switch params.OriginType {
 | 
						switch params.OriginType {
 | 
				
			||||||
	case "primary":
 | 
						case "primary":
 | 
				
			||||||
		err = json.Unmarshal(reverseProxy.PrimaryOriginsJSON, &origins)
 | 
							err = json.Unmarshal(reverseProxy.PrimaryOriginsJSON, &origins)
 | 
				
			||||||
@@ -47,9 +47,9 @@ func (this *DeleteAction) RunPost(params struct {
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	result := []*serverconfigs.OriginServerConfig{}
 | 
						result := []*serverconfigs.OriginRef{}
 | 
				
			||||||
	for _, origin := range origins {
 | 
						for _, origin := range origins {
 | 
				
			||||||
		if origin.Id == params.OriginId {
 | 
							if origin.OriginId == params.OriginId {
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		result = append(result, origin)
 | 
							result = append(result, origin)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,6 @@ package origins
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"encoding/json"
 | 
						"encoding/json"
 | 
				
			||||||
	"errors"
 | 
					 | 
				
			||||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
 | 
				
			||||||
@@ -41,13 +40,13 @@ func (this *UpdatePopupAction) RunGet(params struct {
 | 
				
			|||||||
	this.Data["serverType"] = serverTypeResp.Type
 | 
						this.Data["serverType"] = serverTypeResp.Type
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 源站信息
 | 
						// 源站信息
 | 
				
			||||||
	originResp, err := this.RPC().OriginServerRPC().FindEnabledOriginServerConfig(this.AdminContext(), &pb.FindEnabledOriginServerConfigRequest{OriginId: params.OriginId})
 | 
						originResp, err := this.RPC().OriginRPC().FindEnabledOriginConfig(this.AdminContext(), &pb.FindEnabledOriginConfigRequest{OriginId: params.OriginId})
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		this.ErrorPage(err)
 | 
							this.ErrorPage(err)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	configData := originResp.OriginJSON
 | 
						configData := originResp.OriginJSON
 | 
				
			||||||
	config := &serverconfigs.OriginServerConfig{}
 | 
						config := &serverconfigs.OriginConfig{}
 | 
				
			||||||
	err = json.Unmarshal(configData, config)
 | 
						err = json.Unmarshal(configData, config)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		this.ErrorPage(err)
 | 
							this.ErrorPage(err)
 | 
				
			||||||
@@ -85,7 +84,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
 | 
				
			|||||||
	host := addr[:portIndex]
 | 
						host := addr[:portIndex]
 | 
				
			||||||
	port := addr[portIndex+1:]
 | 
						port := addr[portIndex+1:]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_, err := this.RPC().OriginServerRPC().UpdateOriginServer(this.AdminContext(), &pb.UpdateOriginServerRequest{
 | 
						_, err := this.RPC().OriginRPC().UpdateOrigin(this.AdminContext(), &pb.UpdateOriginRequest{
 | 
				
			||||||
		OriginId: params.OriginId,
 | 
							OriginId: params.OriginId,
 | 
				
			||||||
		Name:     "",
 | 
							Name:     "",
 | 
				
			||||||
		Addr: &pb.NetworkAddress{
 | 
							Addr: &pb.NetworkAddress{
 | 
				
			||||||
@@ -100,79 +99,5 @@ func (this *UpdatePopupAction) RunPost(params struct {
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	originConfigResp, err := this.RPC().OriginServerRPC().FindEnabledOriginServerConfig(this.AdminContext(), &pb.FindEnabledOriginServerConfigRequest{OriginId: params.OriginId})
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		this.ErrorPage(err)
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	originConfigData := originConfigResp.OriginJSON
 | 
					 | 
				
			||||||
	var originConfig = &serverconfigs.OriginServerConfig{}
 | 
					 | 
				
			||||||
	err = json.Unmarshal(originConfigData, originConfig)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		this.ErrorPage(err)
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// 查找反向代理信息
 | 
					 | 
				
			||||||
	reverseProxyResp, err := this.RPC().ReverseProxyRPC().FindEnabledReverseProxy(this.AdminContext(), &pb.FindEnabledReverseProxyRequest{ReverseProxyId: params.ReverseProxyId})
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		this.ErrorPage(err)
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	reverseProxy := reverseProxyResp.ReverseProxy
 | 
					 | 
				
			||||||
	if reverseProxy == nil {
 | 
					 | 
				
			||||||
		this.ErrorPage(errors.New("reverse proxy should not be nil"))
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	origins := []*serverconfigs.OriginServerConfig{}
 | 
					 | 
				
			||||||
	switch params.OriginType {
 | 
					 | 
				
			||||||
	case "primary":
 | 
					 | 
				
			||||||
		if len(reverseProxy.PrimaryOriginsJSON) > 0 {
 | 
					 | 
				
			||||||
			err = json.Unmarshal(reverseProxy.PrimaryOriginsJSON, &origins)
 | 
					 | 
				
			||||||
			if err != nil {
 | 
					 | 
				
			||||||
				this.ErrorPage(err)
 | 
					 | 
				
			||||||
				return
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	case "backup":
 | 
					 | 
				
			||||||
		if len(reverseProxy.BackupOriginsJSON) > 0 {
 | 
					 | 
				
			||||||
			err = json.Unmarshal(reverseProxy.BackupOriginsJSON, &origins)
 | 
					 | 
				
			||||||
			if err != nil {
 | 
					 | 
				
			||||||
				this.ErrorPage(err)
 | 
					 | 
				
			||||||
				return
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	for index, origin := range origins {
 | 
					 | 
				
			||||||
		if origin.Id == params.OriginId {
 | 
					 | 
				
			||||||
			origins[index] = originConfig
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// 保存
 | 
					 | 
				
			||||||
	originsData, err := json.Marshal(origins)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		this.ErrorPage(err)
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	switch params.OriginType {
 | 
					 | 
				
			||||||
	case "primary":
 | 
					 | 
				
			||||||
		_, err = this.RPC().ReverseProxyRPC().UpdateReverseProxyPrimaryOrigins(this.AdminContext(), &pb.UpdateReverseProxyPrimaryOriginsRequest{
 | 
					 | 
				
			||||||
			ReverseProxyId: params.ReverseProxyId,
 | 
					 | 
				
			||||||
			OriginsJSON:    originsData,
 | 
					 | 
				
			||||||
		})
 | 
					 | 
				
			||||||
	case "backup":
 | 
					 | 
				
			||||||
		_, err = this.RPC().ReverseProxyRPC().UpdateReverseProxyBackupOrigins(this.AdminContext(), &pb.UpdateReverseProxyBackupOriginsRequest{
 | 
					 | 
				
			||||||
			ReverseProxyId: params.ReverseProxyId,
 | 
					 | 
				
			||||||
			OriginsJSON:    originsData,
 | 
					 | 
				
			||||||
		})
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		this.ErrorPage(err)
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	this.Success()
 | 
						this.Success()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,9 +2,8 @@ package web
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
 | 
					 | 
				
			||||||
	"github.com/iwind/TeaGo/actions"
 | 
						"github.com/iwind/TeaGo/actions"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -20,30 +19,11 @@ func (this *IndexAction) Init() {
 | 
				
			|||||||
func (this *IndexAction) RunGet(params struct {
 | 
					func (this *IndexAction) RunGet(params struct {
 | 
				
			||||||
	ServerId int64
 | 
						ServerId int64
 | 
				
			||||||
}) {
 | 
					}) {
 | 
				
			||||||
	server, _, isOk := serverutils.FindServer(this.Parent(), params.ServerId)
 | 
						webConfig, err := webutils.FindWebConfigWithServerId(this.Parent(), params.ServerId)
 | 
				
			||||||
	if !isOk {
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	webId := server.WebId
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	webConfig := &serverconfigs.HTTPWebConfig{
 | 
					 | 
				
			||||||
		Id:   webId,
 | 
					 | 
				
			||||||
		IsOn: true,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if webId > 0 {
 | 
					 | 
				
			||||||
		resp, err := this.RPC().HTTPWebRPC().FindEnabledHTTPWeb(this.AdminContext(), &pb.FindEnabledHTTPWebRequest{WebId: webId})
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		this.ErrorPage(err)
 | 
							this.ErrorPage(err)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
		if resp.Web != nil {
 | 
					 | 
				
			||||||
			web := resp.Web
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			webConfig.Id = webId
 | 
					 | 
				
			||||||
			webConfig.IsOn = web.IsOn
 | 
					 | 
				
			||||||
			webConfig.Root = web.Root
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this.Data["webConfig"] = webConfig
 | 
						this.Data["webConfig"] = webConfig
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -57,24 +37,7 @@ func (this *IndexAction) RunPost(params struct {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	Must *actions.Must
 | 
						Must *actions.Must
 | 
				
			||||||
}) {
 | 
					}) {
 | 
				
			||||||
	if params.WebId <= 0 {
 | 
					
 | 
				
			||||||
		resp, err := this.RPC().HTTPWebRPC().CreateHTTPWeb(this.AdminContext(), &pb.CreateHTTPWebRequest{
 | 
					 | 
				
			||||||
			Root: params.Root,
 | 
					 | 
				
			||||||
		})
 | 
					 | 
				
			||||||
		if err != nil {
 | 
					 | 
				
			||||||
			this.ErrorPage(err)
 | 
					 | 
				
			||||||
			return
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		webId := resp.WebId
 | 
					 | 
				
			||||||
		_, err = this.RPC().ServerRPC().UpdateServerWeb(this.AdminContext(), &pb.UpdateServerWebRequest{
 | 
					 | 
				
			||||||
			ServerId: params.ServerId,
 | 
					 | 
				
			||||||
			WebId:    webId,
 | 
					 | 
				
			||||||
		})
 | 
					 | 
				
			||||||
		if err != nil {
 | 
					 | 
				
			||||||
			this.ErrorPage(err)
 | 
					 | 
				
			||||||
			return
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
	_, err := this.RPC().HTTPWebRPC().UpdateHTTPWeb(this.AdminContext(), &pb.UpdateHTTPWebRequest{
 | 
						_, err := this.RPC().HTTPWebRPC().UpdateHTTPWeb(this.AdminContext(), &pb.UpdateHTTPWebRequest{
 | 
				
			||||||
		WebId: params.WebId,
 | 
							WebId: params.WebId,
 | 
				
			||||||
		Root:  params.Root,
 | 
							Root:  params.Root,
 | 
				
			||||||
@@ -83,7 +46,6 @@ func (this *IndexAction) RunPost(params struct {
 | 
				
			|||||||
		this.ErrorPage(err)
 | 
							this.ErrorPage(err)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this.Success()
 | 
						this.Success()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,7 +35,18 @@ import (
 | 
				
			|||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/http"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/http"
 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/https"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/https"
 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations"
 | 
				
			||||||
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/access"
 | 
				
			||||||
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/accessLog"
 | 
				
			||||||
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/cache"
 | 
				
			||||||
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/charset"
 | 
				
			||||||
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/gzip"
 | 
				
			||||||
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/headers"
 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/location"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/location"
 | 
				
			||||||
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/pages"
 | 
				
			||||||
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/reverseProxy"
 | 
				
			||||||
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/stat"
 | 
				
			||||||
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/waf"
 | 
				
			||||||
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/web"
 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/origins"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/origins"
 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/pages"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/pages"
 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/reverseProxy"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/reverseProxy"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,7 +13,7 @@ Vue.component("http-charsets-box", {
 | 
				
			|||||||
	<table class="ui table definition selectable">
 | 
						<table class="ui table definition selectable">
 | 
				
			||||||
		<tr>
 | 
							<tr>
 | 
				
			||||||
			<td class="title">选择字符编码</td>
 | 
								<td class="title">选择字符编码</td>
 | 
				
			||||||
			<td><select class="ui dropdown auto-width" name="charset" v-model="charset">
 | 
								<td><select class="ui dropdown" style="width:20em" name="charset" v-model="charset">
 | 
				
			||||||
					<option value="">[未选择]</option>
 | 
										<option value="">[未选择]</option>
 | 
				
			||||||
					<optgroup label="常用字符编码"></optgroup>
 | 
										<optgroup label="常用字符编码"></optgroup>
 | 
				
			||||||
					<option v-for="charset in vUsualCharsets" :value="charset.charset">{{charset.charset}}({{charset.name}})</option>
 | 
										<option v-for="charset in vUsualCharsets" :value="charset.charset">{{charset.charset}}({{charset.name}})</option>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -40,7 +40,7 @@
 | 
				
			|||||||
  opacity: 0.3;
 | 
					  opacity: 0.3;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
.left-box.tiny {
 | 
					.left-box.tiny {
 | 
				
			||||||
  top: 10em;
 | 
					  top: 10.5em;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
.right-box {
 | 
					.right-box {
 | 
				
			||||||
  position: fixed;
 | 
					  position: fixed;
 | 
				
			||||||
@@ -52,6 +52,10 @@
 | 
				
			|||||||
  padding-bottom: 1em;
 | 
					  padding-bottom: 1em;
 | 
				
			||||||
  overflow-y: auto;
 | 
					  overflow-y: auto;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					.right-box.tiny {
 | 
				
			||||||
 | 
					  top: 10em;
 | 
				
			||||||
 | 
					  left: 26.5em;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
.right-box::-webkit-scrollbar {
 | 
					.right-box::-webkit-scrollbar {
 | 
				
			||||||
  width: 4px;
 | 
					  width: 4px;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -53,7 +53,7 @@
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.left-box.tiny {
 | 
					.left-box.tiny {
 | 
				
			||||||
	top: 10em;
 | 
						top: 10.5em;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.right-box {
 | 
					.right-box {
 | 
				
			||||||
@@ -67,6 +67,11 @@
 | 
				
			|||||||
	overflow-y: auto;
 | 
						overflow-y: auto;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.right-box.tiny {
 | 
				
			||||||
 | 
						top: 10em;
 | 
				
			||||||
 | 
						left: 26.5em;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.right-box::-webkit-scrollbar {
 | 
					.right-box::-webkit-scrollbar {
 | 
				
			||||||
	width: 4px;
 | 
						width: 4px;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					<first-menu>
 | 
				
			||||||
 | 
						<menu-item :href="'/servers/server/settings/locations?serverId=' + serverId">所有路径规则 »</menu-item>
 | 
				
			||||||
 | 
						<menu-item :href="'/servers/server/settings/locations/location?serverId=' + serverId + '&locationId=' + locationId" :active="true">{{locationConfig.pattern}}</menu-item>
 | 
				
			||||||
 | 
					</first-menu>
 | 
				
			||||||
@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					undefined
 | 
				
			||||||
@@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					{$layout}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{$template "/left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div class="right-box">
 | 
				
			||||||
 | 
						{$template "../location_menu"}
 | 
				
			||||||
 | 
						{$template "../left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<div class="right-box tiny">
 | 
				
			||||||
 | 
							<div class="margin"></div>
 | 
				
			||||||
 | 
							<p class="ui message">此功能暂未开放,敬请期待。</p>
 | 
				
			||||||
 | 
						</div>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					undefined
 | 
				
			||||||
@@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					{$layout}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{$template "/left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div class="right-box">
 | 
				
			||||||
 | 
						{$template "../location_menu"}
 | 
				
			||||||
 | 
						{$template "../left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<div class="right-box tiny">
 | 
				
			||||||
 | 
							<form class="ui form" data-tea-action="$" data-tea-success="success">
 | 
				
			||||||
 | 
								<input type="hidden" name="webId" :value="webId"/>
 | 
				
			||||||
 | 
								<http-access-log-config-box
 | 
				
			||||||
 | 
										:v-access-log-config="accessLogConfig"
 | 
				
			||||||
 | 
										:v-fields="fields"
 | 
				
			||||||
 | 
										:v-default-field-codes="defaultFieldCodes"
 | 
				
			||||||
 | 
										:v-access-log-policies="accessLogPolicies"></http-access-log-config-box>
 | 
				
			||||||
 | 
								<submit-btn></submit-btn>
 | 
				
			||||||
 | 
							</form>
 | 
				
			||||||
 | 
						</div>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						this.success = NotifyReloadSuccess("保存成功")
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
							
								
								
									
										0
									
								
								web/views/@default/servers/server/settings/locations/cache/index.css
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								web/views/@default/servers/server/settings/locations/cache/index.css
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
								
								
									
										1
									
								
								web/views/@default/servers/server/settings/locations/cache/index.css.map
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								web/views/@default/servers/server/settings/locations/cache/index.css.map
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					undefined
 | 
				
			||||||
							
								
								
									
										16
									
								
								web/views/@default/servers/server/settings/locations/cache/index.html
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								web/views/@default/servers/server/settings/locations/cache/index.html
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
				
			|||||||
 | 
					{$layout}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{$template "/left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div class="right-box">
 | 
				
			||||||
 | 
						{$template "../location_menu"}
 | 
				
			||||||
 | 
						{$template "../left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<div class="right-box tiny">
 | 
				
			||||||
 | 
							<form class="ui form" data-tea-action="$" data-tea-success="success">
 | 
				
			||||||
 | 
								<input type="hidden" name="webId" :value="webId"/>
 | 
				
			||||||
 | 
								<http-cache-config-box :v-cache-config="cacheConfig" :v-cache-policies="policies"></http-cache-config-box>
 | 
				
			||||||
 | 
								<submit-btn></submit-btn>
 | 
				
			||||||
 | 
							</form>
 | 
				
			||||||
 | 
						</div>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
							
								
								
									
										3
									
								
								web/views/@default/servers/server/settings/locations/cache/index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								web/views/@default/servers/server/settings/locations/cache/index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						this.success = NotifyReloadSuccess("保存成功")
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
							
								
								
									
										0
									
								
								web/views/@default/servers/server/settings/locations/cache/index.less
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								web/views/@default/servers/server/settings/locations/cache/index.less
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					undefined
 | 
				
			||||||
@@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					{$layout}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{$template "/left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div class="right-box">
 | 
				
			||||||
 | 
						{$template "../location_menu"}
 | 
				
			||||||
 | 
						{$template "../left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<div class="right-box tiny">
 | 
				
			||||||
 | 
							<div class="margin"></div>
 | 
				
			||||||
 | 
							<form class="ui form" data-tea-action="$" data-tea-success="success">
 | 
				
			||||||
 | 
								<input type="hidden" name="webId" :value="webId"/>
 | 
				
			||||||
 | 
								<http-charsets-box :v-usual-charsets="usualCharsets" :v-all-charsets="allCharsets" :v-charset="charset"></http-charsets-box>
 | 
				
			||||||
 | 
								<submit-btn></submit-btn>
 | 
				
			||||||
 | 
							</form>
 | 
				
			||||||
 | 
						</div>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						this.success = NotifyReloadSuccess("保存成功")
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
@@ -10,7 +10,7 @@
 | 
				
			|||||||
			<tr>
 | 
								<tr>
 | 
				
			||||||
				<td>路径匹配规则 *</td>
 | 
									<td>路径匹配规则 *</td>
 | 
				
			||||||
				<td>
 | 
									<td>
 | 
				
			||||||
					<input type="text" name="pattern" maxlength="500"/>
 | 
										<input type="text" name="pattern" maxlength="500" ref="focus"/>
 | 
				
			||||||
					<p class="comment">路径通常以斜杠(/)开头,比如/hello。如果匹配类型是正则表达式匹配,则可以是一个正则表达式</p>
 | 
										<p class="comment">路径通常以斜杠(/)开头,比如/hello。如果匹配类型是正则表达式匹配,则可以是一个正则表达式</p>
 | 
				
			||||||
				</td>
 | 
									</td>
 | 
				
			||||||
			</tr>
 | 
								</tr>
 | 
				
			||||||
@@ -36,7 +36,7 @@
 | 
				
			|||||||
			<tr>
 | 
								<tr>
 | 
				
			||||||
				<td class="title">名称</td>
 | 
									<td class="title">名称</td>
 | 
				
			||||||
				<td>
 | 
									<td>
 | 
				
			||||||
					<input type="text" name="name" ref="focus" maxlength="100"/>
 | 
										<input type="text" name="name" maxlength="100"/>
 | 
				
			||||||
					<p class="comment">可以用来说明此规则用途。。</p>
 | 
										<p class="comment">可以用来说明此规则用途。。</p>
 | 
				
			||||||
				</td>
 | 
									</td>
 | 
				
			||||||
			</tr>
 | 
								</tr>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					undefined
 | 
				
			||||||
@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					{$layout}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{$template "/left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div class="right-box">
 | 
				
			||||||
 | 
						{$template "../location_menu"}
 | 
				
			||||||
 | 
						{$template "../left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<div class="right-box tiny">
 | 
				
			||||||
 | 
							<div class="margin"></div>
 | 
				
			||||||
 | 
							<form class="ui form" data-tea-success="success" data-tea-action="$">
 | 
				
			||||||
 | 
								<input type="hidden" name="webId" :value="webId"/>
 | 
				
			||||||
 | 
								<input type="hidden" name="gzipId" :value="gzipConfig.id"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								<http-gzip-box :v-gzip-config="gzipConfig"></http-gzip-box>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								<div class="margin"></div>
 | 
				
			||||||
 | 
								<submit-btn></submit-btn>
 | 
				
			||||||
 | 
							</form>
 | 
				
			||||||
 | 
						</div>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						this.success = NotifyReloadSuccess("保存成功")
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
@@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					{$layout "layout_popup"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<h3>添加需要删除的Header</h3>
 | 
				
			||||||
 | 
					<form class="ui form" data-tea-action="$" data-tea-success="success">
 | 
				
			||||||
 | 
						<input type="hidden" name="headerPolicyId" :value="headerPolicyId"/>
 | 
				
			||||||
 | 
						<table class="ui table definition selectable">
 | 
				
			||||||
 | 
							<tr>
 | 
				
			||||||
 | 
								<td class="title">名称<em>(Name)</em></td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<input type="text" name="name" maxlength="100" ref="focus"/>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
						</table>
 | 
				
			||||||
 | 
						<submit-btn></submit-btn>
 | 
				
			||||||
 | 
					</form>
 | 
				
			||||||
@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						this.success = NotifyPopup
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
@@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					{$layout "layout_popup"}
 | 
				
			||||||
 | 
					<h3>设置Header</h3>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<form class="ui form" data-tea-action="$" data-tea-success="success">
 | 
				
			||||||
 | 
						<input type="hidden" name="serverId" :value="serverId"/>
 | 
				
			||||||
 | 
						<input type="hidden" name="headerPolicyId" :value="headerPolicyId"/>
 | 
				
			||||||
 | 
						<table class="ui table definition selectable">
 | 
				
			||||||
 | 
							<tr>
 | 
				
			||||||
 | 
								<td class="title">名称<em>(Name)</em></td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<input type="text" name="name" value="" maxlength="200" placeholder="类似于Server、Content-Type之类" ref="focus"/>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
							<tr>
 | 
				
			||||||
 | 
								<td>值<em>(Value)</em></td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<input type="text" name="value" maxlength="500"/>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
						</table>
 | 
				
			||||||
 | 
						<submit-btn></submit-btn>
 | 
				
			||||||
 | 
					</form>
 | 
				
			||||||
@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						this.success = NotifyPopup
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					undefined
 | 
				
			||||||
@@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					{$layout}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{$template "/left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div class="right-box">
 | 
				
			||||||
 | 
						{$template "../location_menu"}
 | 
				
			||||||
 | 
						{$template "../left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<div class="right-box tiny">
 | 
				
			||||||
 | 
							<http-header-policy-box :v-request-header-policy="requestHeaderPolicy" :v-response-header-policy="responseHeaderPolicy" :v-params="'serverId=' + serverId"></http-header-policy-box>
 | 
				
			||||||
 | 
						</div>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
@@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					{$layout "layout_popup"}
 | 
				
			||||||
 | 
					<h3>修改Header</h3>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<form class="ui form" data-tea-action="$" data-tea-success="success">
 | 
				
			||||||
 | 
						<input type="hidden" name="serverId" :value="serverId"/>
 | 
				
			||||||
 | 
						<input type="hidden" name="headerPolicyId" :value="headerPolicyId"/>
 | 
				
			||||||
 | 
						<input type="hidden" name="headerId" :value="headerId"/>
 | 
				
			||||||
 | 
						<table class="ui table definition selectable">
 | 
				
			||||||
 | 
							<tr>
 | 
				
			||||||
 | 
								<td class="title">名称<em>(Name)</em></td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<input type="text" name="name" value="" v-model="headerConfig.name" maxlength="200" placeholder="类似于Server、Content-Type之类" ref="focus"/>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
							<tr>
 | 
				
			||||||
 | 
								<td>值<em>(Value)</em></td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<input type="text" name="value" v-model="headerConfig.value" maxlength="500"/>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
						</table>
 | 
				
			||||||
 | 
						<submit-btn></submit-btn>
 | 
				
			||||||
 | 
					</form>
 | 
				
			||||||
@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						this.success = NotifyPopup
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
@@ -2,9 +2,79 @@
 | 
				
			|||||||
{$template "/left_menu"}
 | 
					{$template "/left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<div class="right-box">
 | 
					<div class="right-box">
 | 
				
			||||||
	<first-menu>
 | 
						{$template "../location_menu"}
 | 
				
			||||||
		<menu-item :href="'/servers/server/settings/locations?serverId=' + serverId">所有路径规则 »</menu-item>
 | 
						{$template "../left_menu"}
 | 
				
			||||||
		<menu-item :href="'/servers/server/settings/locations/location?serverId=' + serverId + '&locationId=' + locationId" :active="true">{{locationConfig.pattern}}</menu-item>
 | 
					
 | 
				
			||||||
	</first-menu>
 | 
						<div class="right-box tiny">
 | 
				
			||||||
	{$template "/servers/server/settings/locations/left_menu"}
 | 
							<form class="ui form" data-tea-action="$" data-tea-success="success">
 | 
				
			||||||
 | 
								<input type="hidden" name="locationId" :value="locationConfig.id"/>
 | 
				
			||||||
 | 
								<table class="ui table selectable definition">
 | 
				
			||||||
 | 
									<tr>
 | 
				
			||||||
 | 
										<td>路径匹配规则 *</td>
 | 
				
			||||||
 | 
										<td>
 | 
				
			||||||
 | 
											<input type="text" name="pattern" v-model="pattern" maxlength="500" ref="focus"/>
 | 
				
			||||||
 | 
											<p class="comment">路径通常以斜杠(/)开头,比如/hello。如果匹配类型是正则表达式匹配,则可以是一个正则表达式</p>
 | 
				
			||||||
 | 
										</td>
 | 
				
			||||||
 | 
									</tr>
 | 
				
			||||||
 | 
									<tr>
 | 
				
			||||||
 | 
										<td>匹配类型</td>
 | 
				
			||||||
 | 
										<td>
 | 
				
			||||||
 | 
											<select class="ui dropdown auto-width" name="patternType" v-model="type" @change="changePatternType(type)">
 | 
				
			||||||
 | 
												<option v-for="patternType in patternTypes" :value="patternType.type">{{patternType.name}}</option>
 | 
				
			||||||
 | 
											</select>
 | 
				
			||||||
 | 
											<p class="comment" v-if="selectedType != null" v-html="selectedType.description"></p>
 | 
				
			||||||
 | 
										</td>
 | 
				
			||||||
 | 
									</tr>
 | 
				
			||||||
 | 
									<tr>
 | 
				
			||||||
 | 
										<td>是否终止往下匹配</td>
 | 
				
			||||||
 | 
										<td>
 | 
				
			||||||
 | 
											<div class="ui checkbox">
 | 
				
			||||||
 | 
												<input type="checkbox" name="isBreak" value="1" v-model="locationConfig.isBreak"/>
 | 
				
			||||||
 | 
												<label></label>
 | 
				
			||||||
 | 
											</div>
 | 
				
			||||||
 | 
											<p class="comment">如果选中了此选项,一旦匹配成功,不会继续匹配其他的路径规则。</p>
 | 
				
			||||||
 | 
										</td>
 | 
				
			||||||
 | 
									</tr>
 | 
				
			||||||
 | 
									<tr>
 | 
				
			||||||
 | 
										<td class="title">名称</td>
 | 
				
			||||||
 | 
										<td>
 | 
				
			||||||
 | 
											<input type="text" name="name" maxlength="100" v-model="locationConfig.name"/>
 | 
				
			||||||
 | 
											<p class="comment">可以用来说明此规则用途。。</p>
 | 
				
			||||||
 | 
										</td>
 | 
				
			||||||
 | 
									</tr>
 | 
				
			||||||
 | 
									<tr>
 | 
				
			||||||
 | 
										<td colspan="2"><more-options-indicator></more-options-indicator></td>
 | 
				
			||||||
 | 
									</tr>
 | 
				
			||||||
 | 
									<tbody v-show="moreOptionsVisible">
 | 
				
			||||||
 | 
									<tr>
 | 
				
			||||||
 | 
										<td>不区分大小写</td>
 | 
				
			||||||
 | 
										<td>
 | 
				
			||||||
 | 
											<div class="ui checkbox">
 | 
				
			||||||
 | 
												<input type="checkbox" name="isCaseInsensitive" value="1" v-model="isCaseInsensitive"/>
 | 
				
			||||||
 | 
												<label></label>
 | 
				
			||||||
 | 
											</div>
 | 
				
			||||||
 | 
											<p class="comment">选中表示匹配规则中的路径中的英文字母不区分大小写。</p>
 | 
				
			||||||
 | 
										</td>
 | 
				
			||||||
 | 
									</tr>
 | 
				
			||||||
 | 
									<tr>
 | 
				
			||||||
 | 
										<td>反向匹配</td>
 | 
				
			||||||
 | 
										<td>
 | 
				
			||||||
 | 
											<div class="ui checkbox">
 | 
				
			||||||
 | 
												<input type="checkbox" name="isReverse" value="1" v-model="isReverse"/>
 | 
				
			||||||
 | 
												<label></label>
 | 
				
			||||||
 | 
											</div>
 | 
				
			||||||
 | 
											<p class="comment">选中表示匹配所有<strong>不符合规则</strong>的路径。</p>
 | 
				
			||||||
 | 
										</td>
 | 
				
			||||||
 | 
									</tr>
 | 
				
			||||||
 | 
									<tr>
 | 
				
			||||||
 | 
										<td>描述</td>
 | 
				
			||||||
 | 
										<td>
 | 
				
			||||||
 | 
											<textarea rows="3" name="description" maxlength="200" v-model="locationConfig.description"></textarea>
 | 
				
			||||||
 | 
										</td>
 | 
				
			||||||
 | 
									</tr>
 | 
				
			||||||
 | 
									</tbody>
 | 
				
			||||||
 | 
								</table>
 | 
				
			||||||
 | 
								<submit-btn></submit-btn>
 | 
				
			||||||
 | 
							</form>
 | 
				
			||||||
 | 
						</div>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
@@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						this.success = NotifyReloadSuccess("保存成功")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.$delay(function () {
 | 
				
			||||||
 | 
							this.changePatternType(this.type)
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.selectedType = null
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.changePatternType = function (type) {
 | 
				
			||||||
 | 
							this.selectedType = this.patternTypes.$find(function (k, v) {
 | 
				
			||||||
 | 
								return v.type == type;
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
@@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					{$layout "layout_popup"}
 | 
				
			||||||
 | 
					<h3>添加特殊页面</h3>
 | 
				
			||||||
 | 
					<form class="ui form" data-tea-action="$" data-tea-success="success">
 | 
				
			||||||
 | 
						<table class="ui table selectable definition">
 | 
				
			||||||
 | 
							<tr>
 | 
				
			||||||
 | 
								<td class="title">响应状态码 *</td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<input type="text" name="status" size="3" placeholder="状态码" maxlength="3" style="width:5.2em" ref="focus"/>
 | 
				
			||||||
 | 
									<p class="comment">比如404,或者50x。</p>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
							<tr>
 | 
				
			||||||
 | 
								<td>URL *</td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<input type="text" name="url" maxlength="500" placeholder="页面文件路径或者完整的URL"/>
 | 
				
			||||||
 | 
									<p class="comment">页面文件是相对于节点安装目录的页面文件比如web/pages/40x.html,或者一个完整的URL。</p>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
							<tr>
 | 
				
			||||||
 | 
								<td>新状态码</td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<input type="text" name="newStatus" size="3" placeholder="状态码" maxlength="3" style="width:5.2em"/>
 | 
				
			||||||
 | 
									<p class="comment">可以用来修改响应的状态码,不填表示不改变原有状态码。</p>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
						</table>
 | 
				
			||||||
 | 
						<submit-btn></submit-btn>
 | 
				
			||||||
 | 
					</form>
 | 
				
			||||||
@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						this.success = NotifyPopup
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					undefined
 | 
				
			||||||
@@ -0,0 +1,16 @@
 | 
				
			|||||||
 | 
					{$layout}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{$template "/left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div class="right-box">
 | 
				
			||||||
 | 
						{$template "../location_menu"}
 | 
				
			||||||
 | 
						{$template "../left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<div class="right-box tiny">
 | 
				
			||||||
 | 
							<form class="ui form" data-tea-action="$" data-tea-success="success">
 | 
				
			||||||
 | 
								<input type="hidden" name="webId" :value="webId"/>
 | 
				
			||||||
 | 
								<http-pages-and-shutdown-box :v-pages="pages" :v-shutdown-config="shutdownConfig"></http-pages-and-shutdown-box>
 | 
				
			||||||
 | 
								<submit-btn></submit-btn>
 | 
				
			||||||
 | 
							</form>
 | 
				
			||||||
 | 
						</div>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						this.success = NotifyReloadSuccess("保存成功")
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
@@ -0,0 +1,29 @@
 | 
				
			|||||||
 | 
					{$layout "layout_popup"}
 | 
				
			||||||
 | 
					<h3>修改特殊页面</h3>
 | 
				
			||||||
 | 
					<form class="ui form" data-tea-action="$" data-tea-success="success">
 | 
				
			||||||
 | 
						<input type="hidden" name="pageId" :value="pageConfig.id"/>
 | 
				
			||||||
 | 
						<table class="ui table selectable definition">
 | 
				
			||||||
 | 
							<tr>
 | 
				
			||||||
 | 
								<td class="title">响应状态码 *</td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<input type="text" name="status" size="3" placeholder="状态码" maxlength="3" style="width:5.2em" ref="focus" v-model="pageConfig.status"/>
 | 
				
			||||||
 | 
									<p class="comment">比如404,或者50x。</p>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
							<tr>
 | 
				
			||||||
 | 
								<td>URL *</td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<input type="text" name="url" maxlength="500" placeholder="页面文件路径或者完整的URL" v-model="pageConfig.url"/>
 | 
				
			||||||
 | 
									<p class="comment">页面文件是相对于节点安装目录的页面文件比如web/pages/40x.html,或者一个完整的URL。</p>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
							<tr>
 | 
				
			||||||
 | 
								<td>新状态码</td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<input type="text" name="newStatus" size="3" placeholder="状态码" maxlength="3" style="width:5.2em" v-model="newStatus"/>
 | 
				
			||||||
 | 
									<p class="comment">可以用来修改响应的状态码,不填表示不改变原有状态码。</p>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
						</table>
 | 
				
			||||||
 | 
						<submit-btn></submit-btn>
 | 
				
			||||||
 | 
					</form>
 | 
				
			||||||
@@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						this.success = NotifyPopup
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.newStatus = ""
 | 
				
			||||||
 | 
						if (this.pageConfig.newStatus > 0) {
 | 
				
			||||||
 | 
							this.newStatus = this.pageConfig.newStatus
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
@@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					<first-menu>
 | 
				
			||||||
 | 
						<menu-item :href="'/servers/server/settings/locations/reverseProxy?serverId=' + serverId + '&locationId=' + locationId" code="index">源站列表</menu-item>
 | 
				
			||||||
 | 
						<menu-item :href="'/servers/server/settings/locations/reverseProxy/scheduling?serverId=' + serverId + '&locationId=' + locationId" code="scheduling">调度算法</menu-item>
 | 
				
			||||||
 | 
					</first-menu>
 | 
				
			||||||
@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					undefined
 | 
				
			||||||
@@ -0,0 +1,34 @@
 | 
				
			|||||||
 | 
					{$layout}
 | 
				
			||||||
 | 
					{$template "/left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div class="right-box">
 | 
				
			||||||
 | 
						{$template "../location_menu"}
 | 
				
			||||||
 | 
						{$template "../left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<div class="right-box tiny">
 | 
				
			||||||
 | 
							{$template "menu"}
 | 
				
			||||||
 | 
							<div class="margin"></div>
 | 
				
			||||||
 | 
							<form class="ui form" data-tea-action="$" data-tea-success="success">
 | 
				
			||||||
 | 
								<input type="hidden" name="locationId" :value="locationId"/>
 | 
				
			||||||
 | 
								<input type="hidden" name="reverseProxyRefJSON" :value="JSON.stringify(reverseProxyRef)"/>
 | 
				
			||||||
 | 
								<table class="ui table selectable definition">
 | 
				
			||||||
 | 
									<tr>
 | 
				
			||||||
 | 
										<td class="title">是否启用反向代理</td>
 | 
				
			||||||
 | 
										<td>
 | 
				
			||||||
 | 
											<div class="ui checkbox">
 | 
				
			||||||
 | 
												<input type="checkbox" v-model="reverseProxyRef.isOn"/>
 | 
				
			||||||
 | 
												<label></label>
 | 
				
			||||||
 | 
											</div>
 | 
				
			||||||
 | 
										</td>
 | 
				
			||||||
 | 
									</tr>
 | 
				
			||||||
 | 
								</table>
 | 
				
			||||||
 | 
								<submit-btn></submit-btn>
 | 
				
			||||||
 | 
							</form>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							<div v-if="reverseProxyRef.isOn">
 | 
				
			||||||
 | 
								<div class="ui divider"></div>
 | 
				
			||||||
 | 
								<origin-list-box :v-primary-origins="primaryOrigins" :v-backup-origins="backupOrigins" :v-server-type="serverType"
 | 
				
			||||||
 | 
											 :v-params="'type=server&serverId=' + serverId + '&reverseProxyId=' + reverseProxyConfig.id"></origin-list-box>
 | 
				
			||||||
 | 
							</div>
 | 
				
			||||||
 | 
						</div>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
@@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						this.success = NotifyReloadSuccess("保存成功")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.updateOn = function (b) {
 | 
				
			||||||
 | 
							teaweb.confirm(b ? "确定要启用反向代理服务吗?" : "确定要停用反向代理服务吗?", function () {
 | 
				
			||||||
 | 
								this.$post(".updateOn")
 | 
				
			||||||
 | 
									.params({
 | 
				
			||||||
 | 
										"serverId": this.serverId,
 | 
				
			||||||
 | 
										"isOn": b ? 1 : 0,
 | 
				
			||||||
 | 
										"reverseProxyId": this.reverseProxyId
 | 
				
			||||||
 | 
									})
 | 
				
			||||||
 | 
									.success(function () {
 | 
				
			||||||
 | 
										window.location.reload()
 | 
				
			||||||
 | 
									})
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
@@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					{$layout}
 | 
				
			||||||
 | 
					{$template "/left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div class="right-box">
 | 
				
			||||||
 | 
						{$template "../location_menu"}
 | 
				
			||||||
 | 
						{$template "../left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<div class="right-box tiny">
 | 
				
			||||||
 | 
							{$template "menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							<origin-scheduling-view-box :v-scheduling="scheduling" :v-params="'type=server&serverId=' + serverId + '&reverseProxyId=' + reverseProxyId"></origin-scheduling-view-box>
 | 
				
			||||||
 | 
						</div>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
@@ -0,0 +1,60 @@
 | 
				
			|||||||
 | 
					{$layout "layout_popup"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<h3>修改调度算法</h3>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<form class="ui form" data-tea-action="$" data-tea-success="success">
 | 
				
			||||||
 | 
						<input type="hidden" name="dataType" :value="dataType"/>
 | 
				
			||||||
 | 
						<input type="hidden" name="serverId" :value="serverId"/>
 | 
				
			||||||
 | 
						<input type="hidden" name="reverseProxyId" :value="reverseProxyId"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<table class="ui table selectable definition">
 | 
				
			||||||
 | 
							<tr>
 | 
				
			||||||
 | 
								<td class="title">选择调度算法</td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<select class="ui dropdown auto-width" name="type" v-model="selectedType"
 | 
				
			||||||
 | 
											@change="changeSchedulingType()">
 | 
				
			||||||
 | 
										<option v-for="schedulingType in schedulingTypes"
 | 
				
			||||||
 | 
												:value="schedulingType.code">{{schedulingType.name}}</option>
 | 
				
			||||||
 | 
									</select>
 | 
				
			||||||
 | 
									<p class="comment">{{schedulingTypeDescription}}</p>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
							<tr v-if="selectedType == 'hash'">
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									Key
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<input type="text" name="hashKey" v-model="hashKey" maxlength="500"/>
 | 
				
			||||||
 | 
									<p class="comment">用来计算Hash的字符串,其中可以使用变量。</p>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
							<tr v-if="selectedType == 'hash'">
 | 
				
			||||||
 | 
								<td>常用变量</td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<select class="ui dropdown" style="width:12em" v-model="hashVar" @change="changeHashVar()">
 | 
				
			||||||
 | 
										<option></option>
 | 
				
			||||||
 | 
										<option value="${remoteAddr}">客户端IP</option>
 | 
				
			||||||
 | 
										<option value="${host}${requestURI}">请求URL</option>
 | 
				
			||||||
 | 
									</select>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
							<tr v-if="selectedType == 'sticky'">
 | 
				
			||||||
 | 
								<td>参数类型</td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<select class="ui dropdown" style="width:12em" name="stickyType" v-model="stickyType">
 | 
				
			||||||
 | 
										<option value="cookie">Cookie</option>
 | 
				
			||||||
 | 
										<option value="header">HTTP Header</option>
 | 
				
			||||||
 | 
										<option value="argument">URL参数</option>
 | 
				
			||||||
 | 
									</select>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
							<tr v-if="selectedType == 'sticky'">
 | 
				
			||||||
 | 
								<td>参数名</td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<input type="text" name="stickyParam" v-model="stickyParam" maxlength="50"/>
 | 
				
			||||||
 | 
									<p class="comment">记录或指定后端服务器的参数名,只能是英文字母和数字的组合,不允许有下划线(因为在HTTP Header中下划线是不标准的)</p>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
						</table>
 | 
				
			||||||
 | 
						<submit-btn></submit-btn>
 | 
				
			||||||
 | 
					</form>
 | 
				
			||||||
@@ -0,0 +1,39 @@
 | 
				
			|||||||
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						var that = this;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.success = NotifyPopup
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.selectedType = this.scheduling.code;
 | 
				
			||||||
 | 
						this.schedulingTypeDescription = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.changeSchedulingType = function () {
 | 
				
			||||||
 | 
							this.schedulingTypeDescription = this.schedulingTypes.$find(function (k, v) {
 | 
				
			||||||
 | 
								return v.code == that.selectedType;
 | 
				
			||||||
 | 
							}).description;
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
						this.changeSchedulingType();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// hash
 | 
				
			||||||
 | 
						this.hashKey = "";
 | 
				
			||||||
 | 
						this.hashVar = "";
 | 
				
			||||||
 | 
						if (this.scheduling.code == "hash") {
 | 
				
			||||||
 | 
							this.hashKey = this.scheduling.options.key;
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							this.hashKey = "${remoteAddr}";
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.changeHashVar = function () {
 | 
				
			||||||
 | 
							if (this.hashVar.length > 0) {
 | 
				
			||||||
 | 
								this.hashKey = this.hashVar;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// sticky
 | 
				
			||||||
 | 
						if (this.scheduling.code == "sticky") {
 | 
				
			||||||
 | 
							this.stickyType = this.scheduling.options.type;
 | 
				
			||||||
 | 
							this.stickyParam = this.scheduling.options.param;
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							this.stickyType = "cookie";
 | 
				
			||||||
 | 
							this.stickyParam = "Origin";
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					undefined
 | 
				
			||||||
@@ -0,0 +1,16 @@
 | 
				
			|||||||
 | 
					{$layout}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{$template "/left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div class="right-box">
 | 
				
			||||||
 | 
						{$template "../location_menu"}
 | 
				
			||||||
 | 
						{$template "../left_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<div class="right-box tiny">
 | 
				
			||||||
 | 
							<form class="ui form" data-tea-action="$" data-tea-success="success">
 | 
				
			||||||
 | 
								<input type="hidden" name="webId" :value="webId"/>
 | 
				
			||||||
 | 
								<http-stat-config-box :v-stat-config="statConfig"></http-stat-config-box>
 | 
				
			||||||
 | 
								<submit-btn></submit-btn>
 | 
				
			||||||
 | 
							</form>
 | 
				
			||||||
 | 
						</div>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						this.success = NotifyReloadSuccess("保存成功")
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user