mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 10:58:57 +00:00
Merge pull request #1600 from syncthing/conns
Change /rest/system/connections output (fixes #1487)
This commit is contained in:
commit
ab25cd09ed
@ -201,7 +201,7 @@ func (info ConnectionInfo) MarshalJSON() ([]byte, error) {
|
||||
}
|
||||
|
||||
// ConnectionStats returns a map with connection statistics for each connected device.
|
||||
func (m *Model) ConnectionStats() map[string]ConnectionInfo {
|
||||
func (m *Model) ConnectionStats() map[string]interface{} {
|
||||
type remoteAddrer interface {
|
||||
RemoteAddr() net.Addr
|
||||
}
|
||||
@ -209,7 +209,8 @@ func (m *Model) ConnectionStats() map[string]ConnectionInfo {
|
||||
m.pmut.RLock()
|
||||
m.fmut.RLock()
|
||||
|
||||
var res = make(map[string]ConnectionInfo)
|
||||
var res = make(map[string]interface{})
|
||||
conns := make(map[string]ConnectionInfo, len(m.protoConn))
|
||||
for device, conn := range m.protoConn {
|
||||
ci := ConnectionInfo{
|
||||
Statistics: conn.Statistics(),
|
||||
@ -219,9 +220,11 @@ func (m *Model) ConnectionStats() map[string]ConnectionInfo {
|
||||
ci.Address = nc.RemoteAddr().String()
|
||||
}
|
||||
|
||||
res[device.String()] = ci
|
||||
conns[device.String()] = ci
|
||||
}
|
||||
|
||||
res["connections"] = conns
|
||||
|
||||
m.fmut.RUnlock()
|
||||
m.pmut.RUnlock()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user