mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-05 01:20:25 +08:00
反向代理实现AutoFlush
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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{} // 创建时间
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user