mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 16:00:24 +08:00 
			
		
		
		
	实现源站跟随功能
This commit is contained in:
		@@ -107,6 +107,7 @@ func (this *ReverseProxyDAO) ComposeReverseProxyConfig(tx *dbs.Tx, reverseProxyI
 | 
			
		||||
	config.RequestURI = reverseProxy.RequestURI
 | 
			
		||||
	config.StripPrefix = reverseProxy.StripPrefix
 | 
			
		||||
	config.AutoFlush = reverseProxy.AutoFlush == 1
 | 
			
		||||
	config.FollowRedirects = reverseProxy.FollowRedirects == 1
 | 
			
		||||
 | 
			
		||||
	schedulingConfig := &serverconfigs.SchedulingConfig{}
 | 
			
		||||
	if len(reverseProxy.Scheduling) > 0 && reverseProxy.Scheduling != "null" {
 | 
			
		||||
@@ -312,12 +313,13 @@ func (this *ReverseProxyDAO) UpdateReverseProxy(tx *dbs.Tx,
 | 
			
		||||
	idleTimeout *shared.TimeDuration,
 | 
			
		||||
	maxConns int32,
 | 
			
		||||
	maxIdleConns int32,
 | 
			
		||||
	proxyProtocolJSON []byte) error {
 | 
			
		||||
	proxyProtocolJSON []byte,
 | 
			
		||||
	followRedirects bool) error {
 | 
			
		||||
	if reverseProxyId <= 0 {
 | 
			
		||||
		return errors.New("invalid reverseProxyId")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	op := NewReverseProxyOperator()
 | 
			
		||||
	var op = NewReverseProxyOperator()
 | 
			
		||||
	op.Id = reverseProxyId
 | 
			
		||||
 | 
			
		||||
	if requestHostType < 0 {
 | 
			
		||||
@@ -329,6 +331,7 @@ func (this *ReverseProxyDAO) UpdateReverseProxy(tx *dbs.Tx,
 | 
			
		||||
	op.RequestURI = requestURI
 | 
			
		||||
	op.StripPrefix = stripPrefix
 | 
			
		||||
	op.AutoFlush = autoFlush
 | 
			
		||||
	op.FollowRedirects = followRedirects
 | 
			
		||||
 | 
			
		||||
	if len(addHeaders) == 0 {
 | 
			
		||||
		addHeaders = []string{}
 | 
			
		||||
 
 | 
			
		||||
@@ -24,6 +24,7 @@ type ReverseProxy struct {
 | 
			
		||||
	MaxConns        uint32 `field:"maxConns"`        // 最大并发连接数
 | 
			
		||||
	MaxIdleConns    uint32 `field:"maxIdleConns"`    // 最大空闲连接数
 | 
			
		||||
	ProxyProtocol   string `field:"proxyProtocol"`   // Proxy Protocol配置
 | 
			
		||||
	FollowRedirects uint8  `field:"followRedirects"` // 回源跟随
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ReverseProxyOperator struct {
 | 
			
		||||
@@ -49,6 +50,7 @@ type ReverseProxyOperator struct {
 | 
			
		||||
	MaxConns        interface{} // 最大并发连接数
 | 
			
		||||
	MaxIdleConns    interface{} // 最大空闲连接数
 | 
			
		||||
	ProxyProtocol   interface{} // Proxy Protocol配置
 | 
			
		||||
	FollowRedirects interface{} // 回源跟随
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewReverseProxyOperator() *ReverseProxyOperator {
 | 
			
		||||
 
 | 
			
		||||
@@ -216,7 +216,7 @@ func (this *ReverseProxyService) UpdateReverseProxy(ctx context.Context, req *pb
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	err = models.SharedReverseProxyDAO.UpdateReverseProxy(tx, req.ReverseProxyId, types.Int8(req.RequestHostType), req.RequestHost, req.RequestURI, req.StripPrefix, req.AutoFlush, req.AddHeaders, connTimeout, readTimeout, idleTimeout, req.MaxConns, req.MaxIdleConns, req.ProxyProtocolJSON)
 | 
			
		||||
	err = models.SharedReverseProxyDAO.UpdateReverseProxy(tx, req.ReverseProxyId, types.Int8(req.RequestHostType), req.RequestHost, req.RequestURI, req.StripPrefix, req.AutoFlush, req.AddHeaders, connTimeout, readTimeout, idleTimeout, req.MaxConns, req.MaxIdleConns, req.ProxyProtocolJSON, req.FollowRedirects)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user