Repository: syncthing/syncthing (language: go)

Issue:
Warn if two devices are introducers to each other
Derived from https://github.com/syncthing/syncthing/issues/8383

Whe remote is introducer and we are introducer to remote emit a warning, as this is at best confusing and preventing some config operations, at worst causing busyloops (#8383).


Discussion / hints:

Fix patch:
diff --git a/lib/config/deviceconfiguration.go b/lib/config/deviceconfiguration.go
index 3a85b09338e..65011f3b77a 100644
--- a/lib/config/deviceconfiguration.go
+++ b/lib/config/deviceconfiguration.go
@@ -7,6 +7,7 @@
 package config
 
 import (
+	"fmt"
 	"sort"
 )
 
@@ -65,3 +66,10 @@ func deduplicateObservedFoldersToMap(input []ObservedFolder) map[string]Observed
 
 	return output
 }
+
+func (cfg *DeviceConfiguration) Description() string {
+	if cfg.Name == "" {
+		return fmt.Sprintf("%s", cfg.DeviceID.Short())
+	}
+	return fmt.Sprintf("%s (%s)", cfg.Name, cfg.DeviceID.Short())
+}
diff --git a/lib/model/model.go b/lib/model/model.go
index 0aa5299858c..042a69d3dcf 100644
--- a/lib/model/model.go
+++ b/lib/model/model.go
@@ -1198,6 +1198,13 @@ func (m *model) ClusterConfig(deviceID protocol.DeviceID, cm protocol.ClusterCon
 		ccDeviceInfos[folder.ID] = info
 	}
 
+	for _, info := range ccDeviceInfos {
+		if deviceCfg.Introducer && info.local.Introducer {
+			l.Warnf("Remote %v is an introducer to us, and we are to them - only one should be introducer to the other, see https://docs.syncthing.net/users/introducer.html", deviceCfg.Description())
+		}
+		break
+	}
+
 	// Needs to happen outside of the fmut, as can cause CommitConfiguration
 	if deviceCfg.AutoAcceptFolders {
 		w, _ := m.cfg.Modify(func(cfg *config.Configuration) {


Test patch: