mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-27 12:05:26 +00: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),
|
fmt.Sprintf("Error while sending tags to headscale: %s", err),
|
||||||
output,
|
output,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp != nil {
|
if resp != nil {
|
||||||
|
12
grpcv1.go
12
grpcv1.go
@ -8,6 +8,8 @@ import (
|
|||||||
|
|
||||||
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
"tailscale.com/tailcfg"
|
"tailscale.com/tailcfg"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -194,10 +196,12 @@ func (api headscaleV1APIServer) SetTags(
|
|||||||
|
|
||||||
for _, tag := range request.GetTags() {
|
for _, tag := range request.GetTags() {
|
||||||
if strings.Index(tag, "tag:") != 0 {
|
if strings.Index(tag, "tag:") != 0 {
|
||||||
return &v1.SetTagsResponse{Machine: nil, Error: &v1.Error{
|
return &v1.SetTagsResponse{
|
||||||
Status: 400,
|
Machine: nil,
|
||||||
Message: "Invalid tag detected. Each tag must start with the string 'tag:'",
|
}, status.Error(
|
||||||
}}, nil
|
codes.InvalidArgument,
|
||||||
|
"Invalid tag detected. Each tag must start with the string 'tag:'",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user