Browse Source

cmd/stdiscosrv: Don't start replication listener without peers (fixes #8143) (#8144)

The intention was that if no peers are given, we shouldn't start the
listener. We did that anyway, because:

- splitting an empty string on comma returns a slice with one empty
  string in it
- parsing the empty string as a device ID returns the empty device ID

so we end up with a valid replication peer which is the empty device ID.
Jakob Borg 4 years ago
parent
commit
479712cdc5
1 changed files with 7 additions and 1 deletions
  1. 7 1
      cmd/stdiscosrv/main.go

+ 7 - 1
cmd/stdiscosrv/main.go

@@ -116,8 +116,11 @@ func main() {
 	var replicationDestinations []string
 	parts := strings.Split(replicationPeers, ",")
 	for _, part := range parts {
-		fields := strings.Split(part, "@")
+		if part == "" {
+			continue
+		}
 
+		fields := strings.Split(part, "@")
 		switch len(fields) {
 		case 2:
 			// This is an id@address specification. Grab the address for the
@@ -137,6 +140,9 @@ func main() {
 			if err != nil {
 				log.Fatalln("Parsing device ID:", err)
 			}
+			if id == protocol.EmptyDeviceID {
+				log.Fatalf("Missing device ID for peer in %q", part)
+			}
 			allowedReplicationPeers = append(allowedReplicationPeers, id)
 
 		default: