multi: move label validation to rpc and simplify validation function

Previously labels with reserved prefixes were added to provide us
with a way to identify automatically dispatched loops. This commit moves
the validation of these labels to the rpc level so that it will only
apply to user-initiated swaps.
This commit is contained in:
carla 2020-10-12 13:34:52 +02:00
parent 15a400b411
commit 7b56804bbe
No known key found for this signature in database
GPG key ID: 4CA7FE54A6213C91
5 changed files with 16 additions and 21 deletions

View file

@ -2,6 +2,7 @@ package labels
import (
"errors"
"strings"
)
const (
@ -29,16 +30,10 @@ func Validate(label string) error {
return ErrLabelTooLong
}
// If the label is shorter than our reserved prefix, it cannot contain
// it.
if len(label) < len(Reserved) {
return nil
}
// Check if our label begins with our reserved prefix. We don't mind if
// it has our reserved prefix in another case, we just need to be able
// to reserve a subset of labels with this prefix.
if label[0:len(Reserved)] == Reserved {
if strings.HasPrefix(label, Reserved) {
return ErrReservedPrefix
}