Browse Source

lib/config, lib/model: Warn about two-way introducer (fixes #8393) (#8395)

Simon Frei 3 years ago
parent
commit
3a6ebb8482
2 changed files with 15 additions and 0 deletions
  1. 8 0
      lib/config/deviceconfiguration.go
  2. 7 0
      lib/model/model.go

+ 8 - 0
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())
+}

+ 7 - 0
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) {