2020-09-13 19:27:47 +08:00
|
|
|
package serverconfigs
|
|
|
|
|
|
2021-01-14 16:34:16 +08:00
|
|
|
const (
|
|
|
|
|
DefaultTCPPortRangeMin = 10000
|
|
|
|
|
DefaultTCPPortRangeMax = 40000
|
|
|
|
|
)
|
|
|
|
|
|
2022-01-09 10:44:26 +08:00
|
|
|
// GlobalConfig 服务相关的全局设置
|
2020-09-13 19:27:47 +08:00
|
|
|
type GlobalConfig struct {
|
2020-11-04 20:54:18 +08:00
|
|
|
// HTTP & HTTPS相关配置
|
2020-09-13 19:27:47 +08:00
|
|
|
HTTPAll struct {
|
2020-11-18 12:17:46 +08:00
|
|
|
MatchDomainStrictly bool `yaml:"matchDomainStrictly" json:"matchDomainStrictly"` // 是否严格匹配域名
|
|
|
|
|
AllowMismatchDomains []string `yaml:"allowMismatchDomains" json:"allowMismatchDomains"` // 允许的不匹配的域名
|
|
|
|
|
DefaultDomain string `yaml:"defaultDomain" json:"defaultDomain"` // 默认的域名
|
|
|
|
|
DomainMismatchAction *DomainMismatchAction `yaml:"domainMismatchAction" json:"domainMismatchAction"` // 不匹配时采取的动作
|
2020-12-18 21:19:25 +08:00
|
|
|
DomainAuditingIsOn bool `yaml:"domainAuditingIsOn" json:"domainAuditingIsOn"` // 域名是否需要审核
|
|
|
|
|
DomainAuditingPrompt string `yaml:"domainAuditingPrompt" json:"domainAuditingPrompt"` // 域名审核的提示
|
2020-09-13 19:27:47 +08:00
|
|
|
} `yaml:"httpAll" json:"httpAll"`
|
2020-11-04 20:54:18 +08:00
|
|
|
|
2020-09-13 19:27:47 +08:00
|
|
|
HTTP struct{} `yaml:"http" json:"http"`
|
|
|
|
|
HTTPS struct{} `yaml:"https" json:"https"`
|
2021-01-14 16:34:16 +08:00
|
|
|
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"`
|
2020-11-04 20:54:18 +08:00
|
|
|
|
|
|
|
|
// IP库相关配置
|
|
|
|
|
IPLibrary struct {
|
|
|
|
|
Code string `yaml:"code" json:"code"` // 当前使用的IP库代号
|
|
|
|
|
} `yaml:"ipLibrary" json:"ipLibrary"`
|
2020-09-13 19:27:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *GlobalConfig) Init() error {
|
2020-11-18 12:17:46 +08:00
|
|
|
// HTTPAll
|
|
|
|
|
if this.HTTPAll.DomainMismatchAction != nil {
|
|
|
|
|
err := this.HTTPAll.DomainMismatchAction.Init()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-13 19:27:47 +08:00
|
|
|
return nil
|
|
|
|
|
}
|