From 3e5b1c70832dcc24d20aa909b450903a931217f7 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Mon, 26 Jul 2021 11:23:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=B7=B3=E8=BD=AC=E5=88=B0HT?= =?UTF-8?q?TPS=E5=8F=AF=E4=BB=A5=E8=AE=BE=E7=BD=AE=E5=85=81=E8=AE=B8?= =?UTF-8?q?=E5=92=8C=E6=8E=92=E9=99=A4=E7=9A=84=E5=9F=9F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../http_redirect_to_https_config.go | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/pkg/serverconfigs/http_redirect_to_https_config.go b/pkg/serverconfigs/http_redirect_to_https_config.go index 15927ae..c413a93 100644 --- a/pkg/serverconfigs/http_redirect_to_https_config.go +++ b/pkg/serverconfigs/http_redirect_to_https_config.go @@ -1,14 +1,33 @@ package serverconfigs -// 跳转到HTTPS配置 +import "github.com/TeaOSLab/EdgeCommon/pkg/configutils" + +// HTTPRedirectToHTTPSConfig 跳转到HTTPS配置 type HTTPRedirectToHTTPSConfig struct { IsPrior bool `yaml:"isPrior" json:"isPrior"` // 是否覆盖 IsOn bool `yaml:"isOn" json:"isOn"` // 是否开启 Status int `yaml:"status" json:"status"` // 跳转用的状态码 Host string `yaml:"host" json:"host"` // 跳转后的Host Port int `yaml:"port" json:"port"` // 跳转后的端口 + + OnlyDomains []string `yaml:"onlyDomains" json:"onlyDomains"` // 允许的域名 + ExceptDomains []string `yaml:"exceptDomains" json:"exceptDomains"` // 排除的域名 } +// Init 初始化 func (this *HTTPRedirectToHTTPSConfig) Init() error { return nil } + +// MatchDomain 检查域名是否匹配 +func (this *HTTPRedirectToHTTPSConfig) MatchDomain(domain string) bool { + if len(this.ExceptDomains) > 0 && configutils.MatchDomains(this.ExceptDomains, domain) { + return false + } + + if len(this.OnlyDomains) > 0 && !configutils.MatchDomains(this.OnlyDomains, domain) { + return false + } + + return true +}