From 3e2d8fab122f1048db2b8e30f9509ca87bffe457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Sun, 1 Nov 2020 18:01:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=89=B9=E9=87=8F=E5=9F=9F?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/serverconfigs/server_name_config.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/serverconfigs/server_name_config.go b/pkg/serverconfigs/server_name_config.go index 675b400..a551ecf 100644 --- a/pkg/serverconfigs/server_name_config.go +++ b/pkg/serverconfigs/server_name_config.go @@ -5,19 +5,23 @@ import "github.com/TeaOSLab/EdgeCommon/pkg/configutils" type ServerNameType = string const ( - ServerNameTypeFull = "full" // 完整的域名,包含通配符等 - ServerNameTypePrefix = "prefix" // 前缀 - ServerNameTypeSuffix = "suffix" // 后缀 - ServerNameTypeMatch = "match" // 正则匹配 + ServerNameTypeFull ServerNameType = "full" // 完整的域名,包含通配符等 + ServerNameTypePrefix ServerNameType = "prefix" // 前缀 + ServerNameTypeSuffix ServerNameType = "suffix" // 后缀 + ServerNameTypeMatch ServerNameType = "match" // 正则匹配 ) // 主机名(域名)配置 type ServerNameConfig struct { - Name string `yaml:"name" json:"name"` // 名称 - Type string `yaml:"type" json:"type"` // 类型 + Name string `yaml:"name" json:"name"` // 名称 + Type string `yaml:"type" json:"type"` // 类型 + SubNames []string `yaml:"subNames" json:"subNames"` // 子名称,用来支持大量的域名批量管理 } // 判断主机名是否匹配 func (this *ServerNameConfig) Match(name string) bool { + if len(this.SubNames) > 0 { + return configutils.MatchDomains(this.SubNames, name) + } return configutils.MatchDomains([]string{this.Name}, name) }