mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-26 15:06:37 +08:00
变更版本
This commit is contained in:
@@ -3,8 +3,10 @@ package services
|
||||
import (
|
||||
"context"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/errors"
|
||||
rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"net"
|
||||
)
|
||||
|
||||
// IP条目相关服务
|
||||
@@ -20,6 +22,22 @@ func (this *IPItemService) CreateIPItem(ctx context.Context, req *pb.CreateIPIte
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(req.IpFrom) == 0 {
|
||||
return nil, errors.New("'ipFrom' should not be empty")
|
||||
}
|
||||
|
||||
ipFrom := net.ParseIP(req.IpFrom)
|
||||
if ipFrom == nil {
|
||||
return nil, errors.New("invalid 'ipFrom'")
|
||||
}
|
||||
|
||||
if len(req.IpTo) > 0 {
|
||||
ipTo := net.ParseIP(req.IpTo)
|
||||
if ipTo == nil {
|
||||
return nil, errors.New("invalid 'ipTo'")
|
||||
}
|
||||
}
|
||||
|
||||
tx := this.NullTx()
|
||||
|
||||
if userId > 0 {
|
||||
|
||||
Reference in New Issue
Block a user