增加配置分组配置

This commit is contained in:
刘祥超
2021-09-22 19:39:55 +08:00
parent e8429b8f74
commit 7c530680c0
13 changed files with 1438 additions and 154 deletions

View File

@@ -41,6 +41,9 @@ type ServerConfig struct {
HTTPCachePolicyId int64 `yaml:"httpCachePolicyId" json:"httpCachePolicyId"`
HTTPCachePolicy *HTTPCachePolicy `yaml:"httpCachePolicy" json:"httpCachePolicy"` // 通过 HTTPCachePolicyId 获取
// 分组
Group *ServerGroupConfig `yaml:"group" json:"group"`
isOk bool
}
@@ -56,6 +59,23 @@ func NewServerConfig() *ServerConfig {
}
func (this *ServerConfig) Init() error {
// 分解Group
if this.Group != nil && this.Group.IsOn {
// reverse proxy
if this.IsHTTPFamily() && this.Group.HTTPReverseProxyRef != nil && this.Group.HTTPReverseProxyRef.IsPrior {
this.ReverseProxyRef = this.Group.HTTPReverseProxyRef
this.ReverseProxy = this.Group.HTTPReverseProxy
}
if this.IsTCPFamily() && this.Group.TCPReverseProxyRef != nil && this.Group.TCPReverseProxyRef.IsPrior {
this.ReverseProxyRef = this.Group.TCPReverseProxyRef
this.ReverseProxy = this.Group.TCPReverseProxy
}
if this.IsUDPFamily() && this.Group.UDPReverseProxyRef != nil && this.Group.UDPReverseProxyRef.IsPrior {
this.ReverseProxyRef = this.Group.UDPReverseProxyRef
this.ReverseProxy = this.Group.UDPReverseProxy
}
}
if this.HTTP != nil {
err := this.HTTP.Init()
if err != nil {