用户端可以添加WAF 黑白名单

This commit is contained in:
刘祥超
2021-01-03 20:18:07 +08:00
parent f49c26cdab
commit 70c1ee2984
9 changed files with 129 additions and 17 deletions

View File

@@ -75,9 +75,10 @@ func (this *IPListDAO) FindIPListName(tx *dbs.Tx, id int64) (string, error) {
}
// 创建名单
func (this *IPListDAO) CreateIPList(tx *dbs.Tx, listType ipconfigs.IPListType, name string, code string, timeoutJSON []byte) (int64, error) {
func (this *IPListDAO) CreateIPList(tx *dbs.Tx, userId int64, listType ipconfigs.IPListType, name string, code string, timeoutJSON []byte) (int64, error) {
op := NewIPListOperator()
op.IsOn = true
op.UserId = userId
op.State = IPListStateEnabled
op.Type = listType
op.Name = name
@@ -128,3 +129,18 @@ func (this *IPListDAO) IncreaseVersion(tx *dbs.Tx) (int64, error) {
err = SharedSysSettingDAO.UpdateSetting(tx, SettingCodeIPListVersion, []byte(numberutils.FormatInt64(value)))
return value, nil
}
// 检查用户权限
func (this *IPListDAO) CheckUserIPList(tx *dbs.Tx, userId int64, listId int64) error {
ok, err := this.Query(tx).
Pk(listId).
Attr("userId", userId).
Exist()
if err != nil {
return err
}
if ok {
return nil
}
return ErrNotFound
}