反向代理实现AutoFlush

This commit is contained in:
GoEdgeLab
2020-09-27 18:41:15 +08:00
parent acc4df8200
commit 553825c603
4 changed files with 7 additions and 2 deletions

View File

@@ -96,6 +96,7 @@ func (this *ReverseProxyDAO) ComposeReverseProxyConfig(reverseProxyId int64) (*s
config.RequestHost = reverseProxy.RequestHost config.RequestHost = reverseProxy.RequestHost
config.RequestURI = reverseProxy.RequestURI config.RequestURI = reverseProxy.RequestURI
config.StripPrefix = reverseProxy.StripPrefix config.StripPrefix = reverseProxy.StripPrefix
config.AutoFlush = reverseProxy.AutoFlush == 1
schedulingConfig := &serverconfigs.SchedulingConfig{} schedulingConfig := &serverconfigs.SchedulingConfig{}
if len(reverseProxy.Scheduling) > 0 && reverseProxy.Scheduling != "null" { if len(reverseProxy.Scheduling) > 0 && reverseProxy.Scheduling != "null" {
@@ -216,7 +217,7 @@ func (this *ReverseProxyDAO) UpdateReverseProxyBackupOrigins(reverseProxyId int6
} }
// 修改是否启用 // 修改是否启用
func (this *ReverseProxyDAO) UpdateReverseProxy(reverseProxyId int64, requestHost string, requestURI string, stripPrefix string) error { func (this *ReverseProxyDAO) UpdateReverseProxy(reverseProxyId int64, requestHost string, requestURI string, stripPrefix string, autoFlush bool) error {
if reverseProxyId <= 0 { if reverseProxyId <= 0 {
return errors.New("invalid reverseProxyId") return errors.New("invalid reverseProxyId")
} }
@@ -226,6 +227,7 @@ func (this *ReverseProxyDAO) UpdateReverseProxy(reverseProxyId int64, requestHos
op.RequestHost = requestHost op.RequestHost = requestHost
op.RequestURI = requestURI op.RequestURI = requestURI
op.StripPrefix = stripPrefix op.StripPrefix = stripPrefix
op.AutoFlush = autoFlush
_, err := this.Save(op) _, err := this.Save(op)
return err return err
} }

View File

@@ -13,6 +13,7 @@ type ReverseProxy struct {
StripPrefix string `field:"stripPrefix"` // 去除URL前缀 StripPrefix string `field:"stripPrefix"` // 去除URL前缀
RequestHost string `field:"requestHost"` // 请求Host RequestHost string `field:"requestHost"` // 请求Host
RequestURI string `field:"requestURI"` // 请求URI RequestURI string `field:"requestURI"` // 请求URI
AutoFlush uint8 `field:"autoFlush"` // 是否自动刷新缓冲区
State uint8 `field:"state"` // 状态 State uint8 `field:"state"` // 状态
CreatedAt uint64 `field:"createdAt"` // 创建时间 CreatedAt uint64 `field:"createdAt"` // 创建时间
} }
@@ -29,6 +30,7 @@ type ReverseProxyOperator struct {
StripPrefix interface{} // 去除URL前缀 StripPrefix interface{} // 去除URL前缀
RequestHost interface{} // 请求Host RequestHost interface{} // 请求Host
RequestURI interface{} // 请求URI RequestURI interface{} // 请求URI
AutoFlush interface{} // 是否自动刷新缓冲区
State interface{} // 状态 State interface{} // 状态
CreatedAt interface{} // 创建时间 CreatedAt interface{} // 创建时间
} }

View File

@@ -118,6 +118,7 @@ func (this *ServerDAO) CreateServer(adminId int64, userId int64, serverType serv
if len(excludeNodesJSON) > 0 { if len(excludeNodesJSON) > 0 {
op.ExcludeNodes = excludeNodesJSON op.ExcludeNodes = excludeNodesJSON
} }
op.GroupIds = "[]" op.GroupIds = "[]"
op.Version = 1 op.Version = 1
op.IsOn = 1 op.IsOn = 1

View File

@@ -129,7 +129,7 @@ func (this *ReverseProxyService) UpdateReverseProxy(ctx context.Context, req *pb
return nil, err return nil, err
} }
err = models.SharedReverseProxyDAO.UpdateReverseProxy(req.ReverseProxyId, req.RequestHost, req.RequestURI, req.StripPrefix) err = models.SharedReverseProxyDAO.UpdateReverseProxy(req.ReverseProxyId, req.RequestHost, req.RequestURI, req.StripPrefix, req.AutoFlush)
if err != nil { if err != nil {
return nil, err return nil, err
} }