mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-03 12:20:27 +08:00
增加PROXY Protocol版本号校验
This commit is contained in:
@@ -2,6 +2,11 @@
|
||||
|
||||
package serverconfigs
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
)
|
||||
|
||||
type ProxyProtocolVersion = int
|
||||
|
||||
const (
|
||||
@@ -17,5 +22,11 @@ type ProxyProtocolConfig struct {
|
||||
|
||||
// Init 初始化
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user