mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-23 19:20:24 +08:00
阶段性提交
This commit is contained in:
31
pkg/rpc/dao/http_firewall_rule_set_dao.go
Normal file
31
pkg/rpc/dao/http_firewall_rule_set_dao.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
|
||||
)
|
||||
|
||||
var SharedHTTPFirewallRuleSetDAO = new(HTTPFirewallRuleSetDAO)
|
||||
|
||||
type HTTPFirewallRuleSetDAO struct {
|
||||
BaseDAO
|
||||
}
|
||||
|
||||
// 查找规则集配置
|
||||
func (this *HTTPFirewallRuleSetDAO) FindRuleSetConfig(ctx context.Context, setId int64) (*firewallconfigs.HTTPFirewallRuleSet, error) {
|
||||
resp, err := this.RPC().HTTPFirewallRuleSetRPC().FindEnabledHTTPFirewallRuleSetConfig(ctx, &pb.FindEnabledHTTPFirewallRuleSetConfigRequest{FirewallRuleSetId: setId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(resp.FirewallRuleSetJSON) == 0 {
|
||||
return nil, err
|
||||
}
|
||||
config := &firewallconfigs.HTTPFirewallRuleSet{}
|
||||
err = json.Unmarshal(resp.FirewallRuleSetJSON, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
Reference in New Issue
Block a user