Expose connection type and relay status in the UI
This commit is contained in:
@@ -7,11 +7,17 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"net"
|
||||
|
||||
"github.com/syncthing/protocol"
|
||||
)
|
||||
|
||||
type IntermediateConnection struct {
|
||||
Conn *tls.Conn
|
||||
ConnType ConnectionType
|
||||
}
|
||||
|
||||
type Connection struct {
|
||||
net.Conn
|
||||
protocol.Connection
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user