实现WAF部分功能

This commit is contained in:
GoEdgeLab
2020-10-08 11:11:37 +08:00
parent 15d88b71a3
commit 8e0c10419a
28 changed files with 1443 additions and 17 deletions

View File

@@ -0,0 +1,35 @@
package models
import (
"context"
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
)
var SharedHTTPFirewallRuleSetDAO = new(HTTPFirewallRuleSetDAO)
type HTTPFirewallRuleSetDAO struct {
}
// 查找规则集配置
func (this *HTTPFirewallRuleSetDAO) FindRuleSetConfig(ctx context.Context, setId int64) (*firewallconfigs.HTTPFirewallRuleSet, error) {
client, err := rpc.SharedRPC()
if err != nil {
return nil, err
}
resp, err := client.HTTPFirewallRuleSetRPC().FindHTTPFirewallRuleSetConfig(ctx, &pb.FindHTTPFirewallRuleSetConfigRequest{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
}