Merge pull request #1600 from syncthing/conns

Change /rest/system/connections output (fixes #1487)
This commit is contained in:
Jakob Borg 2015-04-07 14:29:40 +02:00
commit ab25cd09ed

View File

@ -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()