优化代码

This commit is contained in:
GoEdgeLab
2022-03-22 19:30:30 +08:00
parent 31599bee13
commit 2b0e2b6888
90 changed files with 294 additions and 294 deletions

View File

@@ -92,7 +92,7 @@ func (this *StorageManager) Loop() error {
}
if len(policy.Options) > 0 {
err = json.Unmarshal([]byte(policy.Options), storage.Config())
err = json.Unmarshal(policy.Options, storage.Config())
if err != nil {
remotelogs.Error("ACCESS_LOG_STORAGE_MANAGER", "unmarshal policy '"+types.String(policyId)+"' config failed: "+err.Error())
storage.SetOk(false)
@@ -110,7 +110,7 @@ func (this *StorageManager) Loop() error {
remotelogs.Println("ACCESS_LOG_STORAGE_MANAGER", "restart policy '"+types.String(policyId)+"'")
}
} else {
storage, err := this.createStorage(policy.Type, []byte(policy.Options))
storage, err := this.createStorage(policy.Type, policy.Options)
if err != nil {
remotelogs.Error("ACCESS_LOG_STORAGE_MANAGER", "create policy '"+types.String(policyId)+"' failed: "+err.Error())
continue

View File

@@ -330,7 +330,7 @@ func (this *ACMETaskDAO) runTaskWithoutLog(tx *dbs.Tx, taskId int64) (isOk bool,
})
if len(user.Registration) > 0 {
err = remoteUser.SetRegistration([]byte(user.Registration))
err = remoteUser.SetRegistration(user.Registration)
if err != nil {
errMsg = "设置注册信息时出错:" + err.Error()
return

View File

@@ -13,7 +13,7 @@ func (this *APINode) DecodeHTTP() (*serverconfigs.HTTPProtocolConfig, error) {
return nil, nil
}
config := &serverconfigs.HTTPProtocolConfig{}
err := json.Unmarshal([]byte(this.Http), config)
err := json.Unmarshal(this.Http, config)
if err != nil {
return nil, err
}
@@ -32,7 +32,7 @@ func (this *APINode) DecodeHTTPS(tx *dbs.Tx, cacheMap *utils.CacheMap) (*serverc
return nil, nil
}
config := &serverconfigs.HTTPSProtocolConfig{}
err := json.Unmarshal([]byte(this.Https), config)
err := json.Unmarshal(this.Https, config)
if err != nil {
return nil, err
}
@@ -70,7 +70,7 @@ func (this *APINode) DecodeAccessAddrs() ([]*serverconfigs.NetworkAddressConfig,
}
addrConfigs := []*serverconfigs.NetworkAddressConfig{}
err := json.Unmarshal([]byte(this.AccessAddrs), &addrConfigs)
err := json.Unmarshal(this.AccessAddrs, &addrConfigs)
if err != nil {
return nil, err
}
@@ -105,7 +105,7 @@ func (this *APINode) DecodeRestHTTP() (*serverconfigs.HTTPProtocolConfig, error)
return nil, nil
}
config := &serverconfigs.HTTPProtocolConfig{}
err := json.Unmarshal([]byte(this.RestHTTP), config)
err := json.Unmarshal(this.RestHTTP, config)
if err != nil {
return nil, err
}
@@ -130,7 +130,7 @@ func (this *APINode) DecodeRestHTTPS(tx *dbs.Tx, cacheMap *utils.CacheMap) (*ser
return nil, nil
}
config := &serverconfigs.HTTPSProtocolConfig{}
err := json.Unmarshal([]byte(this.RestHTTPS), config)
err := json.Unmarshal(this.RestHTTPS, config)
if err != nil {
return nil, err
}

View File

@@ -39,7 +39,7 @@ func (this *DNSDomain) DecodeRecords() ([]*dnstypes.Record, error) {
return nil, nil
}
result := []*dnstypes.Record{}
err := json.Unmarshal([]byte(records), &result)
err := json.Unmarshal(records, &result)
if err != nil {
return nil, err
}

View File

@@ -11,6 +11,6 @@ func (this *DNSProvider) DecodeAPIParams() (maps.Map, error) {
return maps.Map{}, nil
}
result := maps.Map{}
err := json.Unmarshal([]byte(this.ApiParams), &result)
err := json.Unmarshal(this.ApiParams, &result)
return result, err
}

View File

@@ -8,11 +8,11 @@ import (
// ToPB 转换成PB对象
func (this *HTTPAccessLog) ToPB() (*pb.HTTPAccessLog, error) {
p := &pb.HTTPAccessLog{}
err := json.Unmarshal([]byte(this.Content), p)
err := json.Unmarshal(this.Content, p)
if err != nil {
return nil, err
}
p.RequestId = this.RequestId
p.RequestBody = []byte(this.RequestBody)
p.RequestBody = this.RequestBody
return p, nil
}

View File

@@ -161,7 +161,7 @@ func (this *HTTPAccessLogPolicyDAO) UpdatePolicy(tx *dbs.Tx, policyId int64, nam
op.Version = dbs.SQL("version+1")
} else {
var m1 = maps.Map{}
_ = json.Unmarshal([]byte(oldPolicy.Options), &m1)
_ = json.Unmarshal(oldPolicy.Options, &m1)
var m2 = maps.Map{}
_ = json.Unmarshal(optionsJSON, &m2)

View File

@@ -122,7 +122,7 @@ func (this *HTTPAuthPolicyDAO) ComposePolicyConfig(tx *dbs.Tx, policyId int64, c
var params map[string]interface{}
if IsNotNull(policy.Params) {
err = json.Unmarshal([]byte(policy.Params), &params)
err = json.Unmarshal(policy.Params, &params)
if err != nil {
return nil, err
}

View File

@@ -83,7 +83,7 @@ func (this *HTTPBrotliPolicyDAO) ComposeBrotliConfig(tx *dbs.Tx, policyId int64)
config.IsOn = policy.IsOn == 1
if IsNotNull(policy.MinLength) {
minLengthConfig := &shared.SizeCapacity{}
err = json.Unmarshal([]byte(policy.MinLength), minLengthConfig)
err = json.Unmarshal(policy.MinLength, minLengthConfig)
if err != nil {
return nil, err
}
@@ -91,7 +91,7 @@ func (this *HTTPBrotliPolicyDAO) ComposeBrotliConfig(tx *dbs.Tx, policyId int64)
}
if IsNotNull(policy.MaxLength) {
maxLengthConfig := &shared.SizeCapacity{}
err = json.Unmarshal([]byte(policy.MaxLength), maxLengthConfig)
err = json.Unmarshal(policy.MaxLength, maxLengthConfig)
if err != nil {
return nil, err
}
@@ -101,7 +101,7 @@ func (this *HTTPBrotliPolicyDAO) ComposeBrotliConfig(tx *dbs.Tx, policyId int64)
if IsNotNull(policy.Conds) {
condsConfig := &shared.HTTPRequestCondsConfig{}
err = json.Unmarshal([]byte(policy.Conds), condsConfig)
err = json.Unmarshal(policy.Conds, condsConfig)
if err != nil {
return nil, err
}

View File

@@ -260,7 +260,7 @@ func (this *HTTPCachePolicyDAO) ComposeCachePolicy(tx *dbs.Tx, policyId int64, c
// capacity
if IsNotNull(policy.Capacity) {
capacityConfig := &shared.SizeCapacity{}
err = json.Unmarshal([]byte(policy.Capacity), capacityConfig)
err = json.Unmarshal(policy.Capacity, capacityConfig)
if err != nil {
return nil, err
}
@@ -272,7 +272,7 @@ func (this *HTTPCachePolicyDAO) ComposeCachePolicy(tx *dbs.Tx, policyId int64, c
// max size
if IsNotNull(policy.MaxSize) {
maxSizeConfig := &shared.SizeCapacity{}
err = json.Unmarshal([]byte(policy.MaxSize), maxSizeConfig)
err = json.Unmarshal(policy.MaxSize, maxSizeConfig)
if err != nil {
return nil, err
}
@@ -284,7 +284,7 @@ func (this *HTTPCachePolicyDAO) ComposeCachePolicy(tx *dbs.Tx, policyId int64, c
// options
if IsNotNull(policy.Options) {
m := map[string]interface{}{}
err = json.Unmarshal([]byte(policy.Options), &m)
err = json.Unmarshal(policy.Options, &m)
if err != nil {
return nil, errors.Wrap(err)
}
@@ -294,7 +294,7 @@ func (this *HTTPCachePolicyDAO) ComposeCachePolicy(tx *dbs.Tx, policyId int64, c
// refs
if IsNotNull(policy.Refs) {
refs := []*serverconfigs.HTTPCacheRef{}
err = json.Unmarshal([]byte(policy.Refs), &refs)
err = json.Unmarshal(policy.Refs, &refs)
if err != nil {
return nil, err
}

View File

@@ -83,7 +83,7 @@ func (this *HTTPDeflatePolicyDAO) ComposeDeflateConfig(tx *dbs.Tx, policyId int6
config.IsOn = policy.IsOn == 1
if IsNotNull(policy.MinLength) {
minLengthConfig := &shared.SizeCapacity{}
err = json.Unmarshal([]byte(policy.MinLength), minLengthConfig)
err = json.Unmarshal(policy.MinLength, minLengthConfig)
if err != nil {
return nil, err
}
@@ -91,7 +91,7 @@ func (this *HTTPDeflatePolicyDAO) ComposeDeflateConfig(tx *dbs.Tx, policyId int6
}
if IsNotNull(policy.MaxLength) {
maxLengthConfig := &shared.SizeCapacity{}
err = json.Unmarshal([]byte(policy.MaxLength), maxLengthConfig)
err = json.Unmarshal(policy.MaxLength, maxLengthConfig)
if err != nil {
return nil, err
}
@@ -101,7 +101,7 @@ func (this *HTTPDeflatePolicyDAO) ComposeDeflateConfig(tx *dbs.Tx, policyId int6
if IsNotNull(policy.Conds) {
condsConfig := &shared.HTTPRequestCondsConfig{}
err = json.Unmarshal([]byte(policy.Conds), condsConfig)
err = json.Unmarshal(policy.Conds, condsConfig)
if err != nil {
return nil, err
}

View File

@@ -86,7 +86,7 @@ func (this *HTTPFastcgiDAO) ComposeFastcgiConfig(tx *dbs.Tx, fastcgiId int64) (*
if IsNotNull(fastcgi.Params) {
params := []*serverconfigs.HTTPFastcgiParam{}
err = json.Unmarshal([]byte(fastcgi.Params), &params)
err = json.Unmarshal(fastcgi.Params, &params)
if err != nil {
return nil, err
}
@@ -95,7 +95,7 @@ func (this *HTTPFastcgiDAO) ComposeFastcgiConfig(tx *dbs.Tx, fastcgiId int64) (*
if IsNotNull(fastcgi.ReadTimeout) {
duration := &shared.TimeDuration{}
err = json.Unmarshal([]byte(fastcgi.ReadTimeout), duration)
err = json.Unmarshal(fastcgi.ReadTimeout, duration)
if err != nil {
return nil, err
}
@@ -104,7 +104,7 @@ func (this *HTTPFastcgiDAO) ComposeFastcgiConfig(tx *dbs.Tx, fastcgiId int64) (*
if IsNotNull(fastcgi.ConnTimeout) {
duration := &shared.TimeDuration{}
err = json.Unmarshal([]byte(fastcgi.ConnTimeout), duration)
err = json.Unmarshal(fastcgi.ConnTimeout, duration)
if err != nil {
return nil, err
}

View File

@@ -379,7 +379,7 @@ func (this *HTTPFirewallPolicyDAO) ComposeFirewallPolicy(tx *dbs.Tx, policyId in
// Inbound
inbound := &firewallconfigs.HTTPFirewallInboundConfig{}
if IsNotNull(policy.Inbound) {
err = json.Unmarshal([]byte(policy.Inbound), inbound)
err = json.Unmarshal(policy.Inbound, inbound)
if err != nil {
return nil, err
}
@@ -407,7 +407,7 @@ func (this *HTTPFirewallPolicyDAO) ComposeFirewallPolicy(tx *dbs.Tx, policyId in
// Outbound
outbound := &firewallconfigs.HTTPFirewallOutboundConfig{}
if IsNotNull(policy.Outbound) {
err = json.Unmarshal([]byte(policy.Outbound), outbound)
err = json.Unmarshal(policy.Outbound, outbound)
if err != nil {
return nil, err
}
@@ -435,7 +435,7 @@ func (this *HTTPFirewallPolicyDAO) ComposeFirewallPolicy(tx *dbs.Tx, policyId in
// Block动作配置
if IsNotNull(policy.BlockOptions) {
blockAction := &firewallconfigs.HTTPFirewallBlockAction{}
err = json.Unmarshal([]byte(policy.BlockOptions), blockAction)
err = json.Unmarshal(policy.BlockOptions, blockAction)
if err != nil {
return config, err
}
@@ -443,9 +443,9 @@ func (this *HTTPFirewallPolicyDAO) ComposeFirewallPolicy(tx *dbs.Tx, policyId in
}
// syn flood
if len(policy.SynFlood) > 0 {
if IsNotNull(policy.SynFlood) {
var synFloodConfig = &firewallconfigs.SYNFloodConfig{}
err = json.Unmarshal([]byte(policy.SynFlood), synFloodConfig)
err = json.Unmarshal(policy.SynFlood, synFloodConfig)
if err != nil {
return nil, err
}

View File

@@ -35,12 +35,12 @@ func init() {
})
}
// 初始化
// Init 初始化
func (this *HTTPFirewallRuleDAO) Init() {
_ = this.DAOObject.Init()
}
// 启用条目
// EnableHTTPFirewallRule 启用条目
func (this *HTTPFirewallRuleDAO) EnableHTTPFirewallRule(tx *dbs.Tx, id int64) error {
_, err := this.Query(tx).
Pk(id).
@@ -49,7 +49,7 @@ func (this *HTTPFirewallRuleDAO) EnableHTTPFirewallRule(tx *dbs.Tx, id int64) er
return err
}
// 禁用条目
// DisableHTTPFirewallRule 禁用条目
func (this *HTTPFirewallRuleDAO) DisableHTTPFirewallRule(tx *dbs.Tx, ruleId int64) error {
_, err := this.Query(tx).
Pk(ruleId).
@@ -61,7 +61,7 @@ func (this *HTTPFirewallRuleDAO) DisableHTTPFirewallRule(tx *dbs.Tx, ruleId int6
return this.NotifyUpdate(tx, ruleId)
}
// 查找启用中的条目
// FindEnabledHTTPFirewallRule 查找启用中的条目
func (this *HTTPFirewallRuleDAO) FindEnabledHTTPFirewallRule(tx *dbs.Tx, id int64) (*HTTPFirewallRule, error) {
result, err := this.Query(tx).
Pk(id).
@@ -73,7 +73,7 @@ func (this *HTTPFirewallRuleDAO) FindEnabledHTTPFirewallRule(tx *dbs.Tx, id int6
return result.(*HTTPFirewallRule), err
}
// 组合配置
// ComposeFirewallRule 组合配置
func (this *HTTPFirewallRuleDAO) ComposeFirewallRule(tx *dbs.Tx, ruleId int64) (*firewallconfigs.HTTPFirewallRule, error) {
rule, err := this.FindEnabledHTTPFirewallRule(tx, ruleId)
if err != nil {
@@ -89,7 +89,7 @@ func (this *HTTPFirewallRuleDAO) ComposeFirewallRule(tx *dbs.Tx, ruleId int64) (
paramFilters := []*firewallconfigs.ParamFilter{}
if IsNotNull(rule.ParamFilters) {
err = json.Unmarshal([]byte(rule.ParamFilters), &paramFilters)
err = json.Unmarshal(rule.ParamFilters, &paramFilters)
if err != nil {
return nil, err
}
@@ -102,7 +102,7 @@ func (this *HTTPFirewallRuleDAO) ComposeFirewallRule(tx *dbs.Tx, ruleId int64) (
if IsNotNull(rule.CheckpointOptions) {
checkpointOptions := map[string]interface{}{}
err = json.Unmarshal([]byte(rule.CheckpointOptions), &checkpointOptions)
err = json.Unmarshal(rule.CheckpointOptions, &checkpointOptions)
if err != nil {
return nil, err
}
@@ -114,7 +114,7 @@ func (this *HTTPFirewallRuleDAO) ComposeFirewallRule(tx *dbs.Tx, ruleId int64) (
return config, nil
}
// 从配置中配置规则
// CreateOrUpdateRuleFromConfig 从配置中配置规则
func (this *HTTPFirewallRuleDAO) CreateOrUpdateRuleFromConfig(tx *dbs.Tx, ruleConfig *firewallconfigs.HTTPFirewallRule) (int64, error) {
op := NewHTTPFirewallRuleOperator()
op.Id = ruleConfig.Id
@@ -160,7 +160,7 @@ func (this *HTTPFirewallRuleDAO) CreateOrUpdateRuleFromConfig(tx *dbs.Tx, ruleCo
return types.Int64(op.Id), nil
}
// 通知更新
// NotifyUpdate 通知更新
func (this *HTTPFirewallRuleDAO) NotifyUpdate(tx *dbs.Tx, ruleId int64) error {
setId, err := SharedHTTPFirewallRuleSetDAO.FindEnabledRuleSetIdWithRuleId(tx, ruleId)
if err != nil {

View File

@@ -99,7 +99,7 @@ func (this *HTTPFirewallRuleGroupDAO) ComposeFirewallRuleGroup(tx *dbs.Tx, group
if IsNotNull(group.Sets) {
setRefs := []*firewallconfigs.HTTPFirewallRuleSetRef{}
err = json.Unmarshal([]byte(group.Sets), &setRefs)
err = json.Unmarshal(group.Sets, &setRefs)
if err != nil {
return nil, err
}

View File

@@ -103,7 +103,7 @@ func (this *HTTPFirewallRuleSetDAO) ComposeFirewallRuleSet(tx *dbs.Tx, setId int
if IsNotNull(set.Rules) {
ruleRefs := []*firewallconfigs.HTTPFirewallRuleRef{}
err = json.Unmarshal([]byte(set.Rules), &ruleRefs)
err = json.Unmarshal(set.Rules, &ruleRefs)
if err != nil {
return nil, err
}
@@ -121,7 +121,7 @@ func (this *HTTPFirewallRuleSetDAO) ComposeFirewallRuleSet(tx *dbs.Tx, setId int
var actionConfigs = []*firewallconfigs.HTTPFirewallActionConfig{}
if len(set.Actions) > 0 {
err = json.Unmarshal([]byte(set.Actions), &actionConfigs)
err = json.Unmarshal(set.Actions, &actionConfigs)
if err != nil {
return nil, err
}

View File

@@ -91,7 +91,7 @@ func (this *HTTPGzipDAO) ComposeGzipConfig(tx *dbs.Tx, gzipId int64) (*servercon
config.IsOn = gzip.IsOn == 1
if IsNotNull(gzip.MinLength) {
minLengthConfig := &shared.SizeCapacity{}
err = json.Unmarshal([]byte(gzip.MinLength), minLengthConfig)
err = json.Unmarshal(gzip.MinLength, minLengthConfig)
if err != nil {
return nil, err
}
@@ -99,7 +99,7 @@ func (this *HTTPGzipDAO) ComposeGzipConfig(tx *dbs.Tx, gzipId int64) (*servercon
}
if IsNotNull(gzip.MaxLength) {
maxLengthConfig := &shared.SizeCapacity{}
err = json.Unmarshal([]byte(gzip.MaxLength), maxLengthConfig)
err = json.Unmarshal(gzip.MaxLength, maxLengthConfig)
if err != nil {
return nil, err
}
@@ -109,7 +109,7 @@ func (this *HTTPGzipDAO) ComposeGzipConfig(tx *dbs.Tx, gzipId int64) (*servercon
if IsNotNull(gzip.Conds) {
condsConfig := &shared.HTTPRequestCondsConfig{}
err = json.Unmarshal([]byte(gzip.Conds), condsConfig)
err = json.Unmarshal(gzip.Conds, condsConfig)
if err != nil {
return nil, err
}

View File

@@ -5,22 +5,22 @@ import (
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
)
// 解析最小长度
// DecodeMinLength 解析最小长度
func (this *HTTPGzip) DecodeMinLength() (*shared.SizeCapacity, error) {
if len(this.MinLength) == 0 {
return nil, nil
}
capacity := &shared.SizeCapacity{}
err := json.Unmarshal([]byte(this.MinLength), capacity)
err := json.Unmarshal(this.MinLength, capacity)
return capacity, err
}
// 解析最大长度
// DecodeMaxLength 解析最大长度
func (this *HTTPGzip) DecodeMaxLength() (*shared.SizeCapacity, error) {
if len(this.MaxLength) == 0 {
return nil, nil
}
capacity := &shared.SizeCapacity{}
err := json.Unmarshal([]byte(this.MaxLength), capacity)
err := json.Unmarshal(this.MaxLength, capacity)
return capacity, err
}

View File

@@ -244,9 +244,9 @@ func (this *HTTPHeaderDAO) ComposeHeaderConfig(tx *dbs.Tx, headerId int64) (*sha
// replace
config.ShouldReplace = header.ShouldReplace == 1
if len(header.ReplaceValues) > 0 {
if IsNotNull(header.ReplaceValues) {
var values = []*shared.HTTPHeaderReplaceValue{}
err = json.Unmarshal([]byte(header.ReplaceValues), &values)
err = json.Unmarshal(header.ReplaceValues, &values)
if err != nil {
return nil, err
}
@@ -254,9 +254,9 @@ func (this *HTTPHeaderDAO) ComposeHeaderConfig(tx *dbs.Tx, headerId int64) (*sha
}
// status
if len(header.Status) > 0 {
if IsNotNull(header.Status) {
status := &shared.HTTPStatusConfig{}
err = json.Unmarshal([]byte(header.Status), status)
err = json.Unmarshal(header.Status, status)
if err != nil {
return nil, err
}
@@ -264,9 +264,9 @@ func (this *HTTPHeaderDAO) ComposeHeaderConfig(tx *dbs.Tx, headerId int64) (*sha
}
// methods
if len(header.Methods) > 0 {
if IsNotNull(header.Methods) {
var methods = []string{}
err = json.Unmarshal([]byte(header.Methods), &methods)
err = json.Unmarshal(header.Methods, &methods)
if err != nil {
return nil, err
}
@@ -274,9 +274,9 @@ func (this *HTTPHeaderDAO) ComposeHeaderConfig(tx *dbs.Tx, headerId int64) (*sha
}
// domains
if len(header.Domains) > 0 {
if IsNotNull(header.Domains) {
var domains = []string{}
err = json.Unmarshal([]byte(header.Domains), &domains)
err = json.Unmarshal(header.Domains, &domains)
if err != nil {
return nil, err
}

View File

@@ -187,9 +187,9 @@ func (this *HTTPHeaderPolicyDAO) ComposeHeaderPolicyConfig(tx *dbs.Tx, headerPol
config.IsOn = policy.IsOn == 1
// SetHeaders
if len(policy.SetHeaders) > 0 {
if IsNotNull(policy.SetHeaders) {
refs := []*shared.HTTPHeaderRef{}
err = json.Unmarshal([]byte(policy.SetHeaders), &refs)
err = json.Unmarshal(policy.SetHeaders, &refs)
if err != nil {
return nil, err
}
@@ -211,9 +211,9 @@ func (this *HTTPHeaderPolicyDAO) ComposeHeaderPolicyConfig(tx *dbs.Tx, headerPol
}
// Delete Headers
if len(policy.DeleteHeaders) > 0 {
if IsNotNull(policy.DeleteHeaders) {
headers := []string{}
err = json.Unmarshal([]byte(policy.DeleteHeaders), &headers)
err = json.Unmarshal(policy.DeleteHeaders, &headers)
if err != nil {
return nil, err
}

View File

@@ -166,7 +166,7 @@ func (this *HTTPPageDAO) ComposePageConfig(tx *dbs.Tx, pageId int64, cacheMap *u
if len(page.StatusList) > 0 {
statusList := []string{}
err = json.Unmarshal([]byte(page.StatusList), &statusList)
err = json.Unmarshal(page.StatusList, &statusList)
if err != nil {
return nil, err
}

View File

@@ -109,7 +109,7 @@ func (this *HTTPRewriteRuleDAO) ComposeRewriteRule(tx *dbs.Tx, rewriteRuleId int
// conds
if len(rule.Conds) > 0 {
conds := &shared.HTTPRequestCondsConfig{}
err = json.Unmarshal([]byte(rule.Conds), conds)
err = json.Unmarshal(rule.Conds, conds)
if err != nil {
return nil, err
}

View File

@@ -101,7 +101,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
// root
if IsNotNull(web.Root) {
rootConfig := &serverconfigs.HTTPRootConfig{}
err = json.Unmarshal([]byte(web.Root), rootConfig)
err = json.Unmarshal(web.Root, rootConfig)
if err != nil {
return nil, err
}
@@ -111,7 +111,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
// compression
if IsNotNull(web.Compression) {
compression := &serverconfigs.HTTPCompressionConfig{}
err = json.Unmarshal([]byte(web.Compression), compression)
err = json.Unmarshal(web.Compression, compression)
if err != nil {
return nil, err
}
@@ -148,7 +148,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
// charset
if IsNotNull(web.Charset) {
charsetConfig := &serverconfigs.HTTPCharsetConfig{}
err = json.Unmarshal([]byte(web.Charset), charsetConfig)
err = json.Unmarshal(web.Charset, charsetConfig)
if err != nil {
return nil, err
}
@@ -158,7 +158,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
// headers
if IsNotNull(web.RequestHeader) {
ref := &shared.HTTPHeaderPolicyRef{}
err = json.Unmarshal([]byte(web.RequestHeader), ref)
err = json.Unmarshal(web.RequestHeader, ref)
if err != nil {
return nil, err
}
@@ -177,7 +177,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
if IsNotNull(web.ResponseHeader) {
ref := &shared.HTTPHeaderPolicyRef{}
err = json.Unmarshal([]byte(web.ResponseHeader), ref)
err = json.Unmarshal(web.ResponseHeader, ref)
if err != nil {
return nil, err
}
@@ -197,7 +197,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
// shutdown
if IsNotNull(web.Shutdown) {
shutdownConfig := &serverconfigs.HTTPShutdownConfig{}
err = json.Unmarshal([]byte(web.Shutdown), shutdownConfig)
err = json.Unmarshal(web.Shutdown, shutdownConfig)
if err != nil {
return nil, err
}
@@ -207,7 +207,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
// pages
if IsNotNull(web.Pages) {
pages := []*serverconfigs.HTTPPageConfig{}
err = json.Unmarshal([]byte(web.Pages), &pages)
err = json.Unmarshal(web.Pages, &pages)
if err != nil {
return nil, err
}
@@ -226,7 +226,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
// 访问日志
if IsNotNull(web.AccessLog) {
accessLogConfig := &serverconfigs.HTTPAccessLogRef{}
err = json.Unmarshal([]byte(web.AccessLog), accessLogConfig)
err = json.Unmarshal(web.AccessLog, accessLogConfig)
if err != nil {
return nil, err
}
@@ -236,7 +236,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
// 统计配置
if IsNotNull(web.Stat) {
statRef := &serverconfigs.HTTPStatRef{}
err = json.Unmarshal([]byte(web.Stat), statRef)
err = json.Unmarshal(web.Stat, statRef)
if err != nil {
return nil, err
}
@@ -246,7 +246,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
// 缓存配置
if IsNotNull(web.Cache) {
cacheConfig := &serverconfigs.HTTPCacheConfig{}
err = json.Unmarshal([]byte(web.Cache), &cacheConfig)
err = json.Unmarshal(web.Cache, &cacheConfig)
if err != nil {
return nil, err
}
@@ -258,7 +258,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
// 防火墙配置
if IsNotNull(web.Firewall) {
firewallRef := &firewallconfigs.HTTPFirewallRef{}
err = json.Unmarshal([]byte(web.Firewall), firewallRef)
err = json.Unmarshal(web.Firewall, firewallRef)
if err != nil {
return nil, err
}
@@ -281,7 +281,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
// 路由规则
if IsNotNull(web.Locations) {
refs := []*serverconfigs.HTTPLocationRef{}
err = json.Unmarshal([]byte(web.Locations), &refs)
err = json.Unmarshal(web.Locations, &refs)
if err != nil {
return nil, err
}
@@ -299,7 +299,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
// 跳转
if IsNotNull(web.RedirectToHttps) {
redirectToHTTPSConfig := &serverconfigs.HTTPRedirectToHTTPSConfig{}
err = json.Unmarshal([]byte(web.RedirectToHttps), redirectToHTTPSConfig)
err = json.Unmarshal(web.RedirectToHttps, redirectToHTTPSConfig)
if err != nil {
return nil, err
}
@@ -309,7 +309,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
// Websocket
if IsNotNull(web.Websocket) {
ref := &serverconfigs.HTTPWebsocketRef{}
err = json.Unmarshal([]byte(web.Websocket), ref)
err = json.Unmarshal(web.Websocket, ref)
if err != nil {
return nil, err
}
@@ -328,7 +328,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
// 重写规则
if IsNotNull(web.RewriteRules) {
refs := []*serverconfigs.HTTPRewriteRef{}
err = json.Unmarshal([]byte(web.RewriteRules), &refs)
err = json.Unmarshal(web.RewriteRules, &refs)
if err != nil {
return nil, err
}
@@ -347,7 +347,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
// 主机跳转
if IsNotNull(web.HostRedirects) {
redirects := []*serverconfigs.HTTPHostRedirectConfig{}
err = json.Unmarshal([]byte(web.HostRedirects), &redirects)
err = json.Unmarshal(web.HostRedirects, &redirects)
if err != nil {
return nil, err
}
@@ -357,7 +357,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
// Fastcgi
if IsNotNull(web.Fastcgi) {
ref := &serverconfigs.HTTPFastcgiRef{}
err = json.Unmarshal([]byte(web.Fastcgi), ref)
err = json.Unmarshal(web.Fastcgi, ref)
if err != nil {
return nil, err
}
@@ -381,7 +381,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
// 认证
if IsNotNull(web.Auth) {
authConfig := &serverconfigs.HTTPAuthConfig{}
err = json.Unmarshal([]byte(web.Auth), authConfig)
err = json.Unmarshal(web.Auth, authConfig)
if err != nil {
return nil, err
}
@@ -402,7 +402,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
// WebP
if IsNotNull(web.Webp) {
var webpConfig = &serverconfigs.WebPImageConfig{}
err = json.Unmarshal([]byte(web.Webp), webpConfig)
err = json.Unmarshal(web.Webp, webpConfig)
if err != nil {
return nil, err
}
@@ -412,7 +412,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
// RemoteAddr
if IsNotNull(web.RemoteAddr) {
var remoteAddrConfig = &serverconfigs.HTTPRemoteAddrConfig{}
err = json.Unmarshal([]byte(web.RemoteAddr), remoteAddrConfig)
err = json.Unmarshal(web.RemoteAddr, remoteAddrConfig)
if err != nil {
return nil, err
}
@@ -426,7 +426,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
if len(web.RequestLimit) > 0 {
var requestLimitConfig = &serverconfigs.HTTPRequestLimitConfig{}
if len(web.RequestLimit) > 0 {
err = json.Unmarshal([]byte(web.RequestLimit), requestLimitConfig)
err = json.Unmarshal(web.RequestLimit, requestLimitConfig)
if err != nil {
return nil, err
}
@@ -438,7 +438,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
if len(web.RequestScripts) > 0 {
var requestScriptsConfig = &serverconfigs.HTTPRequestScriptsConfig{}
if len(web.RequestScripts) > 0 {
err = json.Unmarshal([]byte(web.RequestScripts), requestScriptsConfig)
err = json.Unmarshal(web.RequestScripts, requestScriptsConfig)
if err != nil {
return nil, err
}

View File

@@ -37,7 +37,7 @@ func init() {
})
}
// 启用条目
// EnableHTTPWebsocket 启用条目
func (this *HTTPWebsocketDAO) EnableHTTPWebsocket(tx *dbs.Tx, id int64) error {
_, err := this.Query(tx).
Pk(id).
@@ -46,7 +46,7 @@ func (this *HTTPWebsocketDAO) EnableHTTPWebsocket(tx *dbs.Tx, id int64) error {
return err
}
// 禁用条目
// DisableHTTPWebsocket 禁用条目
func (this *HTTPWebsocketDAO) DisableHTTPWebsocket(tx *dbs.Tx, websocketId int64) error {
_, err := this.Query(tx).
Pk(websocketId).
@@ -58,7 +58,7 @@ func (this *HTTPWebsocketDAO) DisableHTTPWebsocket(tx *dbs.Tx, websocketId int64
return this.NotifyUpdate(tx, websocketId)
}
// 查找启用中的条目
// FindEnabledHTTPWebsocket 查找启用中的条目
func (this *HTTPWebsocketDAO) FindEnabledHTTPWebsocket(tx *dbs.Tx, id int64) (*HTTPWebsocket, error) {
result, err := this.Query(tx).
Pk(id).
@@ -70,7 +70,7 @@ func (this *HTTPWebsocketDAO) FindEnabledHTTPWebsocket(tx *dbs.Tx, id int64) (*H
return result.(*HTTPWebsocket), err
}
// 组合配置
// ComposeWebsocketConfig 组合配置
func (this *HTTPWebsocketDAO) ComposeWebsocketConfig(tx *dbs.Tx, websocketId int64) (*serverconfigs.HTTPWebsocketConfig, error) {
websocket, err := this.FindEnabledHTTPWebsocket(tx, websocketId)
if err != nil {
@@ -86,7 +86,7 @@ func (this *HTTPWebsocketDAO) ComposeWebsocketConfig(tx *dbs.Tx, websocketId int
if IsNotNull(websocket.AllowedOrigins) {
origins := []string{}
err = json.Unmarshal([]byte(websocket.AllowedOrigins), &origins)
err = json.Unmarshal(websocket.AllowedOrigins, &origins)
if err != nil {
return nil, err
}
@@ -95,7 +95,7 @@ func (this *HTTPWebsocketDAO) ComposeWebsocketConfig(tx *dbs.Tx, websocketId int
if IsNotNull(websocket.HandshakeTimeout) {
duration := &shared.TimeDuration{}
err = json.Unmarshal([]byte(websocket.HandshakeTimeout), duration)
err = json.Unmarshal(websocket.HandshakeTimeout, duration)
if err != nil {
return nil, err
}
@@ -108,7 +108,7 @@ func (this *HTTPWebsocketDAO) ComposeWebsocketConfig(tx *dbs.Tx, websocketId int
return config, nil
}
// 创建Websocket配置
// CreateWebsocket 创建Websocket配置
func (this *HTTPWebsocketDAO) CreateWebsocket(tx *dbs.Tx, handshakeTimeoutJSON []byte, allowAllOrigins bool, allowedOrigins []string, requestSameOrigin bool, requestOrigin string) (websocketId int64, err error) {
op := NewHTTPWebsocketOperator()
op.IsOn = true
@@ -130,7 +130,7 @@ func (this *HTTPWebsocketDAO) CreateWebsocket(tx *dbs.Tx, handshakeTimeoutJSON [
return types.Int64(op.Id), err
}
// 修改Websocket配置
// UpdateWebsocket 修改Websocket配置
func (this *HTTPWebsocketDAO) UpdateWebsocket(tx *dbs.Tx, websocketId int64, handshakeTimeoutJSON []byte, allowAllOrigins bool, allowedOrigins []string, requestSameOrigin bool, requestOrigin string) error {
if websocketId <= 0 {
return errors.New("invalid websocketId")
@@ -159,7 +159,7 @@ func (this *HTTPWebsocketDAO) UpdateWebsocket(tx *dbs.Tx, websocketId int64, han
return this.NotifyUpdate(tx, websocketId)
}
// 通知更新
// NotifyUpdate 通知更新
func (this *HTTPWebsocketDAO) NotifyUpdate(tx *dbs.Tx, websocketId int64) error {
webId, err := SharedHTTPWebDAO.FindEnabledWebIdWithWebsocketId(tx, websocketId)
if err != nil {

View File

@@ -5,13 +5,13 @@ import (
"github.com/iwind/TeaGo/logs"
)
// 解析分组ID
// DecodeGroupIds 解析分组ID
func (this *MessageRecipient) DecodeGroupIds() []int64 {
if len(this.GroupIds) == 0 {
return []int64{}
}
result := []int64{}
err := json.Unmarshal([]byte(this.GroupIds), &result)
err := json.Unmarshal(this.GroupIds, &result)
if err != nil {
logs.Println("MessageRecipient.DecodeGroupIds(): " + err.Error())
// 不阻断执行

View File

@@ -8,7 +8,7 @@ func (this *MetricChart) DecodeIgnoredKeys() []string {
}
var result = []string{}
err := json.Unmarshal([]byte(this.IgnoredKeys), &result)
err := json.Unmarshal(this.IgnoredKeys, &result)
if err != nil {
// 这里忽略错误
return result

View File

@@ -8,7 +8,7 @@ import (
func (this *MetricItem) DecodeKeys() []string {
var result []string
if len(this.Keys) > 0 {
_ = json.Unmarshal([]byte(this.Keys), &result)
_ = json.Unmarshal(this.Keys, &result)
}
return result
}

View File

@@ -6,7 +6,7 @@ import "encoding/json"
func (this *MetricStat) DecodeKeys() []string {
var result []string
if len(this.Keys) > 0 {
_ = json.Unmarshal([]byte(this.Keys), &result)
_ = json.Unmarshal(this.Keys, &result)
}
return result
}

View File

@@ -8,11 +8,11 @@ import (
func (this *NSRecord) DecodeRouteIds() []string {
var routeIds = []string{}
if len(this.RouteIds) > 0 {
err := json.Unmarshal([]byte(this.RouteIds), &routeIds)
err := json.Unmarshal(this.RouteIds, &routeIds)
if err != nil {
// 检查是否有旧的数据
var oldRouteIds = []int64{}
err = json.Unmarshal([]byte(this.RouteIds), &oldRouteIds)
err = json.Unmarshal(this.RouteIds, &oldRouteIds)
if err != nil {
return []string{}
}

View File

@@ -5,11 +5,11 @@ import (
"github.com/iwind/TeaGo/maps"
)
// 解析参数
// DecodeParams 解析参数
func (this *NodeClusterFirewallAction) DecodeParams() (maps.Map, error) {
if IsNotNull(this.Params) {
params := maps.Map{}
err := json.Unmarshal([]byte(this.Params), &params)
err := json.Unmarshal(this.Params, &params)
if err != nil {
return nil, err
}

View File

@@ -15,7 +15,7 @@ func (this *NodeCluster) DecodeDNSConfig() (*dnsconfigs.ClusterDNSConfig, error)
}, nil
}
dnsConfig := &dnsconfigs.ClusterDNSConfig{}
err := json.Unmarshal([]byte(this.Dns), &dnsConfig)
err := json.Unmarshal(this.Dns, &dnsConfig)
if err != nil {
return nil, err
}

View File

@@ -685,7 +685,7 @@ func (this *NodeDAO) FindNodeInstallStatus(tx *dbs.Tx, nodeId int64) (*NodeInsta
}
status := &NodeInstallStatus{}
err = json.Unmarshal([]byte(installStatus), status)
err = json.Unmarshal(installStatus, status)
if err != nil {
return nil, err
}
@@ -853,7 +853,7 @@ func (this *NodeDAO) ComposeNodeConfig(tx *dbs.Tx, nodeId int64, cacheMap *utils
// 缓存最大容量设置
if len(node.MaxCacheDiskCapacity) > 0 {
capacity := &shared.SizeCapacity{}
err = json.Unmarshal([]byte(node.MaxCacheDiskCapacity), capacity)
err = json.Unmarshal(node.MaxCacheDiskCapacity, capacity)
if err != nil {
return nil, err
}
@@ -864,7 +864,7 @@ func (this *NodeDAO) ComposeNodeConfig(tx *dbs.Tx, nodeId int64, cacheMap *utils
if len(node.MaxCacheMemoryCapacity) > 0 {
capacity := &shared.SizeCapacity{}
err = json.Unmarshal([]byte(node.MaxCacheMemoryCapacity), capacity)
err = json.Unmarshal(node.MaxCacheMemoryCapacity, capacity)
if err != nil {
return nil, err
}

View File

@@ -10,7 +10,7 @@ import (
func (this *NodeIPAddress) DecodeConnectivity() *nodeconfigs.Connectivity {
var connectivity = &nodeconfigs.Connectivity{}
if len(this.Connectivity) > 0 {
err := json.Unmarshal([]byte(this.Connectivity), connectivity)
err := json.Unmarshal(this.Connectivity, connectivity)
if err != nil {
remotelogs.Error("NodeIPAddress.DecodeConnectivity", "decode failed: "+err.Error())
}

View File

@@ -11,7 +11,7 @@ func (this *NodeIPAddressThreshold) DecodeItems() (result []*nodeconfigs.IPAddre
return
}
err := json.Unmarshal([]byte(this.Items), &result)
err := json.Unmarshal(this.Items, &result)
if err != nil {
remotelogs.Error("NodeIPAddressThreshold", "decode items: "+err.Error())
}
@@ -23,7 +23,7 @@ func (this *NodeIPAddressThreshold) DecodeActions() (result []*nodeconfigs.IPAdd
return
}
err := json.Unmarshal([]byte(this.Actions), &result)
err := json.Unmarshal(this.Actions, &result)
if err != nil {
remotelogs.Error("NodeIPAddressThreshold", "decode actions: "+err.Error())
}

View File

@@ -16,7 +16,7 @@ func (this *NodeLogin) DecodeSSHParams() (*NodeLoginSSHParams, error) {
}
params := &NodeLoginSSHParams{}
err := json.Unmarshal([]byte(this.Params), params)
err := json.Unmarshal(this.Params, params)
if err != nil {
return nil, err
}

View File

@@ -13,7 +13,7 @@ func (this *Node) DecodeInstallStatus() (*NodeInstallStatus, error) {
return NewNodeInstallStatus(), nil
}
status := &NodeInstallStatus{}
err := json.Unmarshal([]byte(this.InstallStatus), status)
err := json.Unmarshal(this.InstallStatus, status)
if err != nil {
return NewNodeInstallStatus(), err
}
@@ -34,7 +34,7 @@ func (this *Node) DecodeStatus() (*nodeconfigs.NodeStatus, error) {
return nil, nil
}
status := &nodeconfigs.NodeStatus{}
err := json.Unmarshal([]byte(this.Status), status)
err := json.Unmarshal(this.Status, status)
if err != nil {
return nil, err
}
@@ -47,7 +47,7 @@ func (this *Node) DNSRouteCodes() map[int64][]string {
if len(this.DnsRoutes) == 0 {
return routes
}
err := json.Unmarshal([]byte(this.DnsRoutes), &routes)
err := json.Unmarshal(this.DnsRoutes, &routes)
if err != nil {
// 忽略错误
return routes
@@ -61,7 +61,7 @@ func (this *Node) DNSRouteCodesForDomainId(dnsDomainId int64) ([]string, error)
if len(this.DnsRoutes) == 0 {
return nil, nil
}
err := json.Unmarshal([]byte(this.DnsRoutes), &routes)
err := json.Unmarshal(this.DnsRoutes, &routes)
if err != nil {
return nil, err
}
@@ -78,7 +78,7 @@ func (this *Node) DNSRouteCodesForDomainId(dnsDomainId int64) ([]string, error)
func (this *Node) DecodeConnectedAPINodeIds() ([]int64, error) {
apiNodeIds := []int64{}
if IsNotNull(this.ConnectedAPINodes) {
err := json.Unmarshal([]byte(this.ConnectedAPINodes), &apiNodeIds)
err := json.Unmarshal(this.ConnectedAPINodes, &apiNodeIds)
if err != nil {
return nil, err
}
@@ -93,6 +93,6 @@ func (this *Node) DecodeSecondaryClusterIds() []int64 {
}
var result = []int64{}
// 不需要处理错误
_ = json.Unmarshal([]byte(this.SecondaryClusterIds), &result)
_ = json.Unmarshal(this.SecondaryClusterIds, &result)
return result
}

View File

@@ -8,7 +8,7 @@ func (this *NodeRegion) DecodePriceMap() map[int64]float64 {
return m
}
err := json.Unmarshal([]byte(this.Prices), &m)
err := json.Unmarshal(this.Prices, &m)
if err != nil {
// 忽略错误
return m

View File

@@ -225,7 +225,7 @@ func (this *NodeThresholdDAO) FireNodeThreshold(tx *dbs.Tx, role string, nodeId
if err != nil {
return err
}
originValue := nodeconfigs.UnmarshalNodeValue([]byte(threshold.Value))
originValue := nodeconfigs.UnmarshalNodeValue(threshold.Value)
thresholdValue := types.Float64(originValue)
isMatched := nodeconfigs.CompareNodeValue(threshold.Operator, paramValue, thresholdValue)
if isMatched {

View File

@@ -10,7 +10,7 @@ func (this *NodeValue) DecodeMapValue() maps.Map {
return maps.Map{}
}
var m = maps.Map{}
err := json.Unmarshal([]byte(this.Value), &m)
err := json.Unmarshal(this.Value, &m)
if err != nil {
// 忽略错误
return m

View File

@@ -8,7 +8,7 @@ import (
// ToPB 转换成PB对象
func (this *NSAccessLog) ToPB() (*pb.NSAccessLog, error) {
p := &pb.NSAccessLog{}
err := json.Unmarshal([]byte(this.Content), p)
err := json.Unmarshal(this.Content, p)
if err != nil {
return nil, err
}

View File

@@ -299,7 +299,7 @@ func (this *NSNodeDAO) FindNodeInstallStatus(tx *dbs.Tx, nodeId int64) (*NodeIns
}
status := &NodeInstallStatus{}
err = json.Unmarshal([]byte(installStatus), status)
err = json.Unmarshal(installStatus, status)
if err != nil {
return nil, err
}
@@ -407,7 +407,7 @@ func (this *NSNodeDAO) ComposeNodeConfig(tx *dbs.Tx, nodeId int64) (*dnsconfigs.
// 集群配置
if len(cluster.AccessLog) > 0 {
ref := &dnsconfigs.NSAccessLogRef{}
err = json.Unmarshal([]byte(cluster.AccessLog), ref)
err = json.Unmarshal(cluster.AccessLog, ref)
if err != nil {
return nil, err
}

View File

@@ -12,7 +12,7 @@ func (this *NSNode) DecodeInstallStatus() (*NodeInstallStatus, error) {
return NewNodeInstallStatus(), nil
}
status := &NodeInstallStatus{}
err := json.Unmarshal([]byte(this.InstallStatus), status)
err := json.Unmarshal(this.InstallStatus, status)
if err != nil {
return NewNodeInstallStatus(), err
}
@@ -33,7 +33,7 @@ func (this *NSNode) DecodeStatus() (*nodeconfigs.NodeStatus, error) {
return nil, nil
}
status := &nodeconfigs.NodeStatus{}
err := json.Unmarshal([]byte(this.Status), status)
err := json.Unmarshal(this.Status, status)
if err != nil {
return nil, err
}

View File

@@ -308,7 +308,7 @@ func (this *OriginDAO) ComposeOriginConfig(tx *dbs.Tx, originId int64, cacheMap
if IsNotNull(origin.Addr) {
addr := &serverconfigs.NetworkAddressConfig{}
err = json.Unmarshal([]byte(origin.Addr), addr)
err = json.Unmarshal(origin.Addr, addr)
if err != nil {
return nil, err
}
@@ -317,7 +317,7 @@ func (this *OriginDAO) ComposeOriginConfig(tx *dbs.Tx, originId int64, cacheMap
if IsNotNull(origin.ConnTimeout) {
connTimeout := &shared.TimeDuration{}
err = json.Unmarshal([]byte(origin.ConnTimeout), &connTimeout)
err = json.Unmarshal(origin.ConnTimeout, &connTimeout)
if err != nil {
return nil, err
}
@@ -326,7 +326,7 @@ func (this *OriginDAO) ComposeOriginConfig(tx *dbs.Tx, originId int64, cacheMap
if IsNotNull(origin.ReadTimeout) {
readTimeout := &shared.TimeDuration{}
err = json.Unmarshal([]byte(origin.ReadTimeout), &readTimeout)
err = json.Unmarshal(origin.ReadTimeout, &readTimeout)
if err != nil {
return nil, err
}
@@ -335,7 +335,7 @@ func (this *OriginDAO) ComposeOriginConfig(tx *dbs.Tx, originId int64, cacheMap
if IsNotNull(origin.IdleTimeout) {
idleTimeout := &shared.TimeDuration{}
err = json.Unmarshal([]byte(origin.IdleTimeout), &idleTimeout)
err = json.Unmarshal(origin.IdleTimeout, &idleTimeout)
if err != nil {
return nil, err
}
@@ -345,7 +345,7 @@ func (this *OriginDAO) ComposeOriginConfig(tx *dbs.Tx, originId int64, cacheMap
// headers
if IsNotNull(origin.HttpRequestHeader) {
ref := &shared.HTTPHeaderPolicyRef{}
err = json.Unmarshal([]byte(origin.HttpRequestHeader), ref)
err = json.Unmarshal(origin.HttpRequestHeader, ref)
if err != nil {
return nil, err
}
@@ -364,7 +364,7 @@ func (this *OriginDAO) ComposeOriginConfig(tx *dbs.Tx, originId int64, cacheMap
if IsNotNull(origin.HttpResponseHeader) {
ref := &shared.HTTPHeaderPolicyRef{}
err = json.Unmarshal([]byte(origin.HttpResponseHeader), ref)
err = json.Unmarshal(origin.HttpResponseHeader, ref)
if err != nil {
return nil, err
}
@@ -383,7 +383,7 @@ func (this *OriginDAO) ComposeOriginConfig(tx *dbs.Tx, originId int64, cacheMap
if IsNotNull(origin.HealthCheck) {
healthCheck := &serverconfigs.HealthCheckConfig{}
err = json.Unmarshal([]byte(origin.HealthCheck), healthCheck)
err = json.Unmarshal(origin.HealthCheck, healthCheck)
if err != nil {
return nil, err
}
@@ -392,7 +392,7 @@ func (this *OriginDAO) ComposeOriginConfig(tx *dbs.Tx, originId int64, cacheMap
if IsNotNull(origin.Cert) {
ref := &sslconfigs.SSLCertRef{}
err = json.Unmarshal([]byte(origin.Cert), ref)
err = json.Unmarshal(origin.Cert, ref)
if err != nil {
return nil, err
}

View File

@@ -13,7 +13,7 @@ func (this *Plan) DecodeTrafficPrice() *serverconfigs.PlanTrafficPriceConfig {
return config
}
err := json.Unmarshal([]byte(this.TrafficPrice), config)
err := json.Unmarshal(this.TrafficPrice, config)
if err != nil {
// 忽略错误
}
@@ -29,7 +29,7 @@ func (this *Plan) DecodeBandwidthPrice() *serverconfigs.PlanBandwidthPriceConfig
return config
}
err := json.Unmarshal([]byte(this.BandwidthPrice), config)
err := json.Unmarshal(this.BandwidthPrice, config)
if err != nil {
// 忽略错误
}

View File

@@ -10,7 +10,7 @@ func (this *RegionCity) DecodeCodes() []string {
return []string{}
}
result := []string{}
err := json.Unmarshal([]byte(this.Codes), &result)
err := json.Unmarshal(this.Codes, &result)
if err != nil {
logs.Error(err)
}

View File

@@ -10,7 +10,7 @@ func (this *RegionCountry) DecodeCodes() []string {
return []string{}
}
result := []string{}
err := json.Unmarshal([]byte(this.Codes), &result)
err := json.Unmarshal(this.Codes, &result)
if err != nil {
logs.Error(err)
}

View File

@@ -10,7 +10,7 @@ func (this *RegionProvider) DecodeCodes() []string {
return []string{}
}
result := []string{}
err := json.Unmarshal([]byte(this.Codes), &result)
err := json.Unmarshal(this.Codes, &result)
if err != nil {
logs.Error(err)
}

View File

@@ -10,7 +10,7 @@ func (this *RegionProvince) DecodeCodes() []string {
return []string{}
}
result := []string{}
err := json.Unmarshal([]byte(this.Codes), &result)
err := json.Unmarshal(this.Codes, &result)
if err != nil {
logs.Error(err)
}

View File

@@ -8,7 +8,7 @@ import (
func (this *ReportNode) DecodeAllowIPs() []string {
var result = []string{}
if len(this.AllowIPs) > 0 {
err := json.Unmarshal([]byte(this.AllowIPs), &result)
err := json.Unmarshal(this.AllowIPs, &result)
if err != nil {
remotelogs.Error("ReportNode.DecodeGroupIds", err.Error())
}
@@ -19,7 +19,7 @@ func (this *ReportNode) DecodeAllowIPs() []string {
func (this *ReportNode) DecodeGroupIds() []int64 {
var result = []int64{}
if len(this.GroupIds) > 0 {
err := json.Unmarshal([]byte(this.GroupIds), &result)
err := json.Unmarshal(this.GroupIds, &result)
if err != nil {
remotelogs.Error("ReportNode.DecodeGroupIds", err.Error())
}

View File

@@ -315,9 +315,9 @@ func (this *ServerGroupDAO) ComposeGroupConfig(tx *dbs.Tx, groupId int64, cacheM
IsOn: group.IsOn == 1,
}
if len(group.HttpReverseProxy) > 0 {
if IsNotNull(group.HttpReverseProxy) {
reverseProxyRef := &serverconfigs.ReverseProxyRef{}
err := json.Unmarshal([]byte(group.HttpReverseProxy), reverseProxyRef)
err := json.Unmarshal(group.HttpReverseProxy, reverseProxyRef)
if err != nil {
return nil, err
}
@@ -332,9 +332,9 @@ func (this *ServerGroupDAO) ComposeGroupConfig(tx *dbs.Tx, groupId int64, cacheM
}
}
if len(group.TcpReverseProxy) > 0 {
if IsNotNull(group.TcpReverseProxy) {
reverseProxyRef := &serverconfigs.ReverseProxyRef{}
err := json.Unmarshal([]byte(group.TcpReverseProxy), reverseProxyRef)
err := json.Unmarshal(group.TcpReverseProxy, reverseProxyRef)
if err != nil {
return nil, err
}
@@ -349,9 +349,9 @@ func (this *ServerGroupDAO) ComposeGroupConfig(tx *dbs.Tx, groupId int64, cacheM
}
}
if len(group.UdpReverseProxy) > 0 {
if IsNotNull(group.UdpReverseProxy) {
reverseProxyRef := &serverconfigs.ReverseProxyRef{}
err := json.Unmarshal([]byte(group.UdpReverseProxy), reverseProxyRef)
err := json.Unmarshal(group.UdpReverseProxy, reverseProxyRef)
if err != nil {
return nil, err
}

View File

@@ -8,7 +8,7 @@ func (this *SSLCert) DecodeDNSNames() []string {
}
var result = []string{}
var err = json.Unmarshal([]byte(this.DnsNames), &result)
var err = json.Unmarshal(this.DnsNames, &result)
if err != nil {
return nil
}
@@ -22,7 +22,7 @@ func (this *SSLCert) DecodeCommonNames() []string {
}
var result = []string{}
var err = json.Unmarshal([]byte(this.CommonNames), &result)
var err = json.Unmarshal(this.CommonNames, &result)
if err != nil {
return nil
}

View File

@@ -105,7 +105,7 @@ func (this *SSLPolicyDAO) ComposePolicyConfig(tx *dbs.Tx, policyId int64, cacheM
// certs
if IsNotNull(policy.Certs) {
refs := []*sslconfigs.SSLCertRef{}
err = json.Unmarshal([]byte(policy.Certs), &refs)
err = json.Unmarshal(policy.Certs, &refs)
if err != nil {
return nil, err
}
@@ -127,7 +127,7 @@ func (this *SSLPolicyDAO) ComposePolicyConfig(tx *dbs.Tx, policyId int64, cacheM
// client CA certs
if IsNotNull(policy.ClientCACerts) {
refs := []*sslconfigs.SSLCertRef{}
err = json.Unmarshal([]byte(policy.ClientCACerts), &refs)
err = json.Unmarshal(policy.ClientCACerts, &refs)
if err != nil {
return nil, err
}
@@ -150,7 +150,7 @@ func (this *SSLPolicyDAO) ComposePolicyConfig(tx *dbs.Tx, policyId int64, cacheM
config.CipherSuitesIsOn = policy.CipherSuitesIsOn == 1
if IsNotNull(policy.CipherSuites) {
cipherSuites := []string{}
err = json.Unmarshal([]byte(policy.CipherSuites), &cipherSuites)
err = json.Unmarshal(policy.CipherSuites, &cipherSuites)
if err != nil {
return nil, err
}
@@ -160,7 +160,7 @@ func (this *SSLPolicyDAO) ComposePolicyConfig(tx *dbs.Tx, policyId int64, cacheM
// hsts
if IsNotNull(policy.Hsts) {
hstsConfig := &sslconfigs.HSTSConfig{}
err = json.Unmarshal([]byte(policy.Hsts), hstsConfig)
err = json.Unmarshal(policy.Hsts, hstsConfig)
if err != nil {
return nil, err
}

View File

@@ -6,7 +6,7 @@ import (
"reflect"
)
// 解码事件
// DecodeEvent 解码事件
func (this *SysEvent) DecodeEvent() (EventInterface, error) {
// 解析数据类型
t, isOk := eventTypeMapping[this.Type]
@@ -17,7 +17,7 @@ func (this *SysEvent) DecodeEvent() (EventInterface, error) {
// 解析参数
if IsNotNull(this.Params) {
err := json.Unmarshal([]byte(this.Params), ptr)
err := json.Unmarshal(this.Params, ptr)
if err != nil {
return nil, err
}

View File

@@ -12,7 +12,7 @@ func (this *UserNode) DecodeHTTP() (*serverconfigs.HTTPProtocolConfig, error) {
return nil, nil
}
config := &serverconfigs.HTTPProtocolConfig{}
err := json.Unmarshal([]byte(this.Http), config)
err := json.Unmarshal(this.Http, config)
if err != nil {
return nil, err
}
@@ -31,7 +31,7 @@ func (this *UserNode) DecodeHTTPS(cacheMap *utils.CacheMap) (*serverconfigs.HTTP
return nil, nil
}
config := &serverconfigs.HTTPSProtocolConfig{}
err := json.Unmarshal([]byte(this.Https), config)
err := json.Unmarshal(this.Https, config)
if err != nil {
return nil, err
}
@@ -69,7 +69,7 @@ func (this *UserNode) DecodeAccessAddrs() ([]*serverconfigs.NetworkAddressConfig
}
addrConfigs := []*serverconfigs.NetworkAddressConfig{}
err := json.Unmarshal([]byte(this.AccessAddrs), &addrConfigs)
err := json.Unmarshal(this.AccessAddrs, &addrConfigs)
if err != nil {
return nil, err
}

View File

@@ -7,7 +7,7 @@ import (
var SharedCacheLocker = sync.RWMutex{}
// 处理JSON字节Slice
// JSONBytes 处理JSON字节Slice
func JSONBytes(data []byte) []byte {
if len(data) == 0 {
return []byte("null")
@@ -15,12 +15,12 @@ func JSONBytes(data []byte) []byte {
return data
}
// 判断JSON是否不为空
// IsNotNull 判断JSON是否不为空
func IsNotNull(data string) bool {
return len(data) > 0 && data != "null"
}
// 构造Query
// NewQuery 构造Query
func NewQuery(tx *dbs.Tx, dao dbs.DAOWrapper, adminId int64, userId int64) *dbs.Query {
query := dao.Object().Query(tx)
if adminId > 0 {

View File

@@ -101,7 +101,7 @@ func (this *Updater) loop() error {
if chunk == nil {
continue
}
_, err = fp.Write([]byte(chunk.Data))
_, err = fp.Write(chunk.Data)
if err != nil {
return err
}

View File

@@ -109,7 +109,7 @@ func (this *NSDomainService) FindEnabledNSDomain(ctx context.Context, req *pb.Fi
Id: int64(domain.Id),
Name: domain.Name,
IsOn: domain.IsOn == 1,
TsigJSON: []byte(domain.Tsig),
TsigJSON: domain.Tsig,
CreatedAt: int64(domain.CreatedAt),
NsCluster: &pb.NSCluster{
Id: int64(cluster.Id),
@@ -182,7 +182,7 @@ func (this *NSDomainService) ListEnabledNSDomains(ctx context.Context, req *pb.L
Name: domain.Name,
IsOn: domain.IsOn == 1,
CreatedAt: int64(domain.CreatedAt),
TsigJSON: []byte(domain.Tsig),
TsigJSON: domain.Tsig,
NsCluster: &pb.NSCluster{
Id: int64(cluster.Id),
IsOn: cluster.IsOn == 1,
@@ -220,7 +220,7 @@ func (this *NSDomainService) ListNSDomainsAfterVersion(ctx context.Context, req
IsOn: domain.IsOn == 1,
IsDeleted: domain.State == nameservers.NSDomainStateDisabled,
Version: int64(domain.Version),
TsigJSON: []byte(domain.Tsig),
TsigJSON: domain.Tsig,
NsCluster: &pb.NSCluster{Id: int64(domain.ClusterId)},
User: nil,
})

View File

@@ -127,7 +127,7 @@ func (this *NSNodeService) ListEnabledNSNodesMatch(ctx context.Context, req *pb.
IsInstalled: node.IsInstalled == 1,
InstallDir: node.InstallDir,
IsUp: node.IsUp == 1,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
InstallStatus: installStatusResult,
NsCluster: nil,
})
@@ -242,7 +242,7 @@ func (this *NSNodeService) FindEnabledNSNode(ctx context.Context, req *pb.FindEn
Id: int64(login.Id),
Name: login.Name,
Type: login.Type,
Params: []byte(login.Params),
Params: login.Params,
}
}
@@ -266,7 +266,7 @@ func (this *NSNodeService) FindEnabledNSNode(ctx context.Context, req *pb.FindEn
return &pb.FindEnabledNSNodeResponse{NsNode: &pb.NSNode{
Id: int64(node.Id),
Name: node.Name,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
UniqueId: node.UniqueId,
Secret: node.Secret,
IsInstalled: node.IsInstalled == 1,

View File

@@ -57,7 +57,7 @@ func (this *NSQuestionOptionService) FindNSQuestionOption(ctx context.Context, r
return &pb.FindNSQuestionOptionResponse{NsQuestionOption: &pb.NSQuestionOption{
Id: int64(option.Id),
Name: option.Name,
ValuesJSON: []byte(option.Values),
ValuesJSON: option.Values,
}}, nil
}

View File

@@ -109,7 +109,7 @@ func (this *NSRouteService) FindEnabledNSRoute(ctx context.Context, req *pb.Find
Id: int64(route.Id),
IsOn: route.IsOn == 1,
Name: route.Name,
RangesJSON: []byte(route.Ranges),
RangesJSON: route.Ranges,
NsCluster: pbCluster,
NsDomain: pbDomain,
}}, nil
@@ -164,7 +164,7 @@ func (this *NSRouteService) FindAllEnabledNSRoutes(ctx context.Context, req *pb.
Id: int64(route.Id),
IsOn: route.IsOn == 1,
Name: route.Name,
RangesJSON: []byte(route.Ranges),
RangesJSON: route.Ranges,
NsCluster: pbCluster,
NsDomain: pbDomain,
})
@@ -218,7 +218,7 @@ func (this *NSRouteService) ListNSRoutesAfterVersion(ctx context.Context, req *p
Id: int64(route.Id),
IsOn: route.IsOn == 1,
Name: "",
RangesJSON: []byte(route.Ranges),
RangesJSON: route.Ranges,
IsDeleted: route.State == nameservers.NSRouteStateDisabled,
Order: int64(route.Order),
Version: int64(route.Version),

View File

@@ -173,7 +173,7 @@ func (this *AdminService) FindEnabledAdmin(ctx context.Context, req *pb.FindEnab
pbOtpAuth = &pb.Login{
Id: int64(adminAuth.Id),
Type: adminAuth.Type,
ParamsJSON: []byte(adminAuth.Params),
ParamsJSON: adminAuth.Params,
IsOn: adminAuth.IsOn == 1,
}
}
@@ -393,7 +393,7 @@ func (this *AdminService) ListEnabledAdmins(ctx context.Context, req *pb.ListEna
pbOtpAuth = &pb.Login{
Id: int64(adminAuth.Id),
Type: adminAuth.Type,
ParamsJSON: []byte(adminAuth.Params),
ParamsJSON: adminAuth.Params,
IsOn: adminAuth.IsOn == 1,
}
}

View File

@@ -93,9 +93,9 @@ func (this *APINodeService) FindAllEnabledAPINodes(ctx context.Context, req *pb.
Secret: node.Secret,
Name: node.Name,
Description: node.Description,
HttpJSON: []byte(node.Http),
HttpsJSON: []byte(node.Https),
AccessAddrsJSON: []byte(node.AccessAddrs),
HttpJSON: node.Http,
HttpsJSON: node.Https,
AccessAddrsJSON: node.AccessAddrs,
AccessAddrs: accessAddrs,
})
}
@@ -166,14 +166,14 @@ func (this *APINodeService) ListEnabledAPINodes(ctx context.Context, req *pb.Lis
Secret: node.Secret,
Name: node.Name,
Description: node.Description,
HttpJSON: []byte(node.Http),
HttpsJSON: []byte(node.Https),
HttpJSON: node.Http,
HttpsJSON: node.Https,
RestIsOn: node.RestIsOn == 1,
RestHTTPJSON: []byte(node.RestHTTP),
RestHTTPSJSON: []byte(node.RestHTTPS),
AccessAddrsJSON: []byte(node.AccessAddrs),
RestHTTPJSON: node.RestHTTP,
RestHTTPSJSON: node.RestHTTPS,
AccessAddrsJSON: node.AccessAddrs,
AccessAddrs: accessAddrs,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
})
}
@@ -211,12 +211,12 @@ func (this *APINodeService) FindEnabledAPINode(ctx context.Context, req *pb.Find
Secret: node.Secret,
Name: node.Name,
Description: node.Description,
HttpJSON: []byte(node.Http),
HttpsJSON: []byte(node.Https),
HttpJSON: node.Http,
HttpsJSON: node.Https,
RestIsOn: node.RestIsOn == 1,
RestHTTPJSON: []byte(node.RestHTTP),
RestHTTPSJSON: []byte(node.RestHTTPS),
AccessAddrsJSON: []byte(node.AccessAddrs),
RestHTTPJSON: node.RestHTTP,
RestHTTPSJSON: node.RestHTTPS,
AccessAddrsJSON: node.AccessAddrs,
AccessAddrs: accessAddrs,
}
return &pb.FindEnabledAPINodeResponse{ApiNode: result}, nil
@@ -267,7 +267,7 @@ func (this *APINodeService) FindCurrentAPINode(ctx context.Context, req *pb.Find
RestIsOn: false,
RestHTTPJSON: nil,
RestHTTPSJSON: nil,
AccessAddrsJSON: []byte(node.AccessAddrs),
AccessAddrsJSON: node.AccessAddrs,
AccessAddrs: accessAddrs,
StatusJSON: nil,
}}, nil

View File

@@ -133,7 +133,7 @@ func (this *AuthorityNodeService) ListEnabledAuthorityNodes(ctx context.Context,
Secret: node.Secret,
Name: node.Name,
Description: node.Description,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
})
}

View File

@@ -89,7 +89,7 @@ func (this *DNSProviderService) ListEnabledDNSProviders(ctx context.Context, req
Name: provider.Name,
Type: provider.Type,
TypeName: dnsclients.FindProviderTypeName(provider.Type),
ApiParamsJSON: []byte(provider.ApiParams),
ApiParamsJSON: provider.ApiParams,
DataUpdatedAt: int64(provider.DataUpdatedAt),
})
}
@@ -119,7 +119,7 @@ func (this *DNSProviderService) FindAllEnabledDNSProviders(ctx context.Context,
Name: provider.Name,
Type: provider.Type,
TypeName: dnsclients.FindProviderTypeName(provider.Type),
ApiParamsJSON: []byte(provider.ApiParams),
ApiParamsJSON: provider.ApiParams,
DataUpdatedAt: int64(provider.DataUpdatedAt),
})
}
@@ -168,7 +168,7 @@ func (this *DNSProviderService) FindEnabledDNSProvider(ctx context.Context, req
Name: provider.Name,
Type: provider.Type,
TypeName: dnsclients.FindProviderTypeName(provider.Type),
ApiParamsJSON: []byte(provider.ApiParams),
ApiParamsJSON: provider.ApiParams,
DataUpdatedAt: int64(provider.DataUpdatedAt),
}}, nil
}

View File

@@ -67,5 +67,5 @@ func (this *FileChunkService) DownloadFileChunk(ctx context.Context, req *pb.Dow
if chunk == nil {
return &pb.DownloadFileChunkResponse{FileChunk: nil}, nil
}
return &pb.DownloadFileChunkResponse{FileChunk: &pb.FileChunk{Data: []byte(chunk.Data)}}, nil
return &pb.DownloadFileChunkResponse{FileChunk: &pb.FileChunk{Data: chunk.Data}}, nil
}

View File

@@ -45,8 +45,8 @@ func (this *HTTPAccessLogPolicyService) ListEnabledHTTPAccessLogPolicies(ctx con
Name: policy.Name,
IsOn: policy.IsOn == 1,
Type: policy.Type,
OptionsJSON: []byte(policy.Options),
CondsJSON: []byte(policy.Conds),
OptionsJSON: policy.Options,
CondsJSON: policy.Conds,
IsPublic: policy.IsPublic == 1,
})
}
@@ -123,8 +123,8 @@ func (this *HTTPAccessLogPolicyService) FindEnabledHTTPAccessLogPolicy(ctx conte
Name: policy.Name,
IsOn: policy.IsOn == 1,
Type: policy.Type,
OptionsJSON: []byte(policy.Options),
CondsJSON: []byte(policy.Conds),
OptionsJSON: policy.Options,
CondsJSON: policy.Conds,
IsPublic: policy.IsPublic == 1,
}}, nil
}

View File

@@ -64,6 +64,6 @@ func (this *HTTPAuthPolicyService) FindEnabledHTTPAuthPolicy(ctx context.Context
IsOn: policy.IsOn == 1,
Name: policy.Name,
Type: policy.Type,
ParamsJSON: []byte(policy.Params),
ParamsJSON: policy.Params,
}}, nil
}

View File

@@ -77,9 +77,9 @@ func (this *HTTPFastcgiService) FindEnabledHTTPFastcgi(ctx context.Context, req
Id: int64(fastcgi.Id),
IsOn: fastcgi.IsOn == 1,
Address: fastcgi.Address,
ParamsJSON: []byte(fastcgi.Params),
ReadTimeoutJSON: []byte(fastcgi.ReadTimeout),
ConnTimeoutJSON: []byte(fastcgi.ConnTimeout),
ParamsJSON: fastcgi.Params,
ReadTimeoutJSON: fastcgi.ReadTimeout,
ConnTimeoutJSON: fastcgi.ConnTimeout,
PoolSize: types.Int32(fastcgi.PoolSize),
PathInfoPattern: fastcgi.PathInfoPattern,
}}, nil

View File

@@ -41,8 +41,8 @@ func (this *HTTPFirewallPolicyService) FindAllEnabledHTTPFirewallPolicies(ctx co
Name: p.Name,
Description: p.Description,
IsOn: p.IsOn == 1,
InboundJSON: []byte(p.Inbound),
OutboundJSON: []byte(p.Outbound),
InboundJSON: p.Inbound,
OutboundJSON: p.Outbound,
Mode: p.Mode,
UseLocalFirewall: p.UseLocalFirewall == 1,
})
@@ -390,8 +390,8 @@ func (this *HTTPFirewallPolicyService) ListEnabledHTTPFirewallPolicies(ctx conte
Name: p.Name,
Description: p.Description,
IsOn: p.IsOn == 1,
InboundJSON: []byte(p.Inbound),
OutboundJSON: []byte(p.Outbound),
InboundJSON: p.Inbound,
OutboundJSON: p.Outbound,
Mode: p.Mode,
UseLocalFirewall: p.UseLocalFirewall == 1,
})
@@ -482,10 +482,10 @@ func (this *HTTPFirewallPolicyService) FindEnabledHTTPFirewallPolicy(ctx context
Name: policy.Name,
Description: policy.Description,
IsOn: policy.IsOn == 1,
InboundJSON: []byte(policy.Inbound),
OutboundJSON: []byte(policy.Outbound),
InboundJSON: policy.Inbound,
OutboundJSON: policy.Outbound,
Mode: policy.Mode,
SynFloodJSON: []byte(policy.SynFlood),
SynFloodJSON: policy.SynFlood,
}}, nil
}

View File

@@ -70,7 +70,7 @@ func (this *IPListService) FindEnabledIPList(ctx context.Context, req *pb.FindEn
Type: list.Type,
Name: list.Name,
Code: list.Code,
TimeoutJSON: []byte(list.Timeout),
TimeoutJSON: list.Timeout,
Description: list.Description,
IsGlobal: list.IsGlobal == 1,
}}, nil
@@ -111,7 +111,7 @@ func (this *IPListService) ListEnabledIPLists(ctx context.Context, req *pb.ListE
Type: list.Type,
Name: list.Name,
Code: list.Code,
TimeoutJSON: []byte(list.Timeout),
TimeoutJSON: list.Timeout,
IsPublic: list.IsPublic == 1,
Description: list.Description,
IsGlobal: list.IsGlobal == 1,

View File

@@ -9,12 +9,12 @@ import (
"github.com/iwind/TeaGo/maps"
)
// 管理员认证相关服务
// LoginService 管理员认证相关服务
type LoginService struct {
BaseService
}
// 查找认证
// FindEnabledLogin 查找认证
func (this *LoginService) FindEnabledLogin(ctx context.Context, req *pb.FindEnabledLoginRequest) (*pb.FindEnabledLoginResponse, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -33,14 +33,14 @@ func (this *LoginService) FindEnabledLogin(ctx context.Context, req *pb.FindEnab
return &pb.FindEnabledLoginResponse{Login: &pb.Login{
Id: int64(login.Id),
Type: login.Type,
ParamsJSON: []byte(login.Params),
ParamsJSON: login.Params,
IsOn: login.IsOn == 1,
AdminId: int64(login.AdminId),
UserId: int64(login.UserId),
}}, nil
}
// 修改认证
// UpdateLogin 修改认证
func (this *LoginService) UpdateLogin(ctx context.Context, req *pb.UpdateLoginRequest) (*pb.RPCSuccess, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {

View File

@@ -108,7 +108,7 @@ func (this *MessageService) ListUnreadMessages(ctx context.Context, req *pb.List
Type: message.Type,
Body: message.Body,
Level: message.Level,
ParamsJSON: []byte(message.Params),
ParamsJSON: message.Params,
IsRead: message.IsRead == 1,
CreatedAt: int64(message.CreatedAt),
NodeCluster: pbCluster,

View File

@@ -131,9 +131,9 @@ func (this *MessageMediaInstanceService) ListEnabledMessageMediaInstances(ctx co
Name: instance.Name,
IsOn: instance.IsOn == 1,
MessageMedia: pbMedia,
ParamsJSON: []byte(instance.Params),
ParamsJSON: instance.Params,
Description: instance.Description,
RateJSON: []byte(instance.Rate),
RateJSON: instance.Rate,
})
}
@@ -179,9 +179,9 @@ func (this *MessageMediaInstanceService) FindEnabledMessageMediaInstance(ctx con
Name: instance.Name,
IsOn: instance.IsOn == 1,
MessageMedia: pbMedia,
ParamsJSON: []byte(instance.Params),
ParamsJSON: instance.Params,
Description: instance.Description,
RateJSON: []byte(instance.Rate),
RateJSON: instance.Rate,
HashLife: types.Int32(instance.HashLife),
}}, nil
}

View File

@@ -150,7 +150,7 @@ func (this *MessageReceiverService) FindAllEnabledMessageReceivers(ctx context.C
NodeId: int64(receiver.NodeId),
ServerId: int64(receiver.ServerId),
Type: receiver.Type,
ParamsJSON: []byte(receiver.Params),
ParamsJSON: receiver.Params,
MessageRecipient: pbRecipient,
MessageRecipientGroup: pbRecipientGroup,
})

View File

@@ -82,8 +82,8 @@ func (this *MessageTaskService) FindSendingMessageTasks(ctx context.Context, req
MessageMedia: &pb.MessageMedia{
Type: instance.MediaType,
},
ParamsJSON: []byte(instance.Params),
RateJSON: []byte(instance.Rate),
ParamsJSON: instance.Params,
RateJSON: instance.Rate,
},
}
} else { // 没有指定既定的接收人
@@ -107,8 +107,8 @@ func (this *MessageTaskService) FindSendingMessageTasks(ctx context.Context, req
MessageMedia: &pb.MessageMedia{
Type: instance.MediaType,
},
ParamsJSON: []byte(instance.Params),
RateJSON: []byte(instance.Rate),
ParamsJSON: instance.Params,
RateJSON: instance.Rate,
},
}
}
@@ -232,7 +232,7 @@ func (this *MessageTaskService) FindEnabledMessageTask(ctx context.Context, req
MessageMedia: &pb.MessageMedia{
Type: instance.MediaType,
},
ParamsJSON: []byte(instance.Params),
ParamsJSON: instance.Params,
},
}
} else { // 没有指定既定的接收人
@@ -256,14 +256,14 @@ func (this *MessageTaskService) FindEnabledMessageTask(ctx context.Context, req
MessageMedia: &pb.MessageMedia{
Type: instance.MediaType,
},
ParamsJSON: []byte(instance.Params),
ParamsJSON: instance.Params,
},
}
}
var result = &pb.MessageTaskResult{}
if len(task.Result) > 0 {
err = json.Unmarshal([]byte(task.Result), result)
err = json.Unmarshal(task.Result, result)
if err != nil {
return nil, err
}
@@ -352,8 +352,8 @@ func (this *MessageTaskService) ListMessageTasksWithStatus(ctx context.Context,
MessageMedia: &pb.MessageMedia{
Type: instance.MediaType,
},
ParamsJSON: []byte(instance.Params),
RateJSON: []byte(instance.Rate),
ParamsJSON: instance.Params,
RateJSON: instance.Rate,
},
}
} else { // 没有指定既定的接收人
@@ -378,15 +378,15 @@ func (this *MessageTaskService) ListMessageTasksWithStatus(ctx context.Context,
MessageMedia: &pb.MessageMedia{
Type: instance.MediaType,
},
ParamsJSON: []byte(instance.Params),
RateJSON: []byte(instance.Rate),
ParamsJSON: instance.Params,
RateJSON: instance.Rate,
},
}
}
var result = &pb.MessageTaskResult{}
if len(task.Result) > 0 {
err = json.Unmarshal([]byte(task.Result), result)
err = json.Unmarshal(task.Result, result)
if err != nil {
return nil, err
}

View File

@@ -82,7 +82,7 @@ func (this *MetricChartService) FindEnabledMetricChart(ctx context.Context, req
Type: chart.Type,
WidthDiv: types.Int32(chart.WidthDiv),
MaxItems: types.Int32(chart.MaxItems),
ParamsJSON: []byte(chart.Params),
ParamsJSON: chart.Params,
IgnoreEmptyKeys: chart.IgnoreEmptyKeys == 1,
IgnoredKeys: chart.DecodeIgnoredKeys(),
IsOn: chart.IsOn == 1,
@@ -126,7 +126,7 @@ func (this *MetricChartService) ListEnabledMetricCharts(ctx context.Context, req
Type: chart.Type,
WidthDiv: types.Int32(chart.WidthDiv),
MaxItems: types.Int32(chart.MaxItems),
ParamsJSON: []byte(chart.Params),
ParamsJSON: chart.Params,
IgnoreEmptyKeys: chart.IgnoreEmptyKeys == 1,
IgnoredKeys: chart.DecodeIgnoredKeys(),
IsOn: chart.IsOn == 1,

View File

@@ -133,7 +133,7 @@ func (this *MonitorNodeService) ListEnabledMonitorNodes(ctx context.Context, req
Secret: node.Secret,
Name: node.Name,
Description: node.Description,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
})
}

View File

@@ -314,7 +314,7 @@ func (this *NodeService) ListEnabledNodesMatch(ctx context.Context, req *pb.List
Name: node.Name,
Version: int64(node.Version),
IsInstalled: node.IsInstalled == 1,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
NodeCluster: &pb.NodeCluster{
Id: int64(node.ClusterId),
Name: clusterName,
@@ -356,7 +356,7 @@ func (this *NodeService) FindAllEnabledNodesWithNodeClusterId(ctx context.Contex
for _, node := range nodes {
apiNodeIds := []int64{}
if models.IsNotNull(node.ConnectedAPINodes) {
err = json.Unmarshal([]byte(node.ConnectedAPINodes), &apiNodeIds)
err = json.Unmarshal(node.ConnectedAPINodes, &apiNodeIds)
if err != nil {
return nil, err
}
@@ -482,7 +482,7 @@ func (this *NodeService) FindEnabledNode(ctx context.Context, req *pb.FindEnable
Id: int64(login.Id),
Name: login.Name,
Type: login.Type,
Params: []byte(login.Params),
Params: login.Params,
}
}
@@ -536,9 +536,9 @@ func (this *NodeService) FindEnabledNode(ctx context.Context, req *pb.FindEnable
// 最大硬盘容量
var pbMaxCacheDiskCapacity *pb.SizeCapacity
if len(node.MaxCacheDiskCapacity) > 0 {
if models.IsNotNull(node.MaxCacheDiskCapacity) {
pbMaxCacheDiskCapacity = &pb.SizeCapacity{}
err = json.Unmarshal([]byte(node.MaxCacheDiskCapacity), pbMaxCacheDiskCapacity)
err = json.Unmarshal(node.MaxCacheDiskCapacity, pbMaxCacheDiskCapacity)
if err != nil {
return nil, err
}
@@ -546,9 +546,9 @@ func (this *NodeService) FindEnabledNode(ctx context.Context, req *pb.FindEnable
// 最大内存容量
var pbMaxCacheMemoryCapacity *pb.SizeCapacity
if len(node.MaxCacheMemoryCapacity) > 0 {
if models.IsNotNull(node.MaxCacheMemoryCapacity) {
pbMaxCacheMemoryCapacity = &pb.SizeCapacity{}
err = json.Unmarshal([]byte(node.MaxCacheMemoryCapacity), pbMaxCacheMemoryCapacity)
err = json.Unmarshal(node.MaxCacheMemoryCapacity, pbMaxCacheMemoryCapacity)
if err != nil {
return nil, err
}
@@ -557,7 +557,7 @@ func (this *NodeService) FindEnabledNode(ctx context.Context, req *pb.FindEnable
return &pb.FindEnabledNodeResponse{Node: &pb.Node{
Id: int64(node.Id),
Name: node.Name,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
UniqueId: node.UniqueId,
Version: int64(node.Version),
LatestVersion: int64(node.LatestVersion),
@@ -876,7 +876,7 @@ func (this *NodeService) FindAllEnabledNodesWithNodeGrantId(ctx context.Context,
Name: node.Name,
Version: int64(node.Version),
IsInstalled: node.IsInstalled == 1,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
NodeCluster: &pb.NodeCluster{
Id: int64(node.ClusterId),
Name: clusterName,
@@ -928,7 +928,7 @@ func (this *NodeService) FindAllNotInstalledNodesWithNodeClusterId(ctx context.C
Id: int64(login.Id),
Name: login.Name,
Type: login.Type,
Params: []byte(login.Params),
Params: login.Params,
}
}
@@ -974,7 +974,7 @@ func (this *NodeService) FindAllNotInstalledNodesWithNodeClusterId(ctx context.C
Name: node.Name,
Version: int64(node.Version),
IsInstalled: node.IsInstalled == 1,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
IsOn: node.IsOn == 1,
NodeLogin: pbLogin,
IpAddresses: pbAddresses,
@@ -1037,7 +1037,7 @@ func (this *NodeService) FindAllUpgradeNodesWithNodeClusterId(ctx context.Contex
Id: int64(login.Id),
Name: login.Name,
Type: login.Type,
Params: []byte(login.Params),
Params: login.Params,
}
}
@@ -1092,7 +1092,7 @@ func (this *NodeService) FindAllUpgradeNodesWithNodeClusterId(ctx context.Contex
Name: node.Name,
Version: int64(node.Version),
IsInstalled: node.IsInstalled == 1,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
IsOn: node.IsOn == 1,
IpAddresses: pbAddresses,
NodeLogin: pbLogin,

View File

@@ -94,7 +94,7 @@ func (this *NodeClusterFirewallActionService) FindAllEnabledNodeClusterFirewallA
Name: action.Name,
EventLevel: action.EventLevel,
Type: action.Type,
ParamsJSON: []byte(action.Params),
ParamsJSON: action.Params,
})
}
return &pb.FindAllEnabledNodeClusterFirewallActionsResponse{NodeClusterFirewallActions: pbActions}, nil
@@ -121,7 +121,7 @@ func (this *NodeClusterFirewallActionService) FindEnabledNodeClusterFirewallActi
Name: action.Name,
EventLevel: action.EventLevel,
Type: action.Type,
ParamsJSON: []byte(action.Params),
ParamsJSON: action.Params,
}}, nil
}

View File

@@ -109,8 +109,8 @@ func (this *NodeIPAddressThresholdService) FindAllEnabledNodeIPAddressThresholds
for _, threshold := range thresholds {
pbThresholds = append(pbThresholds, &pb.NodeIPAddressThreshold{
Id: int64(threshold.Id),
ItemsJSON: []byte(threshold.Items),
ActionsJSON: []byte(threshold.Actions),
ItemsJSON: threshold.Items,
ActionsJSON: threshold.Actions,
})
}
return &pb.FindAllEnabledNodeIPAddressThresholdsResponse{NodeIPAddressThresholds: pbThresholds}, nil

View File

@@ -6,12 +6,12 @@ import (
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
// 节点区域相关服务
// NodeRegionService 节点区域相关服务
type NodeRegionService struct {
BaseService
}
// 创建区域
// CreateNodeRegion 创建区域
func (this *NodeRegionService) CreateNodeRegion(ctx context.Context, req *pb.CreateNodeRegionRequest) (*pb.CreateNodeRegionResponse, error) {
adminId, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -27,7 +27,7 @@ func (this *NodeRegionService) CreateNodeRegion(ctx context.Context, req *pb.Cre
return &pb.CreateNodeRegionResponse{NodeRegionId: regionId}, nil
}
// 修改区域
// UpdateNodeRegion 修改区域
func (this *NodeRegionService) UpdateNodeRegion(ctx context.Context, req *pb.UpdateNodeRegionRequest) (*pb.RPCSuccess, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -43,7 +43,7 @@ func (this *NodeRegionService) UpdateNodeRegion(ctx context.Context, req *pb.Upd
return this.Success()
}
// 删除区域
// DeleteNodeRegion 删除区域
func (this *NodeRegionService) DeleteNodeRegion(ctx context.Context, req *pb.DeleteNodeRegionRequest) (*pb.RPCSuccess, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -59,7 +59,7 @@ func (this *NodeRegionService) DeleteNodeRegion(ctx context.Context, req *pb.Del
return this.Success()
}
// 查找所有区域
// FindAllEnabledNodeRegions 查找所有区域
func (this *NodeRegionService) FindAllEnabledNodeRegions(ctx context.Context, req *pb.FindAllEnabledNodeRegionsRequest) (*pb.FindAllEnabledNodeRegionsResponse, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -79,13 +79,13 @@ func (this *NodeRegionService) FindAllEnabledNodeRegions(ctx context.Context, re
IsOn: region.IsOn == 1,
Name: region.Name,
Description: region.Description,
PricesJSON: []byte(region.Prices),
PricesJSON: region.Prices,
})
}
return &pb.FindAllEnabledNodeRegionsResponse{NodeRegions: result}, nil
}
// 查找所有启用的区域
// FindAllEnabledAndOnNodeRegions 查找所有启用的区域
func (this *NodeRegionService) FindAllEnabledAndOnNodeRegions(ctx context.Context, req *pb.FindAllEnabledAndOnNodeRegionsRequest) (*pb.FindAllEnabledAndOnNodeRegionsResponse, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -105,13 +105,13 @@ func (this *NodeRegionService) FindAllEnabledAndOnNodeRegions(ctx context.Contex
IsOn: region.IsOn == 1,
Name: region.Name,
Description: region.Description,
PricesJSON: []byte(region.Prices),
PricesJSON: region.Prices,
})
}
return &pb.FindAllEnabledAndOnNodeRegionsResponse{NodeRegions: result}, nil
}
// 排序
// UpdateNodeRegionOrders 排序
func (this *NodeRegionService) UpdateNodeRegionOrders(ctx context.Context, req *pb.UpdateNodeRegionOrdersRequest) (*pb.RPCSuccess, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -127,7 +127,7 @@ func (this *NodeRegionService) UpdateNodeRegionOrders(ctx context.Context, req *
return this.Success()
}
// 查找单个区域信息
// FindEnabledNodeRegion 查找单个区域信息
func (this *NodeRegionService) FindEnabledNodeRegion(ctx context.Context, req *pb.FindEnabledNodeRegionRequest) (*pb.FindEnabledNodeRegionResponse, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
@@ -148,11 +148,11 @@ func (this *NodeRegionService) FindEnabledNodeRegion(ctx context.Context, req *p
IsOn: region.IsOn == 1,
Name: region.Name,
Description: region.Description,
PricesJSON: []byte(region.Prices),
PricesJSON: region.Prices,
}}, nil
}
// 修改价格项价格
// UpdateNodeRegionPrice 修改价格项价格
func (this *NodeRegionService) UpdateNodeRegionPrice(ctx context.Context, req *pb.UpdateNodeRegionPriceRequest) (*pb.RPCSuccess, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {

View File

@@ -94,7 +94,7 @@ func (this *NodeThresholdService) FindAllEnabledNodeThresholds(ctx context.Conte
Item: threshold.Item,
Param: threshold.Param,
Operator: threshold.Operator,
ValueJSON: []byte(threshold.Value),
ValueJSON: threshold.Value,
Message: threshold.Message,
Duration: types.Int32(threshold.Duration),
DurationUnit: threshold.DurationUnit,
@@ -160,7 +160,7 @@ func (this *NodeThresholdService) FindEnabledNodeThreshold(ctx context.Context,
Item: threshold.Item,
Param: threshold.Param,
Operator: threshold.Operator,
ValueJSON: []byte(threshold.Value),
ValueJSON: threshold.Value,
Message: threshold.Message,
Duration: types.Int32(threshold.Duration),
DurationUnit: threshold.DurationUnit,

View File

@@ -63,7 +63,7 @@ func (this *NodeValueService) ListNodeValues(ctx context.Context, req *pb.ListNo
pbValues := []*pb.NodeValue{}
for _, value := range values {
pbValues = append(pbValues, &pb.NodeValue{
ValueJSON: []byte(value.Value),
ValueJSON: value.Value,
CreatedAt: int64(value.CreatedAt),
})
}

View File

@@ -30,7 +30,7 @@ func (this *RegionCountryService) FindAllEnabledRegionCountries(ctx context.Cont
result := []*pb.RegionCountry{}
for _, country := range countries {
pinyinStrings := []string{}
err = json.Unmarshal([]byte(country.Pinyin), &pinyinStrings)
err = json.Unmarshal(country.Pinyin, &pinyinStrings)
if err != nil {
return nil, err
}

View File

@@ -62,9 +62,9 @@ func (this *ReverseProxyService) FindEnabledReverseProxy(ctx context.Context, re
result := &pb.ReverseProxy{
Id: int64(reverseProxy.Id),
SchedulingJSON: []byte(reverseProxy.Scheduling),
PrimaryOriginsJSON: []byte(reverseProxy.PrimaryOrigins),
BackupOriginsJSON: []byte(reverseProxy.BackupOrigins),
SchedulingJSON: reverseProxy.Scheduling,
PrimaryOriginsJSON: reverseProxy.PrimaryOrigins,
BackupOriginsJSON: reverseProxy.BackupOrigins,
}
return &pb.FindEnabledReverseProxyResponse{ReverseProxy: result}, nil
}

View File

@@ -435,7 +435,7 @@ func (this *ServerGroupService) FindEnabledServerGroupConfigInfo(ctx context.Con
if len(group.HttpReverseProxy) > 0 {
var ref = &serverconfigs.ReverseProxyRef{}
err = json.Unmarshal([]byte(group.HttpReverseProxy), ref)
err = json.Unmarshal(group.HttpReverseProxy, ref)
if err != nil {
return nil, err
}
@@ -444,7 +444,7 @@ func (this *ServerGroupService) FindEnabledServerGroupConfigInfo(ctx context.Con
if len(group.TcpReverseProxy) > 0 {
var ref = &serverconfigs.ReverseProxyRef{}
err = json.Unmarshal([]byte(group.TcpReverseProxy), ref)
err = json.Unmarshal(group.TcpReverseProxy, ref)
if err != nil {
return nil, err
}
@@ -453,7 +453,7 @@ func (this *ServerGroupService) FindEnabledServerGroupConfigInfo(ctx context.Con
if len(group.UdpReverseProxy) > 0 {
var ref = &serverconfigs.ReverseProxyRef{}
err = json.Unmarshal([]byte(group.UdpReverseProxy), ref)
err = json.Unmarshal(group.UdpReverseProxy, ref)
if err != nil {
return nil, err
}

View File

@@ -436,7 +436,7 @@ func (this *ServerStatBoardService) ComposeServerStatNodeBoard(ctx context.Conte
}
for _, v := range cacheDirValues {
result.CacheDirsValues = append(result.CacheDirsValues, &pb.NodeValue{
ValueJSON: []byte(v.Value),
ValueJSON: v.Value,
CreatedAt: int64(v.CreatedAt),
})
}

View File

@@ -222,7 +222,7 @@ func (this *SSLCertService) ListSSLCertsWithOCSPError(ctx context.Context, req *
CommonNames: cert.DecodeCommonNames(),
IsACME: cert.IsACME == 1,
AcmeTaskId: int64(cert.AcmeTaskId),
Ocsp: []byte(cert.Ocsp),
Ocsp: cert.Ocsp,
OcspIsUpdated: cert.OcspIsUpdated == 1,
OcspError: cert.OcspError,
Description: cert.Description,
@@ -300,7 +300,7 @@ func (this *SSLCertService) ListUpdatedSSLCertOCSP(ctx context.Context, req *pb.
for _, cert := range certs {
result = append(result, &pb.ListUpdatedSSLCertOCSPResponse_SSLCertOCSP{
SslCertId: int64(cert.Id),
Data: []byte(cert.Ocsp),
Data: cert.Ocsp,
ExpiresAt: int64(cert.OcspExpiresAt),
Version: int64(cert.OcspUpdatedVersion),
})

View File

@@ -92,9 +92,9 @@ func (this *UserNodeService) FindAllEnabledUserNodes(ctx context.Context, req *p
Secret: node.Secret,
Name: node.Name,
Description: node.Description,
HttpJSON: []byte(node.Http),
HttpsJSON: []byte(node.Https),
AccessAddrsJSON: []byte(node.AccessAddrs),
HttpJSON: node.Http,
HttpsJSON: node.Https,
AccessAddrsJSON: node.AccessAddrs,
AccessAddrs: accessAddrs,
})
}
@@ -147,11 +147,11 @@ func (this *UserNodeService) ListEnabledUserNodes(ctx context.Context, req *pb.L
Secret: node.Secret,
Name: node.Name,
Description: node.Description,
HttpJSON: []byte(node.Http),
HttpsJSON: []byte(node.Https),
AccessAddrsJSON: []byte(node.AccessAddrs),
HttpJSON: node.Http,
HttpsJSON: node.Https,
AccessAddrsJSON: node.AccessAddrs,
AccessAddrs: accessAddrs,
StatusJSON: []byte(node.Status),
StatusJSON: node.Status,
})
}
@@ -188,9 +188,9 @@ func (this *UserNodeService) FindEnabledUserNode(ctx context.Context, req *pb.Fi
Secret: node.Secret,
Name: node.Name,
Description: node.Description,
HttpJSON: []byte(node.Http),
HttpsJSON: []byte(node.Https),
AccessAddrsJSON: []byte(node.AccessAddrs),
HttpJSON: node.Http,
HttpsJSON: node.Https,
AccessAddrsJSON: node.AccessAddrs,
AccessAddrs: accessAddrs,
}
return &pb.FindEnabledUserNodeResponse{UserNode: result}, nil
@@ -235,9 +235,9 @@ func (this *UserNodeService) FindCurrentUserNode(ctx context.Context, req *pb.Fi
Secret: node.Secret,
Name: node.Name,
Description: node.Description,
HttpJSON: []byte(node.Http),
HttpsJSON: []byte(node.Https),
AccessAddrsJSON: []byte(node.AccessAddrs),
HttpJSON: node.Http,
HttpsJSON: node.Https,
AccessAddrsJSON: node.AccessAddrs,
AccessAddrs: accessAddrs,
}
return &pb.FindCurrentUserNodeResponse{UserNode: result}, nil

View File

@@ -106,7 +106,7 @@ func (this *SSLCertUpdateOCSPTask) UpdateCertOCSP(certOne *models.SSLCert) (ocsp
return
}
keyPair, err := tls.X509KeyPair([]byte(certOne.CertData), []byte(certOne.KeyData))
keyPair, err := tls.X509KeyPair(certOne.CertData, certOne.KeyData)
if err != nil {
return nil, 0, errors.New("parse certificate failed: " + err.Error())
}