mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-22 21:10:29 +00:00
Record session uptime (purely for the admin socket)
This commit is contained in:
parent
b2513fce56
commit
78eb40cbad
@ -200,7 +200,7 @@ func main() {
|
|||||||
if !keysOrdered {
|
if !keysOrdered {
|
||||||
for k := range slv.(map[string]interface{}) {
|
for k := range slv.(map[string]interface{}) {
|
||||||
if !*verbose {
|
if !*verbose {
|
||||||
if k == "box_pub_key" || k == "box_sig_key" || k == "nodeinfo" {
|
if k == "box_pub_key" || k == "box_sig_key" || k == "nodeinfo" || k == "was_mtu_fixed" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,6 +162,7 @@ func (a *AdminSocket) Init(c *yggdrasil.Core, state *config.NodeState, log *log.
|
|||||||
"bytes_sent": s.BytesSent,
|
"bytes_sent": s.BytesSent,
|
||||||
"bytes_recvd": s.BytesRecvd,
|
"bytes_recvd": s.BytesRecvd,
|
||||||
"mtu": s.MTU,
|
"mtu": s.MTU,
|
||||||
|
"uptime": s.Uptime.Seconds(),
|
||||||
"was_mtu_fixed": s.WasMTUFixed,
|
"was_mtu_fixed": s.WasMTUFixed,
|
||||||
"box_pub_key": s.PublicKey,
|
"box_pub_key": s.PublicKey,
|
||||||
}
|
}
|
||||||
|
@ -89,6 +89,7 @@ type Session struct {
|
|||||||
BytesSent uint64
|
BytesSent uint64
|
||||||
BytesRecvd uint64
|
BytesRecvd uint64
|
||||||
MTU uint16
|
MTU uint16
|
||||||
|
Uptime time.Duration
|
||||||
WasMTUFixed bool
|
WasMTUFixed bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,6 +217,7 @@ func (c *Core) GetSessions() []Session {
|
|||||||
MTU: sinfo.getMTU(),
|
MTU: sinfo.getMTU(),
|
||||||
BytesSent: sinfo.bytesSent,
|
BytesSent: sinfo.bytesSent,
|
||||||
BytesRecvd: sinfo.bytesRecvd,
|
BytesRecvd: sinfo.bytesRecvd,
|
||||||
|
Uptime: time.Now().Sub(sinfo.timeOpened),
|
||||||
WasMTUFixed: sinfo.wasMTUFixed,
|
WasMTUFixed: sinfo.wasMTUFixed,
|
||||||
}
|
}
|
||||||
copy(session.PublicKey[:], sinfo.theirPermPub[:])
|
copy(session.PublicKey[:], sinfo.theirPermPub[:])
|
||||||
|
@ -34,6 +34,7 @@ type sessionInfo struct {
|
|||||||
theirMTU uint16 //
|
theirMTU uint16 //
|
||||||
myMTU uint16 //
|
myMTU uint16 //
|
||||||
wasMTUFixed bool // Was the MTU fixed by a receive error?
|
wasMTUFixed bool // Was the MTU fixed by a receive error?
|
||||||
|
timeOpened time.Time // Time the sessino was opened
|
||||||
time time.Time // Time we last received a packet
|
time time.Time // Time we last received a packet
|
||||||
mtuTime time.Time // time myMTU was last changed
|
mtuTime time.Time // time myMTU was last changed
|
||||||
pingTime time.Time // time the first ping was sent since the last received packet
|
pingTime time.Time // time the first ping was sent since the last received packet
|
||||||
@ -284,6 +285,7 @@ func (ss *sessions) createSession(theirPermKey *crypto.BoxPubKey) *sessionInfo {
|
|||||||
sinfo.theirMTU = 1280
|
sinfo.theirMTU = 1280
|
||||||
sinfo.myMTU = 1280
|
sinfo.myMTU = 1280
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
sinfo.timeOpened = now
|
||||||
sinfo.time = now
|
sinfo.time = now
|
||||||
sinfo.mtuTime = now
|
sinfo.mtuTime = now
|
||||||
sinfo.pingTime = now
|
sinfo.pingTime = now
|
||||||
|
Loading…
Reference in New Issue
Block a user