mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-12 03:10:24 +08:00
阶段性提交
This commit is contained in:
8
pkg/rpc/dao/base_dao.go
Normal file
8
pkg/rpc/dao/base_dao.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package dao
|
||||
|
||||
type BaseDAO struct {
|
||||
}
|
||||
|
||||
func (this *BaseDAO) RPC() RPCClient {
|
||||
return sharedRPCClient
|
||||
}
|
||||
69
pkg/rpc/dao/http_cache_policy_dao.go
Normal file
69
pkg/rpc/dao/http_cache_policy_dao.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
)
|
||||
|
||||
var SharedHTTPCachePolicyDAO = new(HTTPCachePolicyDAO)
|
||||
|
||||
type HTTPCachePolicyDAO struct {
|
||||
BaseDAO
|
||||
}
|
||||
|
||||
// 查找缓存策略配置
|
||||
func (this *HTTPCachePolicyDAO) FindEnabledHTTPCachePolicyConfig(ctx context.Context, cachePolicyId int64) (*serverconfigs.HTTPCachePolicy, error) {
|
||||
resp, err := this.RPC().HTTPCachePolicyRPC().FindEnabledHTTPCachePolicyConfig(ctx, &pb.FindEnabledHTTPCachePolicyConfigRequest{HttpCachePolicyId: cachePolicyId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(resp.HttpCachePolicyJSON) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
config := &serverconfigs.HTTPCachePolicy{}
|
||||
err = json.Unmarshal(resp.HttpCachePolicyJSON, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
|
||||
// 查找缓存策略信息
|
||||
func (this *HTTPCachePolicyDAO) FindEnabledHTTPCachePolicy(ctx context.Context, cachePolicyId int64) (*pb.HTTPCachePolicy, error) {
|
||||
resp, err := this.RPC().HTTPCachePolicyRPC().FindEnabledHTTPCachePolicy(ctx, &pb.FindEnabledHTTPCachePolicyRequest{
|
||||
HttpCachePolicyId: cachePolicyId,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.HttpCachePolicy, nil
|
||||
}
|
||||
|
||||
// 根据服务ID查找缓存策略
|
||||
func (this *HTTPCachePolicyDAO) FindEnabledHTTPCachePolicyWithServerId(ctx context.Context, serverId int64) (*pb.HTTPCachePolicy, error) {
|
||||
serverResp, err := this.RPC().ServerRPC().FindEnabledServer(ctx, &pb.FindEnabledServerRequest{ServerId: serverId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
server := serverResp.Server
|
||||
if server == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if server.NodeCluster == nil {
|
||||
return nil, nil
|
||||
}
|
||||
clusterId := server.NodeCluster.Id
|
||||
cluster, err := SharedNodeClusterDAO.FindEnabledNodeCluster(ctx, clusterId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if cluster == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if cluster.HttpCachePolicyId == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return this.FindEnabledHTTPCachePolicy(ctx, cluster.HttpCachePolicyId)
|
||||
}
|
||||
182
pkg/rpc/dao/http_firewall_policy_dao.go
Normal file
182
pkg/rpc/dao/http_firewall_policy_dao.go
Normal file
@@ -0,0 +1,182 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ipconfigs"
|
||||
)
|
||||
|
||||
var SharedHTTPFirewallPolicyDAO = new(HTTPFirewallPolicyDAO)
|
||||
|
||||
// WAF策略相关
|
||||
type HTTPFirewallPolicyDAO struct {
|
||||
BaseDAO
|
||||
}
|
||||
|
||||
// 查找WAF策略基本信息
|
||||
func (this *HTTPFirewallPolicyDAO) FindEnabledHTTPFirewallPolicy(ctx context.Context, policyId int64) (*pb.HTTPFirewallPolicy, error) {
|
||||
resp, err := this.RPC().HTTPFirewallPolicyRPC().FindEnabledHTTPFirewallPolicy(ctx, &pb.FindEnabledHTTPFirewallPolicyRequest{HttpFirewallPolicyId: policyId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.HttpFirewallPolicy, nil
|
||||
}
|
||||
|
||||
// 查找WAF策略配置
|
||||
func (this *HTTPFirewallPolicyDAO) FindEnabledHTTPFirewallPolicyConfig(ctx context.Context, policyId int64) (*firewallconfigs.HTTPFirewallPolicy, error) {
|
||||
resp, err := this.RPC().HTTPFirewallPolicyRPC().FindEnabledHTTPFirewallPolicyConfig(ctx, &pb.FindEnabledHTTPFirewallPolicyConfigRequest{HttpFirewallPolicyId: policyId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(resp.HttpFirewallPolicyJSON) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
firewallPolicy := &firewallconfigs.HTTPFirewallPolicy{}
|
||||
err = json.Unmarshal(resp.HttpFirewallPolicyJSON, firewallPolicy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return firewallPolicy, nil
|
||||
}
|
||||
|
||||
// 查找WAF的Inbound
|
||||
func (this *HTTPFirewallPolicyDAO) FindEnabledHTTPFirewallPolicyInboundConfig(ctx context.Context, policyId int64) (*firewallconfigs.HTTPFirewallInboundConfig, error) {
|
||||
config, err := this.FindEnabledHTTPFirewallPolicyConfig(ctx, policyId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if config == nil {
|
||||
return nil, errors.New("not found")
|
||||
}
|
||||
return config.Inbound, nil
|
||||
}
|
||||
|
||||
// 根据类型查找WAF的IP名单
|
||||
func (this *HTTPFirewallPolicyDAO) FindEnabledPolicyIPListIdWithType(ctx context.Context, policyId int64, listType ipconfigs.IPListType) (int64, error) {
|
||||
switch listType {
|
||||
case ipconfigs.IPListTypeWhite:
|
||||
return this.FindEnabledPolicyWhiteIPListId(ctx, policyId)
|
||||
case ipconfigs.IPListTypeBlack:
|
||||
return this.FindEnabledPolicyBlackIPListId(ctx, policyId)
|
||||
default:
|
||||
return 0, errors.New("invalid ip list type '" + listType + "'")
|
||||
}
|
||||
}
|
||||
|
||||
// 查找WAF的白名单
|
||||
func (this *HTTPFirewallPolicyDAO) FindEnabledPolicyWhiteIPListId(ctx context.Context, policyId int64) (int64, error) {
|
||||
config, err := this.FindEnabledHTTPFirewallPolicyConfig(ctx, policyId)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if config == nil {
|
||||
return 0, errors.New("not found")
|
||||
}
|
||||
if config.Inbound == nil {
|
||||
config.Inbound = &firewallconfigs.HTTPFirewallInboundConfig{IsOn: true}
|
||||
}
|
||||
if config.Inbound.WhiteListRef == nil || config.Inbound.WhiteListRef.ListId == 0 {
|
||||
createResp, err := this.RPC().IPListRPC().CreateIPList(ctx, &pb.CreateIPListRequest{
|
||||
Type: "white",
|
||||
Name: "白名单",
|
||||
Code: "white",
|
||||
TimeoutJSON: nil,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
listId := createResp.IpListId
|
||||
config.Inbound.WhiteListRef = &ipconfigs.IPListRef{
|
||||
IsOn: true,
|
||||
ListId: listId,
|
||||
}
|
||||
inboundJSON, err := json.Marshal(config.Inbound)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
_, err = this.RPC().HTTPFirewallPolicyRPC().UpdateHTTPFirewallInboundConfig(ctx, &pb.UpdateHTTPFirewallInboundConfigRequest{
|
||||
HttpFirewallPolicyId: policyId,
|
||||
InboundJSON: inboundJSON,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return listId, nil
|
||||
}
|
||||
|
||||
return config.Inbound.WhiteListRef.ListId, nil
|
||||
}
|
||||
|
||||
// 查找WAF的黑名单
|
||||
func (this *HTTPFirewallPolicyDAO) FindEnabledPolicyBlackIPListId(ctx context.Context, policyId int64) (int64, error) {
|
||||
config, err := this.FindEnabledHTTPFirewallPolicyConfig(ctx, policyId)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if config == nil {
|
||||
return 0, errors.New("not found")
|
||||
}
|
||||
if config.Inbound == nil {
|
||||
config.Inbound = &firewallconfigs.HTTPFirewallInboundConfig{IsOn: true}
|
||||
}
|
||||
if config.Inbound.BlackListRef == nil || config.Inbound.BlackListRef.ListId == 0 {
|
||||
createResp, err := this.RPC().IPListRPC().CreateIPList(ctx, &pb.CreateIPListRequest{
|
||||
Type: "black",
|
||||
Name: "黑名单",
|
||||
Code: "black",
|
||||
TimeoutJSON: nil,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
listId := createResp.IpListId
|
||||
config.Inbound.BlackListRef = &ipconfigs.IPListRef{
|
||||
IsOn: true,
|
||||
ListId: listId,
|
||||
}
|
||||
inboundJSON, err := json.Marshal(config.Inbound)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
_, err = this.RPC().HTTPFirewallPolicyRPC().UpdateHTTPFirewallInboundConfig(ctx, &pb.UpdateHTTPFirewallInboundConfigRequest{
|
||||
HttpFirewallPolicyId: policyId,
|
||||
InboundJSON: inboundJSON,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return listId, nil
|
||||
}
|
||||
|
||||
return config.Inbound.BlackListRef.ListId, nil
|
||||
}
|
||||
|
||||
// 根据服务Id查找WAF策略
|
||||
func (this *HTTPFirewallPolicyDAO) FindEnabledHTTPFirewallPolicyWithServerId(ctx context.Context, serverId int64) (*pb.HTTPFirewallPolicy, error) {
|
||||
serverResp, err := this.RPC().ServerRPC().FindEnabledServer(ctx, &pb.FindEnabledServerRequest{ServerId: serverId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
server := serverResp.Server
|
||||
if server == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if server.NodeCluster == nil {
|
||||
return nil, nil
|
||||
}
|
||||
clusterId := server.NodeCluster.Id
|
||||
cluster, err := SharedNodeClusterDAO.FindEnabledNodeCluster(ctx, clusterId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if cluster == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if cluster.HttpFirewallPolicyId == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return SharedHTTPFirewallPolicyDAO.FindEnabledHTTPFirewallPolicy(ctx, cluster.HttpFirewallPolicyId)
|
||||
}
|
||||
34
pkg/rpc/dao/http_firewall_rule_group_dao.go
Normal file
34
pkg/rpc/dao/http_firewall_rule_group_dao.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
|
||||
)
|
||||
|
||||
var SharedHTTPFirewallRuleGroupDAO = new(HTTPFirewallRuleGroupDAO)
|
||||
|
||||
type HTTPFirewallRuleGroupDAO struct {
|
||||
BaseDAO
|
||||
}
|
||||
|
||||
// 查找分组配置
|
||||
func (this *HTTPFirewallRuleGroupDAO) FindRuleGroupConfig(ctx context.Context, groupId int64) (*firewallconfigs.HTTPFirewallRuleGroup, error) {
|
||||
groupResp, err := this.RPC().HTTPFirewallRuleGroupRPC().FindEnabledHTTPFirewallRuleGroupConfig(ctx, &pb.FindEnabledHTTPFirewallRuleGroupConfigRequest{FirewallRuleGroupId: groupId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(groupResp.FirewallRuleGroupJSON) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
groupConfig := &firewallconfigs.HTTPFirewallRuleGroup{}
|
||||
err = json.Unmarshal(groupResp.FirewallRuleGroupJSON, groupConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return groupConfig, nil
|
||||
}
|
||||
31
pkg/rpc/dao/http_firewall_rule_set_dao.go
Normal file
31
pkg/rpc/dao/http_firewall_rule_set_dao.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
|
||||
)
|
||||
|
||||
var SharedHTTPFirewallRuleSetDAO = new(HTTPFirewallRuleSetDAO)
|
||||
|
||||
type HTTPFirewallRuleSetDAO struct {
|
||||
BaseDAO
|
||||
}
|
||||
|
||||
// 查找规则集配置
|
||||
func (this *HTTPFirewallRuleSetDAO) FindRuleSetConfig(ctx context.Context, setId int64) (*firewallconfigs.HTTPFirewallRuleSet, error) {
|
||||
resp, err := this.RPC().HTTPFirewallRuleSetRPC().FindEnabledHTTPFirewallRuleSetConfig(ctx, &pb.FindEnabledHTTPFirewallRuleSetConfigRequest{FirewallRuleSetId: setId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(resp.FirewallRuleSetJSON) == 0 {
|
||||
return nil, err
|
||||
}
|
||||
config := &firewallconfigs.HTTPFirewallRuleSet{}
|
||||
err = json.Unmarshal(resp.FirewallRuleSetJSON, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
36
pkg/rpc/dao/log_dao.go
Normal file
36
pkg/rpc/dao/log_dao.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
)
|
||||
|
||||
var SharedLogDAO = NewLogDAO()
|
||||
|
||||
type LogDAO struct {
|
||||
BaseDAO
|
||||
}
|
||||
|
||||
func NewLogDAO() *LogDAO {
|
||||
return &LogDAO{}
|
||||
}
|
||||
|
||||
func (this *LogDAO) CreateUserLog(ctx context.Context, level string, action string, description string, ip string) error {
|
||||
_, err := this.RPC().LogRPC().CreateLog(ctx, &pb.CreateLogRequest{
|
||||
Level: level,
|
||||
Description: description,
|
||||
Action: action,
|
||||
Ip: ip,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func (this *LogDAO) CreateAdminLog(ctx context.Context, level string, action string, description string, ip string) error {
|
||||
_, err := this.RPC().LogRPC().CreateLog(ctx, &pb.CreateLogRequest{
|
||||
Level: level,
|
||||
Description: description,
|
||||
Action: action,
|
||||
Ip: ip,
|
||||
})
|
||||
return err
|
||||
}
|
||||
21
pkg/rpc/dao/node_cluster_dao.go
Normal file
21
pkg/rpc/dao/node_cluster_dao.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
)
|
||||
|
||||
var SharedNodeClusterDAO = new(NodeClusterDAO)
|
||||
|
||||
type NodeClusterDAO struct {
|
||||
BaseDAO
|
||||
}
|
||||
|
||||
// 查找集群
|
||||
func (this *NodeClusterDAO) FindEnabledNodeCluster(ctx context.Context, clusterId int64) (*pb.NodeCluster, error) {
|
||||
clusterResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeCluster(ctx, &pb.FindEnabledNodeClusterRequest{NodeClusterId: clusterId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return clusterResp.NodeCluster, nil
|
||||
}
|
||||
51
pkg/rpc/dao/rpc_client.go
Normal file
51
pkg/rpc/dao/rpc_client.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package dao
|
||||
|
||||
import "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
|
||||
var sharedRPCClient RPCClient
|
||||
|
||||
func SetRPC(client RPCClient) {
|
||||
sharedRPCClient = client
|
||||
}
|
||||
|
||||
type RPCClient interface {
|
||||
SysSettingRPC() pb.SysSettingServiceClient
|
||||
NodeClusterRPC() pb.NodeClusterServiceClient
|
||||
NodeRegionRPC() pb.NodeRegionServiceClient
|
||||
NodePriceItemRPC() pb.NodePriceItemServiceClient
|
||||
ServerRPC() pb.ServerServiceClient
|
||||
ServerGroupRPC() pb.ServerGroupServiceClient
|
||||
OriginRPC() pb.OriginServiceClient
|
||||
HTTPWebRPC() pb.HTTPWebServiceClient
|
||||
ReverseProxyRPC() pb.ReverseProxyServiceClient
|
||||
HTTPGzipRPC() pb.HTTPGzipServiceClient
|
||||
HTTPHeaderRPC() pb.HTTPHeaderServiceClient
|
||||
HTTPHeaderPolicyRPC() pb.HTTPHeaderPolicyServiceClient
|
||||
HTTPPageRPC() pb.HTTPPageServiceClient
|
||||
HTTPAccessLogPolicyRPC() pb.HTTPAccessLogPolicyServiceClient
|
||||
HTTPCachePolicyRPC() pb.HTTPCachePolicyServiceClient
|
||||
HTTPFirewallPolicyRPC() pb.HTTPFirewallPolicyServiceClient
|
||||
HTTPFirewallRuleGroupRPC() pb.HTTPFirewallRuleGroupServiceClient
|
||||
HTTPFirewallRuleSetRPC() pb.HTTPFirewallRuleSetServiceClient
|
||||
HTTPLocationRPC() pb.HTTPLocationServiceClient
|
||||
HTTPWebsocketRPC() pb.HTTPWebsocketServiceClient
|
||||
HTTPRewriteRuleRPC() pb.HTTPRewriteRuleServiceClient
|
||||
HTTPAccessLogRPC() pb.HTTPAccessLogServiceClient
|
||||
SSLCertRPC() pb.SSLCertServiceClient
|
||||
SSLPolicyRPC() pb.SSLPolicyServiceClient
|
||||
MessageRPC() pb.MessageServiceClient
|
||||
IPListRPC() pb.IPListServiceClient
|
||||
IPItemRPC() pb.IPItemServiceClient
|
||||
FileRPC() pb.FileServiceClient
|
||||
FileChunkRPC() pb.FileChunkServiceClient
|
||||
RegionCountryRPC() pb.RegionCountryServiceClient
|
||||
RegionProvinceRPC() pb.RegionProvinceServiceClient
|
||||
LogRPC() pb.LogServiceClient
|
||||
DNSDomainRPC() pb.DNSDomainServiceClient
|
||||
DNSRPC() pb.DNSServiceClient
|
||||
ACMEUserRPC() pb.ACMEUserServiceClient
|
||||
ACMETaskRPC() pb.ACMETaskServiceClient
|
||||
UserRPC() pb.UserServiceClient
|
||||
UserBillRPC() pb.UserBillServiceClient
|
||||
UserNodeRPC() pb.UserNodeServiceClient
|
||||
}
|
||||
31
pkg/rpc/dao/server_dao.go
Normal file
31
pkg/rpc/dao/server_dao.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
)
|
||||
|
||||
var SharedServerDAO = new(ServerDAO)
|
||||
|
||||
type ServerDAO struct {
|
||||
BaseDAO
|
||||
}
|
||||
|
||||
// 查找服务配置
|
||||
func (this *ServerDAO) FindServerConfig(ctx context.Context, serverId int64) (*serverconfigs.ServerConfig, error) {
|
||||
resp, err := this.RPC().ServerRPC().FindEnabledServerConfig(ctx, &pb.FindEnabledServerConfigRequest{ServerId: serverId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(resp.ServerJSON) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
config := &serverconfigs.ServerConfig{}
|
||||
err = json.Unmarshal(resp.ServerJSON, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
41
pkg/rpc/dao/sys_setting_dao.go
Normal file
41
pkg/rpc/dao/sys_setting_dao.go
Normal file
@@ -0,0 +1,41 @@
|
||||
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
|
||||
}
|
||||
@@ -42,6 +42,9 @@ type Server struct {
|
||||
// 配置相关
|
||||
Config []byte `protobuf:"bytes,17,opt,name=config,proto3" json:"config,omitempty"`
|
||||
ServerNamesJSON []byte `protobuf:"bytes,8,opt,name=serverNamesJSON,proto3" json:"serverNamesJSON,omitempty"`
|
||||
IsAuditing bool `protobuf:"varint,20,opt,name=isAuditing,proto3" json:"isAuditing,omitempty"`
|
||||
AuditingServerNamesJSON []byte `protobuf:"bytes,21,opt,name=auditingServerNamesJSON,proto3" json:"auditingServerNamesJSON,omitempty"`
|
||||
AuditingResult *ServerNameAuditingResult `protobuf:"bytes,22,opt,name=auditingResult,proto3" json:"auditingResult,omitempty"`
|
||||
HttpJSON []byte `protobuf:"bytes,9,opt,name=httpJSON,proto3" json:"httpJSON,omitempty"`
|
||||
HttpsJSON []byte `protobuf:"bytes,10,opt,name=httpsJSON,proto3" json:"httpsJSON,omitempty"`
|
||||
TcpJSON []byte `protobuf:"bytes,11,opt,name=tcpJSON,proto3" json:"tcpJSON,omitempty"`
|
||||
@@ -164,6 +167,27 @@ func (x *Server) GetServerNamesJSON() []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Server) GetIsAuditing() bool {
|
||||
if x != nil {
|
||||
return x.IsAuditing
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *Server) GetAuditingServerNamesJSON() []byte {
|
||||
if x != nil {
|
||||
return x.AuditingServerNamesJSON
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Server) GetAuditingResult() *ServerNameAuditingResult {
|
||||
if x != nil {
|
||||
return x.AuditingResult
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Server) GetHttpJSON() []byte {
|
||||
if x != nil {
|
||||
return x.HttpJSON
|
||||
@@ -249,50 +273,63 @@ var file_model_server_proto_rawDesc = []byte{
|
||||
0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x1a, 0x18, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
|
||||
0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x10, 0x6d, 0x6f,
|
||||
0x64, 0x65, 0x6c, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x98,
|
||||
0x05, 0x0a, 0x06, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x73, 0x4f,
|
||||
0x6e, 0x18, 0x12, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x12, 0x12, 0x0a,
|
||||
0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70,
|
||||
0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63,
|
||||
0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x22, 0x0a, 0x0c, 0x69, 0x6e, 0x63, 0x6c, 0x75,
|
||||
0x64, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x69,
|
||||
0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x65,
|
||||
0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28,
|
||||
0x0c, 0x52, 0x0c, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12,
|
||||
0x1c, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x07, 0x20, 0x01,
|
||||
0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x18, 0x0a,
|
||||
0x07, 0x64, 0x6e, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
|
||||
0x64, 0x6e, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69,
|
||||
0x67, 0x18, 0x11, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12,
|
||||
0x28, 0x0a, 0x0f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x4a, 0x53,
|
||||
0x4f, 0x4e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
|
||||
0x4e, 0x61, 0x6d, 0x65, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x1a, 0x0a, 0x08, 0x68, 0x74, 0x74,
|
||||
0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x68, 0x74, 0x74,
|
||||
0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x1c, 0x0a, 0x09, 0x68, 0x74, 0x74, 0x70, 0x73, 0x4a, 0x53,
|
||||
0x4f, 0x4e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x68, 0x74, 0x74, 0x70, 0x73, 0x4a,
|
||||
0x53, 0x4f, 0x4e, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x63, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0b,
|
||||
0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x74, 0x63, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x18, 0x0a,
|
||||
0x07, 0x74, 0x6c, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07,
|
||||
0x74, 0x6c, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x6e, 0x69, 0x78, 0x4a,
|
||||
0x53, 0x4f, 0x4e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x75, 0x6e, 0x69, 0x78, 0x4a,
|
||||
0x53, 0x4f, 0x4e, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x64, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0e,
|
||||
0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x75, 0x64, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x14, 0x0a,
|
||||
0x05, 0x77, 0x65, 0x62, 0x49, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x77, 0x65,
|
||||
0x62, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72,
|
||||
0x6f, 0x78, 0x79, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x10, 0x72,
|
||||
0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4a, 0x53, 0x4f, 0x4e, 0x12,
|
||||
0x31, 0x0a, 0x0b, 0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x18, 0x1e,
|
||||
0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c,
|
||||
0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x0b, 0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74,
|
||||
0x65, 0x72, 0x12, 0x27, 0x0a, 0x06, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x18, 0x1f, 0x20, 0x03,
|
||||
0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x47, 0x72,
|
||||
0x6f, 0x75, 0x70, 0x52, 0x06, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x12, 0x1c, 0x0a, 0x04, 0x75,
|
||||
0x73, 0x65, 0x72, 0x18, 0x20, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x70, 0x62, 0x2e, 0x55,
|
||||
0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70,
|
||||
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x64, 0x65, 0x6c, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x27,
|
||||
0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d,
|
||||
0x65, 0x5f, 0x61, 0x75, 0x64, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c,
|
||||
0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb8, 0x06, 0x0a, 0x06, 0x53, 0x65, 0x72, 0x76,
|
||||
0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02,
|
||||
0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x18, 0x12, 0x20, 0x01, 0x28, 0x08,
|
||||
0x52, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61,
|
||||
0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20,
|
||||
0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x12, 0x22, 0x0a, 0x0c, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73,
|
||||
0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x4e,
|
||||
0x6f, 0x64, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x4e,
|
||||
0x6f, 0x64, 0x65, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x65, 0x78, 0x63, 0x6c,
|
||||
0x75, 0x64, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61,
|
||||
0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65,
|
||||
0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x6e, 0x73, 0x4e, 0x61, 0x6d,
|
||||
0x65, 0x18, 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x6e, 0x73, 0x4e, 0x61, 0x6d, 0x65,
|
||||
0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x11, 0x20, 0x01, 0x28, 0x0c,
|
||||
0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x28, 0x0a, 0x0f, 0x73, 0x65, 0x72, 0x76,
|
||||
0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x08, 0x20, 0x01, 0x28,
|
||||
0x0c, 0x52, 0x0f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x4a, 0x53,
|
||||
0x4f, 0x4e, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x73, 0x41, 0x75, 0x64, 0x69, 0x74, 0x69, 0x6e, 0x67,
|
||||
0x18, 0x14, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x41, 0x75, 0x64, 0x69, 0x74, 0x69,
|
||||
0x6e, 0x67, 0x12, 0x38, 0x0a, 0x17, 0x61, 0x75, 0x64, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x53, 0x65,
|
||||
0x72, 0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x15, 0x20,
|
||||
0x01, 0x28, 0x0c, 0x52, 0x17, 0x61, 0x75, 0x64, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72,
|
||||
0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x44, 0x0a, 0x0e,
|
||||
0x61, 0x75, 0x64, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x16,
|
||||
0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72,
|
||||
0x4e, 0x61, 0x6d, 0x65, 0x41, 0x75, 0x64, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x75,
|
||||
0x6c, 0x74, 0x52, 0x0e, 0x61, 0x75, 0x64, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x75,
|
||||
0x6c, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x68, 0x74, 0x74, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x09,
|
||||
0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x68, 0x74, 0x74, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x1c,
|
||||
0x0a, 0x09, 0x68, 0x74, 0x74, 0x70, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0a, 0x20, 0x01, 0x28,
|
||||
0x0c, 0x52, 0x09, 0x68, 0x74, 0x74, 0x70, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x18, 0x0a, 0x07,
|
||||
0x74, 0x63, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x74,
|
||||
0x63, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x6c, 0x73, 0x4a, 0x53, 0x4f,
|
||||
0x4e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x74, 0x6c, 0x73, 0x4a, 0x53, 0x4f, 0x4e,
|
||||
0x12, 0x1a, 0x0a, 0x08, 0x75, 0x6e, 0x69, 0x78, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0d, 0x20, 0x01,
|
||||
0x28, 0x0c, 0x52, 0x08, 0x75, 0x6e, 0x69, 0x78, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x18, 0x0a, 0x07,
|
||||
0x75, 0x64, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x75,
|
||||
0x64, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x14, 0x0a, 0x05, 0x77, 0x65, 0x62, 0x49, 0x64, 0x18,
|
||||
0x0f, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x77, 0x65, 0x62, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10,
|
||||
0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4a, 0x53, 0x4f, 0x4e,
|
||||
0x18, 0x10, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x10, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50,
|
||||
0x72, 0x6f, 0x78, 0x79, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x31, 0x0a, 0x0b, 0x6e, 0x6f, 0x64, 0x65,
|
||||
0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e,
|
||||
0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x0b,
|
||||
0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x06, 0x67,
|
||||
0x72, 0x6f, 0x75, 0x70, 0x73, 0x18, 0x1f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x62,
|
||||
0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x06, 0x67, 0x72,
|
||||
0x6f, 0x75, 0x70, 0x73, 0x12, 0x1c, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x20, 0x20, 0x01,
|
||||
0x28, 0x0b, 0x32, 0x08, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73,
|
||||
0x65, 0x72, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -310,19 +347,21 @@ func file_model_server_proto_rawDescGZIP() []byte {
|
||||
var file_model_server_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_model_server_proto_goTypes = []interface{}{
|
||||
(*Server)(nil), // 0: pb.Server
|
||||
(*NodeCluster)(nil), // 1: pb.NodeCluster
|
||||
(*ServerGroup)(nil), // 2: pb.ServerGroup
|
||||
(*User)(nil), // 3: pb.User
|
||||
(*ServerNameAuditingResult)(nil), // 1: pb.ServerNameAuditingResult
|
||||
(*NodeCluster)(nil), // 2: pb.NodeCluster
|
||||
(*ServerGroup)(nil), // 3: pb.ServerGroup
|
||||
(*User)(nil), // 4: pb.User
|
||||
}
|
||||
var file_model_server_proto_depIdxs = []int32{
|
||||
1, // 0: pb.Server.nodeCluster:type_name -> pb.NodeCluster
|
||||
2, // 1: pb.Server.groups:type_name -> pb.ServerGroup
|
||||
3, // 2: pb.Server.user:type_name -> pb.User
|
||||
3, // [3:3] is the sub-list for method output_type
|
||||
3, // [3:3] is the sub-list for method input_type
|
||||
3, // [3:3] is the sub-list for extension type_name
|
||||
3, // [3:3] is the sub-list for extension extendee
|
||||
0, // [0:3] is the sub-list for field type_name
|
||||
1, // 0: pb.Server.auditingResult:type_name -> pb.ServerNameAuditingResult
|
||||
2, // 1: pb.Server.nodeCluster:type_name -> pb.NodeCluster
|
||||
3, // 2: pb.Server.groups:type_name -> pb.ServerGroup
|
||||
4, // 3: pb.Server.user:type_name -> pb.User
|
||||
4, // [4:4] is the sub-list for method output_type
|
||||
4, // [4:4] is the sub-list for method input_type
|
||||
4, // [4:4] is the sub-list for extension type_name
|
||||
4, // [4:4] is the sub-list for extension extendee
|
||||
0, // [0:4] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_model_server_proto_init() }
|
||||
@@ -333,6 +372,7 @@ func file_model_server_proto_init() {
|
||||
file_model_node_cluster_proto_init()
|
||||
file_model_server_group_proto_init()
|
||||
file_model_user_proto_init()
|
||||
file_model_server_name_auditing_result_proto_init()
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_model_server_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Server); i {
|
||||
|
||||
168
pkg/rpc/pb/model_server_name_auditing_result.pb.go
Normal file
168
pkg/rpc/pb/model_server_name_auditing_result.pb.go
Normal file
@@ -0,0 +1,168 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.25.0
|
||||
// protoc v3.12.3
|
||||
// source: model_server_name_auditing_result.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
||||
// of the legacy proto package is being used.
|
||||
const _ = proto.ProtoPackageIsVersion4
|
||||
|
||||
type ServerNameAuditingResult struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
IsOk bool `protobuf:"varint,1,opt,name=isOk,proto3" json:"isOk,omitempty"`
|
||||
Reason string `protobuf:"bytes,2,opt,name=reason,proto3" json:"reason,omitempty"`
|
||||
CreatedAt int64 `protobuf:"varint,3,opt,name=createdAt,proto3" json:"createdAt,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ServerNameAuditingResult) Reset() {
|
||||
*x = ServerNameAuditingResult{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_model_server_name_auditing_result_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ServerNameAuditingResult) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ServerNameAuditingResult) ProtoMessage() {}
|
||||
|
||||
func (x *ServerNameAuditingResult) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_model_server_name_auditing_result_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ServerNameAuditingResult.ProtoReflect.Descriptor instead.
|
||||
func (*ServerNameAuditingResult) Descriptor() ([]byte, []int) {
|
||||
return file_model_server_name_auditing_result_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *ServerNameAuditingResult) GetIsOk() bool {
|
||||
if x != nil {
|
||||
return x.IsOk
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *ServerNameAuditingResult) GetReason() string {
|
||||
if x != nil {
|
||||
return x.Reason
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ServerNameAuditingResult) GetCreatedAt() int64 {
|
||||
if x != nil {
|
||||
return x.CreatedAt
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_model_server_name_auditing_result_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_model_server_name_auditing_result_proto_rawDesc = []byte{
|
||||
0x0a, 0x27, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x6e,
|
||||
0x61, 0x6d, 0x65, 0x5f, 0x61, 0x75, 0x64, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x65, 0x73,
|
||||
0x75, 0x6c, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0x64, 0x0a,
|
||||
0x18, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x41, 0x75, 0x64, 0x69, 0x74,
|
||||
0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x73, 0x4f,
|
||||
0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6b, 0x12, 0x16, 0x0a,
|
||||
0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72,
|
||||
0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64,
|
||||
0x41, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65,
|
||||
0x64, 0x41, 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_model_server_name_auditing_result_proto_rawDescOnce sync.Once
|
||||
file_model_server_name_auditing_result_proto_rawDescData = file_model_server_name_auditing_result_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_model_server_name_auditing_result_proto_rawDescGZIP() []byte {
|
||||
file_model_server_name_auditing_result_proto_rawDescOnce.Do(func() {
|
||||
file_model_server_name_auditing_result_proto_rawDescData = protoimpl.X.CompressGZIP(file_model_server_name_auditing_result_proto_rawDescData)
|
||||
})
|
||||
return file_model_server_name_auditing_result_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_model_server_name_auditing_result_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_model_server_name_auditing_result_proto_goTypes = []interface{}{
|
||||
(*ServerNameAuditingResult)(nil), // 0: pb.ServerNameAuditingResult
|
||||
}
|
||||
var file_model_server_name_auditing_result_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_model_server_name_auditing_result_proto_init() }
|
||||
func file_model_server_name_auditing_result_proto_init() {
|
||||
if File_model_server_name_auditing_result_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_model_server_name_auditing_result_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ServerNameAuditingResult); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_model_server_name_auditing_result_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_model_server_name_auditing_result_proto_goTypes,
|
||||
DependencyIndexes: file_model_server_name_auditing_result_proto_depIdxs,
|
||||
MessageInfos: file_model_server_name_auditing_result_proto_msgTypes,
|
||||
}.Build()
|
||||
File_model_server_name_auditing_result_proto = out.File
|
||||
file_model_server_name_auditing_result_proto_rawDesc = nil
|
||||
file_model_server_name_auditing_result_proto_goTypes = nil
|
||||
file_model_server_name_auditing_result_proto_depIdxs = nil
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,7 @@ package pb;
|
||||
import "model_node_cluster.proto";
|
||||
import "model_server_group.proto";
|
||||
import "model_user.proto";
|
||||
import "model_server_name_auditing_result.proto";
|
||||
|
||||
message Server {
|
||||
int64 id = 1;
|
||||
@@ -21,6 +22,10 @@ message Server {
|
||||
// 配置相关
|
||||
bytes config = 17;
|
||||
bytes serverNamesJSON = 8;
|
||||
bool isAuditing = 20;
|
||||
bytes auditingServerNamesJSON = 21;
|
||||
ServerNameAuditingResult auditingResult = 22;
|
||||
|
||||
bytes httpJSON = 9;
|
||||
bytes httpsJSON = 10;
|
||||
bytes tcpJSON = 11;
|
||||
|
||||
10
pkg/rpc/protos/model_server_name_auditing_result.proto
Normal file
10
pkg/rpc/protos/model_server_name_auditing_result.proto
Normal file
@@ -0,0 +1,10 @@
|
||||
syntax = "proto3";
|
||||
option go_package = "./pb";
|
||||
|
||||
package pb;
|
||||
|
||||
message ServerNameAuditingResult {
|
||||
bool isOk = 1;
|
||||
string reason = 2;
|
||||
int64 createdAt = 3;
|
||||
}
|
||||
@@ -5,6 +5,7 @@ package pb;
|
||||
|
||||
import "model_server.proto";
|
||||
import "model_dns_domain.proto";
|
||||
import "model_server_name_auditing_result.proto";
|
||||
import "rpc_messages.proto";
|
||||
|
||||
service ServerService {
|
||||
@@ -14,6 +15,9 @@ service ServerService {
|
||||
// 修改服务基本信息
|
||||
rpc updateServerBasic (UpdateServerBasicRequest) returns (RPCSuccess);
|
||||
|
||||
// 修改服务是否启用
|
||||
rpc updateServerIsOn (UpdateServerIsOnRequest) returns (RPCSuccess);
|
||||
|
||||
// 修改服务的HTTP设置
|
||||
rpc updateServerHTTP (UpdateServerHTTPRequest) returns (RPCSuccess);
|
||||
|
||||
@@ -44,6 +48,9 @@ service ServerService {
|
||||
// 修改服务的域名设置
|
||||
rpc updateServerNames (UpdateServerNamesRequest) returns (RPCSuccess);
|
||||
|
||||
// 审核服务的域名设置
|
||||
rpc updateServerNamesAuditing (UpdateServerNamesAuditingRequest) returns (RPCSuccess);
|
||||
|
||||
// 计算匹配的服务数量
|
||||
rpc countAllEnabledServersMatch (CountAllEnabledServersMatchRequest) returns (RPCCountResponse);
|
||||
|
||||
@@ -51,11 +58,14 @@ service ServerService {
|
||||
rpc listEnabledServersMatch (ListEnabledServersMatchRequest) returns (ListEnabledServersMatchResponse);
|
||||
|
||||
// 禁用某服务
|
||||
rpc disableServer (DisableServerRequest) returns (DisableServerResponse);
|
||||
rpc deleteServer (DeleteServerRequest) returns (RPCSuccess);
|
||||
|
||||
// 查找单个服务
|
||||
rpc findEnabledServer (FindEnabledServerRequest) returns (FindEnabledServerResponse);
|
||||
|
||||
// 查找服务配置
|
||||
rpc findEnabledServerConfig (FindEnabledServerConfigRequest) returns (FindEnabledServerConfigResponse);
|
||||
|
||||
// 查找服务的服务类型
|
||||
rpc findEnabledServerType (FindEnabledServerTypeRequest) returns (FindEnabledServerTypeResponse);
|
||||
|
||||
@@ -85,6 +95,9 @@ service ServerService {
|
||||
|
||||
// 查找单个服务的DNS信息
|
||||
rpc findEnabledServerDNS (FindEnabledServerDNSRequest) returns (FindEnabledServerDNSResponse);
|
||||
|
||||
// 检查服务是否属于某个用户
|
||||
rpc checkUserServer (CheckUserServerRequest) returns (RPCSuccess);
|
||||
}
|
||||
|
||||
// 创建服务
|
||||
@@ -126,35 +139,41 @@ message UpdateServerBasicRequest {
|
||||
repeated int64 groupIds = 6;
|
||||
}
|
||||
|
||||
// 修改服务启是否启用
|
||||
message UpdateServerIsOnRequest {
|
||||
int64 serverId = 1;
|
||||
bool isOn = 2;
|
||||
}
|
||||
|
||||
// 修改服务的HTTP等设置
|
||||
message UpdateServerHTTPRequest {
|
||||
int64 serverId = 1;
|
||||
bytes config = 2;
|
||||
bytes httpJSON = 2;
|
||||
}
|
||||
|
||||
message UpdateServerHTTPSRequest {
|
||||
int64 serverId = 1;
|
||||
bytes config = 2;
|
||||
bytes httpsJSON = 2;
|
||||
}
|
||||
|
||||
message UpdateServerTCPRequest {
|
||||
int64 serverId = 1;
|
||||
bytes config = 2;
|
||||
bytes tcpJSON = 2;
|
||||
}
|
||||
|
||||
message UpdateServerTLSRequest {
|
||||
int64 serverId = 1;
|
||||
bytes config = 2;
|
||||
bytes tlsJSON = 2;
|
||||
}
|
||||
|
||||
message UpdateServerUnixRequest {
|
||||
int64 serverId = 1;
|
||||
bytes config = 2;
|
||||
bytes unixJSON = 2;
|
||||
}
|
||||
|
||||
message UpdateServerUDPRequest {
|
||||
int64 serverId = 1;
|
||||
bytes config = 2;
|
||||
bytes udpJSON = 2;
|
||||
}
|
||||
|
||||
message UpdateServerWebRequest {
|
||||
@@ -174,12 +193,21 @@ message FindServerNamesRequest {
|
||||
|
||||
message FindServerNamesResponse {
|
||||
bytes serverNamesJSON = 1;
|
||||
bool isAuditing = 2;
|
||||
bytes auditingServerNamesJSON = 3;
|
||||
ServerNameAuditingResult auditingResult = 4;
|
||||
}
|
||||
|
||||
// 修改服务的域名设置
|
||||
message UpdateServerNamesRequest {
|
||||
int64 serverId = 1;
|
||||
bytes config = 2;
|
||||
bytes serverNamesJSON = 2;
|
||||
}
|
||||
|
||||
// 审核服务的域名设置
|
||||
message UpdateServerNamesAuditingRequest {
|
||||
int64 serverId = 1;
|
||||
ServerNameAuditingResult auditingResult = 2;
|
||||
}
|
||||
|
||||
// 计算服务数量
|
||||
@@ -187,6 +215,8 @@ message CountAllEnabledServersMatchRequest {
|
||||
int64 groupId = 1;
|
||||
string keyword = 2;
|
||||
int64 userId = 3;
|
||||
int64 clusterId = 4;
|
||||
int32 auditingFlag = 5;
|
||||
}
|
||||
|
||||
// 列出单页服务
|
||||
@@ -196,6 +226,8 @@ message ListEnabledServersMatchRequest {
|
||||
int64 groupId = 3;
|
||||
string keyword = 4;
|
||||
int64 userId = 5;
|
||||
int64 clusterId = 6;
|
||||
int32 auditingFlag = 7;
|
||||
}
|
||||
|
||||
message ListEnabledServersMatchResponse {
|
||||
@@ -203,14 +235,10 @@ message ListEnabledServersMatchResponse {
|
||||
}
|
||||
|
||||
// 禁用服务
|
||||
message DisableServerRequest {
|
||||
message DeleteServerRequest {
|
||||
int64 serverId = 1;
|
||||
}
|
||||
|
||||
message DisableServerResponse {
|
||||
|
||||
}
|
||||
|
||||
// 查找单个服务
|
||||
message FindEnabledServerRequest {
|
||||
int64 serverId = 1;
|
||||
@@ -220,6 +248,15 @@ message FindEnabledServerResponse {
|
||||
Server server = 1;
|
||||
}
|
||||
|
||||
// 查找服务配置
|
||||
message FindEnabledServerConfigRequest {
|
||||
int64 serverId = 1;
|
||||
}
|
||||
|
||||
message FindEnabledServerConfigResponse {
|
||||
bytes serverJSON = 1;
|
||||
}
|
||||
|
||||
// 查找服务的服务类型
|
||||
message FindEnabledServerTypeRequest {
|
||||
int64 serverId = 1;
|
||||
@@ -305,3 +342,8 @@ message FindEnabledServerDNSResponse {
|
||||
string dnsName = 1;
|
||||
DNSDomain domain = 2;
|
||||
}
|
||||
|
||||
// 检查服务是否属于某个用户
|
||||
message CheckUserServerRequest {
|
||||
int64 serverId = 1;
|
||||
}
|
||||
@@ -2,6 +2,17 @@ package serverconfigs
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
func NewHTTPProtocolConfigFromJSON(configJSON []byte) (*HTTPProtocolConfig, error) {
|
||||
config := &HTTPProtocolConfig{}
|
||||
if len(configJSON) > 0 {
|
||||
err := json.Unmarshal(configJSON, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
|
||||
type HTTPProtocolConfig struct {
|
||||
BaseProtocol `yaml:",inline"`
|
||||
}
|
||||
|
||||
@@ -5,6 +5,17 @@ import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
|
||||
)
|
||||
|
||||
func NewHTTPSProtocolConfigFromJSON(configJSON []byte) (*HTTPSProtocolConfig, error) {
|
||||
config := &HTTPSProtocolConfig{}
|
||||
if len(configJSON) > 0 {
|
||||
err := json.Unmarshal(configJSON, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
|
||||
// HTTPS协议配置
|
||||
type HTTPSProtocolConfig struct {
|
||||
BaseProtocol `yaml:",inline"`
|
||||
|
||||
Reference in New Issue
Block a user