mirror of
				https://github.com/TeaOSLab/EdgeCommon.git
				synced 2025-11-04 13:10:24 +08:00 
			
		
		
		
	增加PROXY Protocol版本号校验
This commit is contained in:
		@@ -2,6 +2,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
package serverconfigs
 | 
					package serverconfigs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"errors"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/types"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type ProxyProtocolVersion = int
 | 
					type ProxyProtocolVersion = int
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
@@ -17,5 +22,11 @@ type ProxyProtocolConfig struct {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Init 初始化
 | 
					// Init 初始化
 | 
				
			||||||
func (this *ProxyProtocolConfig) Init() error {
 | 
					func (this *ProxyProtocolConfig) Init() error {
 | 
				
			||||||
 | 
						if this.IsOn {
 | 
				
			||||||
 | 
							if this.Version != ProxyProtocolVersion1 && this.Version != ProxyProtocolVersion2 {
 | 
				
			||||||
 | 
								return errors.New("invalid ProxyProtocol version '" + types.String(this.Version) + "'")
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user