From 9cc9c4e2b3cb2eb2d50a060051a48f0e2d746e53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Sun, 6 Aug 2023 09:55:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0PROXY=20Protocol=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/serverconfigs/proxy_protocol_config.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/serverconfigs/proxy_protocol_config.go b/pkg/serverconfigs/proxy_protocol_config.go index cde30ee..95c14d1 100644 --- a/pkg/serverconfigs/proxy_protocol_config.go +++ b/pkg/serverconfigs/proxy_protocol_config.go @@ -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 }