Allow node IDs with spaces/dashes in config. Use dashes in GUI. (ref #230)
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"reflect"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"code.google.com/p/go.crypto/bcrypt"
|
||||
"github.com/calmh/syncthing/logger"
|
||||
@@ -181,6 +182,14 @@ func Load(rd io.Reader, myID string) (Configuration, error) {
|
||||
cfg.Repositories = []RepositoryConfiguration{}
|
||||
}
|
||||
|
||||
// Sanitize node IDs
|
||||
for i := range cfg.Nodes {
|
||||
node := &cfg.Nodes[i]
|
||||
// Strip spaces and dashes
|
||||
node.NodeID = strings.Replace(node.NodeID, "-", "", -1)
|
||||
node.NodeID = strings.Replace(node.NodeID, " ", "", -1)
|
||||
}
|
||||
|
||||
// Check for missing, bad or duplicate repository ID:s
|
||||
var seenRepos = map[string]*RepositoryConfiguration{}
|
||||
var uniqueCounter int
|
||||
@@ -196,6 +205,13 @@ func Load(rd io.Reader, myID string) (Configuration, error) {
|
||||
repo.ID = "default"
|
||||
}
|
||||
|
||||
for i := range repo.Nodes {
|
||||
node := &repo.Nodes[i]
|
||||
// Strip spaces and dashes
|
||||
node.NodeID = strings.Replace(node.NodeID, "-", "", -1)
|
||||
node.NodeID = strings.Replace(node.NodeID, " ", "", -1)
|
||||
}
|
||||
|
||||
if seen, ok := seenRepos[repo.ID]; ok {
|
||||
l.Warnf("Multiple repositories with ID %q; disabling", repo.ID)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user