mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2026-02-26 04:25:37 +08:00
集群设置中增加服务设置
This commit is contained in:
@@ -6,42 +6,25 @@ const (
|
||||
)
|
||||
|
||||
// GlobalConfig 服务相关的全局设置
|
||||
// Deprecated
|
||||
type GlobalConfig struct {
|
||||
// HTTP & HTTPS相关配置
|
||||
HTTPAll struct {
|
||||
MatchDomainStrictly bool `yaml:"matchDomainStrictly" json:"matchDomainStrictly"` // 是否严格匹配域名
|
||||
AllowMismatchDomains []string `yaml:"allowMismatchDomains" json:"allowMismatchDomains"` // 允许的不匹配的域名
|
||||
DefaultDomain string `yaml:"defaultDomain" json:"defaultDomain"` // 默认的域名
|
||||
DomainMismatchAction *DomainMismatchAction `yaml:"domainMismatchAction" json:"domainMismatchAction"` // 不匹配时采取的动作
|
||||
DomainAuditingIsOn bool `yaml:"domainAuditingIsOn" json:"domainAuditingIsOn"` // 域名是否需要审核
|
||||
DomainAuditingPrompt string `yaml:"domainAuditingPrompt" json:"domainAuditingPrompt"` // 域名审核的提示
|
||||
//MatchDomainStrictly bool `yaml:"matchDomainStrictly" json:"matchDomainStrictly"` // 是否严格匹配域名
|
||||
//AllowMismatchDomains []string `yaml:"allowMismatchDomains" json:"allowMismatchDomains"` // 允许的不匹配的域名
|
||||
//DefaultDomain string `yaml:"defaultDomain" json:"defaultDomain"` // 默认的域名
|
||||
//DomainMismatchAction *DomainMismatchAction `yaml:"domainMismatchAction" json:"domainMismatchAction"` // 不匹配时采取的动作
|
||||
DomainAuditingIsOn bool `yaml:"domainAuditingIsOn" json:"domainAuditingIsOn"` // 域名是否需要审核
|
||||
DomainAuditingPrompt string `yaml:"domainAuditingPrompt" json:"domainAuditingPrompt"` // 域名审核的提示
|
||||
} `yaml:"httpAll" json:"httpAll"`
|
||||
|
||||
HTTP struct{} `yaml:"http" json:"http"`
|
||||
HTTPS struct{} `yaml:"https" json:"https"`
|
||||
TCPAll struct {
|
||||
PortRangeMin int `yaml:"portRangeMin" json:"portRangeMin"` // 最小端口
|
||||
PortRangeMax int `yaml:"portRangeMax" json:"portRangeMax"` // 最大端口
|
||||
DenyPorts []int `yaml:"denyPorts" json:"denyPorts"` // 禁止使用的端口
|
||||
} `yaml:"tcpAll" json:"tcpAll"`
|
||||
TCP struct{} `yaml:"tcp" json:"tcp"`
|
||||
TLS struct{} `yaml:"tls" json:"tls"`
|
||||
Unix struct{} `yaml:"unix" json:"unix"`
|
||||
UDP struct{} `yaml:"udp" json:"udp"`
|
||||
|
||||
// IP库相关配置
|
||||
IPLibrary struct {
|
||||
Code string `yaml:"code" json:"code"` // 当前使用的IP库代号
|
||||
} `yaml:"ipLibrary" json:"ipLibrary"`
|
||||
}
|
||||
|
||||
func (this *GlobalConfig) Init() error {
|
||||
// HTTPAll
|
||||
if this.HTTPAll.DomainMismatchAction != nil {
|
||||
err := this.HTTPAll.DomainMismatchAction.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
36
pkg/serverconfigs/global_server_config.go
Normal file
36
pkg/serverconfigs/global_server_config.go
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package serverconfigs
|
||||
|
||||
func DefaultGlobalServerConfig() *GlobalServerConfig {
|
||||
var config = &GlobalServerConfig{}
|
||||
config.Log.RecordServerError = false
|
||||
return config
|
||||
}
|
||||
|
||||
// GlobalServerConfig 全局的服务配置
|
||||
type GlobalServerConfig struct {
|
||||
HTTPAll struct {
|
||||
MatchDomainStrictly bool `yaml:"matchDomainStrictly" json:"matchDomainStrictly"` // 是否严格匹配域名
|
||||
AllowMismatchDomains []string `yaml:"allowMismatchDomains" json:"allowMismatchDomains"` // 允许的不匹配的域名
|
||||
AllowNodeIP bool `yaml:"allowNodeIP" json:"allowNodeIP"` // 允许IP直接访问
|
||||
DefaultDomain string `yaml:"defaultDomain" json:"defaultDomain"` // 默认的域名
|
||||
DomainMismatchAction *DomainMismatchAction `yaml:"domainMismatchAction" json:"domainMismatchAction"` // 不匹配时采取的动作
|
||||
} `yaml:"httpAll" json:"httpAll"`
|
||||
|
||||
Log struct {
|
||||
RecordServerError bool `yaml:"recordServerError" json:"recordServerError"` // 记录服务错误到运行日志
|
||||
} `yaml:"log" json:"log"`
|
||||
}
|
||||
|
||||
func (this *GlobalServerConfig) Init() error {
|
||||
// 未找到域名时的动作
|
||||
if this.HTTPAll.DomainMismatchAction != nil {
|
||||
err := this.HTTPAll.DomainMismatchAction.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user