From d6fad4a5a1bd85139c9307913913f12d33aece3f Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Thu, 7 Sep 2023 18:01:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=BF=E5=AE=A2IP=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/serverconfigs/http_remote_addr_config.go | 21 ++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/pkg/serverconfigs/http_remote_addr_config.go b/pkg/serverconfigs/http_remote_addr_config.go index ce02001..54f93d5 100644 --- a/pkg/serverconfigs/http_remote_addr_config.go +++ b/pkg/serverconfigs/http_remote_addr_config.go @@ -7,12 +7,23 @@ import ( "strings" ) +type HTTPRemoteAddrType = string + +const ( + HTTPRemoteAddrTypeDefault HTTPRemoteAddrType = "default" // 默认(直连) + HTTPRemoteAddrTypeProxy HTTPRemoteAddrType = "proxy" // 代理 + HTTPRemoteAddrTypeRequestHeader HTTPRemoteAddrType = "requestHeader" // 请求报头 + HTTPRemoteAddrTypeVariable HTTPRemoteAddrType = "variable" // 变量 +) + // HTTPRemoteAddrConfig HTTP获取客户端IP地址方式 type HTTPRemoteAddrConfig struct { - IsPrior bool `yaml:"isPrior" json:"isPrior"` - IsOn bool `yaml:"isOn" json:"isOn"` - Value string `yaml:"value" json:"value"` // 值变量 - IsCustomized bool `yaml:"isCustomized" json:"isCustomized"` // 是否自定义 + IsPrior bool `yaml:"isPrior" json:"isPrior"` + IsOn bool `yaml:"isOn" json:"isOn"` + Value string `yaml:"value" json:"value"` // 值变量 + Type HTTPRemoteAddrType `yaml:"type" json:"type"` // 类型 + + RequestHeaderName string `yaml:"requestHeaderName" json:"requestHeaderName"` // 请求报头名称(type = requestHeader时生效) isEmpty bool } @@ -26,8 +37,6 @@ func (this *HTTPRemoteAddrConfig) Init() error { this.isEmpty = true } - this.Value = strings.ReplaceAll(this.Value, "${remoteAddr}", "${remoteAddrValue}") - return nil }