优化代码

This commit is contained in:
刘祥超
2020-12-18 21:19:25 +08:00
parent d906380700
commit a6befe4233
14 changed files with 739 additions and 470 deletions

View File

@@ -8,6 +8,8 @@ type GlobalConfig struct {
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"`

View File

@@ -1,5 +1,7 @@
package serverconfigs
import "encoding/json"
type HTTPCacheConfig struct {
IsPrior bool `yaml:"isPrior" json:"isPrior"`
IsOn bool `yaml:"isOn" json:"isOn"`
@@ -16,3 +18,7 @@ func (this *HTTPCacheConfig) Init() error {
}
return nil
}
func (this *HTTPCacheConfig) AsJSON() ([]byte, error) {
return json.Marshal(this)
}

View File

@@ -1,5 +1,7 @@
package serverconfigs
import "encoding/json"
type HTTPProtocolConfig struct {
BaseProtocol `yaml:",inline"`
}
@@ -12,3 +14,8 @@ func (this *HTTPProtocolConfig) Init() error {
return nil
}
// 转换为JSON
func (this *HTTPProtocolConfig) AsJSON() ([]byte, error) {
return json.Marshal(this)
}

View File

@@ -1,6 +1,9 @@
package serverconfigs
import "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
import (
"encoding/json"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
)
// HTTPS协议配置
type HTTPSProtocolConfig struct {
@@ -26,3 +29,8 @@ func (this *HTTPSProtocolConfig) Init() error {
return nil
}
// 转换为JSON
func (this *HTTPSProtocolConfig) AsJSON() ([]byte, error) {
return json.Marshal(this)
}

View File

@@ -1,5 +1,7 @@
package serverconfigs
import "encoding/json"
type TCPProtocolConfig struct {
BaseProtocol `yaml:",inline"`
}
@@ -12,3 +14,8 @@ func (this *TCPProtocolConfig) Init() error {
return nil
}
// 转换为JSON
func (this *TCPProtocolConfig) AsJSON() ([]byte, error) {
return json.Marshal(this)
}

View File

@@ -1,6 +1,9 @@
package shared
import "time"
import (
"encoding/json"
"time"
)
type TimeDurationUnit = string
@@ -34,3 +37,7 @@ func (this *TimeDuration) Duration() time.Duration {
return time.Duration(this.Count) * time.Second
}
}
func (this *TimeDuration) AsJSON() ([]byte, error) {
return json.Marshal(this)
}