diff --git a/gui/default/index.html b/gui/default/index.html
index ac84df04c..d3dae0553 100644
--- a/gui/default/index.html
+++ b/gui/default/index.html
@@ -848,6 +848,14 @@
+
Allowed Networks |
diff --git a/lib/model/model.go b/lib/model/model.go
index 95011b657..b6d1910cc 100644
--- a/lib/model/model.go
+++ b/lib/model/model.go
@@ -712,15 +712,28 @@ func (m *model) UsageReportingStats(report *contract.Report, version int, previe
}
}
-type ConnectionInfo struct {
- protocol.Statistics
+type ConnectionStats struct {
+ protocol.Statistics // Total for primary + secondaries
+
Connected bool `json:"connected"`
Paused bool `json:"paused"`
- Address string `json:"address"`
ClientVersion string `json:"clientVersion"`
- Type string `json:"type"`
- IsLocal bool `json:"isLocal"`
- Crypto string `json:"crypto"`
+
+ Address string `json:"address"` // mirror values from Primary, for compatibility with <1.24.0
+ Type string `json:"type"` // mirror values from Primary, for compatibility with <1.24.0
+ IsLocal bool `json:"isLocal"` // mirror values from Primary, for compatibility with <1.24.0
+ Crypto string `json:"crypto"` // mirror values from Primary, for compatibility with <1.24.0
+
+ Primary ConnectionInfo `json:"primary,omitempty"`
+ Secondary []ConnectionInfo `json:"secondary,omitempty"`
+}
+
+type ConnectionInfo struct {
+ protocol.Statistics
+ Address string `json:"address"`
+ Type string `json:"type"`
+ IsLocal bool `json:"isLocal"`
+ Crypto string `json:"crypto"`
}
// NumConnections returns the current number of active connected devices.
@@ -737,30 +750,61 @@ func (m *model) ConnectionStats() map[string]interface{} {
res := make(map[string]interface{})
devs := m.cfg.Devices()
- conns := make(map[string]ConnectionInfo, len(devs))
+ conns := make(map[string]ConnectionStats, len(devs))
for device, deviceCfg := range devs {
+ if device == m.id {
+ continue
+ }
hello := m.helloMessages[device]
versionString := hello.ClientVersion
if hello.ClientName != "syncthing" {
versionString = hello.ClientName + " " + hello.ClientVersion
}
- ci := ConnectionInfo{
- ClientVersion: strings.TrimSpace(versionString),
+ connIDs, ok := m.deviceConns[device]
+ cs := ConnectionStats{
+ Connected: ok,
Paused: deviceCfg.Paused,
+ ClientVersion: strings.TrimSpace(versionString),
}
- if connIDs, ok := m.deviceConns[device]; ok {
- conn := m.conns[connIDs[0]] // XXX: only accounts primary, should account all
- ci.Type = conn.Type()
- ci.IsLocal = conn.IsLocal()
- ci.Crypto = conn.Crypto()
- ci.Connected = ok
- ci.Statistics = conn.Statistics()
+ if ok {
+ conn := m.conns[connIDs[0]]
+
+ cs.Primary.Type = conn.Type()
+ cs.Primary.IsLocal = conn.IsLocal()
+ cs.Primary.Crypto = conn.Crypto()
+ cs.Primary.Statistics = conn.Statistics()
if addr := conn.RemoteAddr(); addr != nil {
- ci.Address = addr.String()
+ cs.Primary.Address = addr.String()
+ }
+
+ cs.Type = cs.Primary.Type
+ cs.IsLocal = cs.Primary.IsLocal
+ cs.Crypto = cs.Primary.Crypto
+ cs.Address = cs.Primary.Address
+ cs.Statistics = cs.Primary.Statistics
+
+ for _, connID := range connIDs[1:] {
+ conn = m.conns[connID]
+ sec := ConnectionInfo{
+ Statistics: conn.Statistics(),
+ Address: conn.RemoteAddr().String(),
+ Type: conn.Type(),
+ IsLocal: conn.IsLocal(),
+ Crypto: conn.Crypto(),
+ }
+ if sec.At.After(cs.At) {
+ cs.At = sec.At
+ }
+ if sec.StartedAt.Before(cs.StartedAt) {
+ cs.StartedAt = sec.StartedAt
+ }
+ cs.InBytesTotal += sec.InBytesTotal
+ cs.OutBytesTotal += sec.OutBytesTotal
+ cs.Secondary = append(cs.Secondary, sec)
}
}
- conns[device.String()] = ci
+ conns[device.String()] = cs
}
res["connections"] = conns
@@ -2291,7 +2335,11 @@ func (m *model) AddConnection(conn protocol.Connection, hello protocol.Hello) {
m.evLogger.Log(events.DeviceConnected, event)
- l.Infof(`Device %s client is "%s %s" named "%s" at %s`, deviceID, hello.ClientName, hello.ClientVersion, hello.DeviceName, conn)
+ if len(m.deviceConns[deviceID]) == 1 {
+ l.Infof(`Device %s client is "%s %s" named "%s" at %s`, deviceID.Short(), hello.ClientName, hello.ClientVersion, hello.DeviceName, conn)
+ } else {
+ l.Infof(`Additional connection #%d for device %s at %s`, len(m.deviceConns[deviceID]), deviceID.Short(), conn)
+ }
m.pmut.Unlock()
diff --git a/test/h1/config.xml b/test/h1/config.xml
index 1cbd6f7c2..41612af97 100644
--- a/test/h1/config.xml
+++ b/test/h1/config.xml
@@ -1,18 +1,12 @@
-
- basic
+
+ fake
-
-
-
-
-
-
1
3600
@@ -58,6 +52,7 @@
0
false
0
+ 0
tcp://127.0.0.1:22002
@@ -68,7 +63,7 @@
0
false
0
- 4
+ 9
127.0.0.1:8081
@@ -184,6 +179,7 @@
0
false
0
+ 0
diff --git a/test/h2/config.xml b/test/h2/config.xml
index ae7cc494a..d59c64fc9 100644
--- a/test/h2/config.xml
+++ b/test/h2/config.xml
@@ -1,6 +1,6 @@
- basic
+ fake
@@ -16,7 +16,7 @@
basic
- 1
+ 8
0
0
random
@@ -31,7 +31,7 @@
.stfolder
false
0
- 2
+ 8
false
standard
standard
@@ -55,7 +55,7 @@
0
false
0
- 4
+ 9
tcp://127.0.0.1:22002
|