From 2b8191001b07dc18deca15f7f6e5e10c0483a16d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Mon, 18 Sep 2023 16:55:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E5=85=A8=E5=B1=80=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E7=9A=84TCP=E7=9B=B8=E5=85=B3=E8=AE=BE=E7=BD=AE=E7=A7=BB?= =?UTF-8?q?=E5=88=B0=E2=80=9C=E9=9B=86=E7=BE=A4=E8=AE=BE=E7=BD=AE--?= =?UTF-8?q?=E7=BD=91=E7=AB=99=E8=AE=BE=E7=BD=AE=E2=80=9D=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/nodeconfigs/node_config.go | 11 +----- pkg/rpc/dao/sys_setting_dao.go | 41 ----------------------- pkg/serverconfigs/global_config.go | 25 -------------- pkg/serverconfigs/global_server_config.go | 6 ++++ pkg/systemconfigs/settings.go | 1 - 5 files changed, 7 insertions(+), 77 deletions(-) delete mode 100644 pkg/rpc/dao/sys_setting_dao.go delete mode 100644 pkg/serverconfigs/global_config.go diff --git a/pkg/nodeconfigs/node_config.go b/pkg/nodeconfigs/node_config.go index daa916f..f7d8d0b 100644 --- a/pkg/nodeconfigs/node_config.go +++ b/pkg/nodeconfigs/node_config.go @@ -74,7 +74,6 @@ type NodeConfig struct { ParentNodes map[int64][]*ParentNodeConfig `yaml:"parentNodes" json:"parentNodes"` // clusterId => []*ParentNodeConfig // 全局配置 - GlobalConfig *serverconfigs.GlobalConfig `yaml:"globalConfig" json:"globalConfig"` // 全局配置 GlobalServerConfig *serverconfigs.GlobalServerConfig `yaml:"globalServerConfig" json:"globalServerConfig"` // 服务全局配置,用来替代 GlobalConfig ProductConfig *ProductConfig `yaml:"productConfig" json:"productConfig"` @@ -263,14 +262,6 @@ func (this *NodeConfig) Init(ctx context.Context) (err error, serverErrors []*Se } } - // global config - if this.GlobalConfig != nil { - err = this.GlobalConfig.Init() - if err != nil { - return - } - } - // cache policy if len(this.HTTPCachePolicies) > 0 { for _, policy := range this.HTTPCachePolicies { @@ -774,4 +765,4 @@ func (this *NodeConfig) SecretHash() string { // HasConnTimeoutSettings 检查是否有连接超时设置 func (this *NodeConfig) HasConnTimeoutSettings() bool { return this.GlobalServerConfig != nil && (this.GlobalServerConfig.Performance.AutoReadTimeout || this.GlobalServerConfig.Performance.AutoWriteTimeout) -} \ No newline at end of file +} diff --git a/pkg/rpc/dao/sys_setting_dao.go b/pkg/rpc/dao/sys_setting_dao.go deleted file mode 100644 index cc43f31..0000000 --- a/pkg/rpc/dao/sys_setting_dao.go +++ /dev/null @@ -1,41 +0,0 @@ -package dao - -import ( - "context" - "encoding/json" - "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" -) - -type SettingCode = string - -const ( - SettingCodeServerGlobalConfig SettingCode = "serverGlobalConfig" // 服务相关全局设置 - SettingCodeNodeMonitor SettingCode = "nodeMonitor" // 监控节点状态 - SettingCodeClusterHealthCheck SettingCode = "clusterHealthCheck" // 集群健康检查 - SettingCodeIPListVersion SettingCode = "ipListVersion" // IP名单的版本号 - SettingCodeAdminSecurityConfig SettingCode = "adminSecurityConfig" // 管理员安全设置 -) - -var SharedSysSettingDAO = new(SysSettingDAO) - -type SysSettingDAO struct { - BaseDAO -} - -// 读取服务全局配置 -func (this *SysSettingDAO) ReadGlobalConfig(ctx context.Context) (*serverconfigs.GlobalConfig, error) { - globalConfigResp, err := this.RPC().SysSettingRPC().ReadSysSetting(ctx, &pb.ReadSysSettingRequest{Code: SettingCodeServerGlobalConfig}) - if err != nil { - return nil, err - } - if len(globalConfigResp.ValueJSON) == 0 { - return nil, nil - } - globalConfig := &serverconfigs.GlobalConfig{} - err = json.Unmarshal(globalConfigResp.ValueJSON, globalConfig) - if err != nil { - return nil, err - } - return globalConfig, nil -} diff --git a/pkg/serverconfigs/global_config.go b/pkg/serverconfigs/global_config.go deleted file mode 100644 index 988f227..0000000 --- a/pkg/serverconfigs/global_config.go +++ /dev/null @@ -1,25 +0,0 @@ -package serverconfigs - -// 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"` // 域名审核的提示 - } `yaml:"httpAll" json:"httpAll"` - - TCPAll struct { - PortRangeMin int `yaml:"portRangeMin" json:"portRangeMin"` // 最小端口 - PortRangeMax int `yaml:"portRangeMax" json:"portRangeMax"` // 最大端口 - DenyPorts []int `yaml:"denyPorts" json:"denyPorts"` // 禁止使用的端口 - } `yaml:"tcpAll" json:"tcpAll"` -} - -func (this *GlobalConfig) Init() error { - return nil -} diff --git a/pkg/serverconfigs/global_server_config.go b/pkg/serverconfigs/global_server_config.go index 787aa68..fd98371 100644 --- a/pkg/serverconfigs/global_server_config.go +++ b/pkg/serverconfigs/global_server_config.go @@ -61,6 +61,12 @@ type GlobalServerConfig struct { DomainAuditingPrompt string `yaml:"domainAuditingPrompt" json:"domainAuditingPrompt"` // 域名审核的提示 } `yaml:"httpAll" json:"httpAll"` // HTTP统一配置 + TCPAll struct { + PortRangeMin int `yaml:"portRangeMin" json:"portRangeMin"` // 最小端口 + PortRangeMax int `yaml:"portRangeMax" json:"portRangeMax"` // 最大端口 + DenyPorts []int `yaml:"denyPorts" json:"denyPorts"` // 禁止使用的端口 + } `yaml:"tcpAll" json:"tcpAll"` + HTTPAccessLog struct { IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用此功能 EnableRequestHeaders bool `yaml:"enableRequestHeaders" json:"enableRequestHeaders"` // 记录请求Header diff --git a/pkg/systemconfigs/settings.go b/pkg/systemconfigs/settings.go index 2c467ba..ae6ae87 100644 --- a/pkg/systemconfigs/settings.go +++ b/pkg/systemconfigs/settings.go @@ -3,7 +3,6 @@ package systemconfigs type SettingCode = string const ( - SettingCodeServerGlobalConfig SettingCode = "serverGlobalConfig" // Deprecated 服务相关全局设置 SettingCodeNodeMonitor SettingCode = "nodeMonitor" // 监控节点状态 SettingCodeClusterHealthCheck SettingCode = "clusterHealthCheck" // 集群健康检查 SettingCodeIPListVersion SettingCode = "ipListVersion" // IP名单的版本号