From 479712cdc53a75998ec07aa0a9c32b5cbdedadbb Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Thu, 27 Jan 2022 09:36:54 +0100 Subject: [PATCH] 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. --- cmd/stdiscosrv/main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/stdiscosrv/main.go b/cmd/stdiscosrv/main.go index f1e96e065..5c22fe83d 100644 --- a/cmd/stdiscosrv/main.go +++ b/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: