Expose connection type and relay status in the UI

This commit is contained in:
Audrius Butkevicius
2015-07-17 21:22:07 +01:00
parent 2c0f8dc546
commit 8f2db99c86
15 changed files with 183 additions and 123 deletions

View File

@@ -219,6 +219,7 @@ type ConnectionInfo struct {
protocol.Statistics
Address string
ClientVersion string
Type ConnectionType
}
func (info ConnectionInfo) MarshalJSON() ([]byte, error) {
@@ -227,6 +228,7 @@ func (info ConnectionInfo) MarshalJSON() ([]byte, error) {
"inBytesTotal": info.InBytesTotal,
"outBytesTotal": info.OutBytesTotal,
"address": info.Address,
"type": info.Type.String(),
"clientVersion": info.ClientVersion,
})
}
@@ -249,6 +251,7 @@ func (m *Model) ConnectionStats() map[string]interface{} {
}
if addr := m.conn[device].RemoteAddr(); addr != nil {
ci.Address = addr.String()
ci.Type = conn.Type
}
conns[device.String()] = ci
@@ -585,6 +588,7 @@ func (m *Model) ClusterConfig(deviceID protocol.DeviceID, cm protocol.ClusterCon
}
if conn, ok := m.conn[deviceID]; ok {
event["type"] = conn.Type.String()
addr := conn.RemoteAddr()
if addr != nil {
event["addr"] = addr.String()