Archived
完善套餐
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
package serverconfigs
|
||||
|
||||
type PlanConfig struct {
|
||||
Id int64 `yaml:"id" json:"id"`
|
||||
Id int64 `yaml:"id" json:"id"`
|
||||
Name string `yaml:"name" json:"name"`
|
||||
}
|
||||
|
||||
func (this *PlanConfig) Init() error {
|
||||
|
||||
@@ -15,14 +15,14 @@ const (
|
||||
ServerNameTypeMatch ServerNameType = "match" // 正则匹配
|
||||
)
|
||||
|
||||
// 主机名(域名)配置
|
||||
// ServerNameConfig 主机名(域名)配置
|
||||
type ServerNameConfig struct {
|
||||
Name string `yaml:"name" json:"name"` // 名称
|
||||
Type string `yaml:"type" json:"type"` // 类型
|
||||
SubNames []string `yaml:"subNames" json:"subNames"` // 子名称,用来支持大量的域名批量管理
|
||||
}
|
||||
|
||||
// 格式化域名
|
||||
// Normalize 格式化域名
|
||||
func (this *ServerNameConfig) Normalize() {
|
||||
this.Name = strings.ToLower(this.Name)
|
||||
for index, subName := range this.SubNames {
|
||||
@@ -30,7 +30,7 @@ func (this *ServerNameConfig) Normalize() {
|
||||
}
|
||||
}
|
||||
|
||||
// 判断主机名是否匹配
|
||||
// Match 判断主机名是否匹配
|
||||
func (this *ServerNameConfig) Match(name string) bool {
|
||||
if len(this.SubNames) > 0 {
|
||||
return configutils.MatchDomains(this.SubNames, name)
|
||||
@@ -38,14 +38,25 @@ func (this *ServerNameConfig) Match(name string) bool {
|
||||
return configutils.MatchDomains([]string{this.Name}, name)
|
||||
}
|
||||
|
||||
// 格式化一组域名
|
||||
// FirstName 获取第一个名称
|
||||
func (this *ServerNameConfig) FirstName() string {
|
||||
if len(this.Name) > 0 {
|
||||
return this.Name
|
||||
}
|
||||
if len(this.SubNames) > 0 {
|
||||
return this.SubNames[0]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// NormalizeServerNames 格式化一组域名
|
||||
func NormalizeServerNames(serverNames []*ServerNameConfig) {
|
||||
for _, serverName := range serverNames {
|
||||
serverName.Normalize()
|
||||
}
|
||||
}
|
||||
|
||||
// 获取所有域名
|
||||
// PlainServerNames 获取所有域名
|
||||
func PlainServerNames(serverNames []*ServerNameConfig) (result []string) {
|
||||
NormalizeServerNames(serverNames)
|
||||
for _, serverName := range serverNames {
|
||||
|
||||
Reference in New Issue
Block a user