mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2026-03-11 18:05:36 +08:00
优化代码
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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), ¶ms)
|
||||
err = json.Unmarshal(policy.Params, ¶ms)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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), ¶ms)
|
||||
err = json.Unmarshal(fastcgi.Params, ¶ms)
|
||||
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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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), ¶mFilters)
|
||||
err = json.Unmarshal(rule.ParamFilters, ¶mFilters)
|
||||
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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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())
|
||||
// 不阻断执行
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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{}
|
||||
}
|
||||
|
||||
@@ -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), ¶ms)
|
||||
err := json.Unmarshal(this.Params, ¶ms)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
// 忽略错误
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user