IP名单代号增加长度限制

This commit is contained in:
GoEdgeLab
2024-05-05 19:19:42 +08:00
parent ea03586e7f
commit 18b06b0368

View File

@@ -50,6 +50,10 @@ func (this *IPListService) CreateIPList(ctx context.Context, req *pb.CreateIPLis
// 检查代号
if len(req.Code) > 0 {
if len(req.Code) > 100 {
return nil, errors.New("too long 'code', should be short than 100 characters")
}
if !models.SharedIPListDAO.ValidateIPListCode(req.Code) {
return nil, errors.New("invalid 'code' format")
}
@@ -82,6 +86,10 @@ func (this *IPListService) UpdateIPList(ctx context.Context, req *pb.UpdateIPLis
// 检查代号
if len(req.Code) > 0 {
if len(req.Code) > 100 {
return nil, errors.New("too long 'code', should be short than 100 characters")
}
if !models.SharedIPListDAO.ValidateIPListCode(req.Code) {
return nil, errors.New("invalid 'code' format")
}