mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-20 19:09:07 +01:00
feat: add validation of tags
This commit is contained in:
parent
fdbc9657bc
commit
62cfd60e38
@ -543,6 +543,8 @@ var tagCmd = &cobra.Command{
|
||||
fmt.Sprintf("Error while sending tags to headscale: %s", err),
|
||||
output,
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if resp != nil {
|
||||
|
12
grpcv1.go
12
grpcv1.go
@ -8,6 +8,8 @@ import (
|
||||
|
||||
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
||||
"github.com/rs/zerolog/log"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"tailscale.com/tailcfg"
|
||||
)
|
||||
|
||||
@ -194,10 +196,12 @@ func (api headscaleV1APIServer) SetTags(
|
||||
|
||||
for _, tag := range request.GetTags() {
|
||||
if strings.Index(tag, "tag:") != 0 {
|
||||
return &v1.SetTagsResponse{Machine: nil, Error: &v1.Error{
|
||||
Status: 400,
|
||||
Message: "Invalid tag detected. Each tag must start with the string 'tag:'",
|
||||
}}, nil
|
||||
return &v1.SetTagsResponse{
|
||||
Machine: nil,
|
||||
}, status.Error(
|
||||
codes.InvalidArgument,
|
||||
"Invalid tag detected. Each tag must start with the string 'tag:'",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user