mirror of
https://gitee.com/samwaf/SamWaf.git
synced 2026-11-02 19:21:44 +08:00
Merge pull request #547 from samwafgo/feat_export_badip
feat: export bad ip
This commit is contained in:
+7
-2
@@ -10,14 +10,15 @@ import (
|
||||
"SamWaf/model/request"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/xuri/excelize/v2"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/xuri/excelize/v2"
|
||||
)
|
||||
|
||||
type WafCommonApi struct {
|
||||
@@ -141,6 +142,10 @@ func getStructTypeValueByName(name string) (reflect.Type, reflect.Value) {
|
||||
// 模拟获取数据
|
||||
webHosts := wafHostService.GetAllHostApi()
|
||||
return reflect.TypeOf(model.Hosts{}), reflect.ValueOf(webHosts)
|
||||
case "ipblock":
|
||||
// 获取所有IP黑名单数据
|
||||
ipBlocks := wafIpBlockService.GetAllBlockIpApi()
|
||||
return reflect.TypeOf(model.IPBlockList{}), reflect.ValueOf(ipBlocks)
|
||||
default:
|
||||
return nil, reflect.ValueOf(nil)
|
||||
}
|
||||
|
||||
@@ -172,3 +172,10 @@ func (receiver *WafBlockIpService) GetHostCodes() ([]string, error) {
|
||||
Pluck("host_code", &hostCodes).Error
|
||||
return hostCodes, err
|
||||
}
|
||||
|
||||
// GetAllBlockIpApi 获取所有IP黑名单数据(用于导出)
|
||||
func (receiver *WafBlockIpService) GetAllBlockIpApi() []model.IPBlockList {
|
||||
var list []model.IPBlockList
|
||||
global.GWAF_LOCAL_DB.Where("user_code = ? AND tenant_id = ?", global.GWAF_USER_CODE, global.GWAF_TENANT_ID).Find(&list)
|
||||
return list
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user