mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	Record session uptime (purely for the admin socket)
This commit is contained in:
		
							parent
							
								
									b2513fce56
								
							
						
					
					
						commit
						78eb40cbad
					
				
					 4 changed files with 6 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -162,6 +162,7 @@ func (a *AdminSocket) Init(c *yggdrasil.Core, state *config.NodeState, log *log.
 | 
			
		|||
				"bytes_sent":    s.BytesSent,
 | 
			
		||||
				"bytes_recvd":   s.BytesRecvd,
 | 
			
		||||
				"mtu":           s.MTU,
 | 
			
		||||
				"uptime":        s.Uptime.Seconds(),
 | 
			
		||||
				"was_mtu_fixed": s.WasMTUFixed,
 | 
			
		||||
				"box_pub_key":   s.PublicKey,
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -89,6 +89,7 @@ type Session struct {
 | 
			
		|||
	BytesSent   uint64
 | 
			
		||||
	BytesRecvd  uint64
 | 
			
		||||
	MTU         uint16
 | 
			
		||||
	Uptime      time.Duration
 | 
			
		||||
	WasMTUFixed bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -216,6 +217,7 @@ func (c *Core) GetSessions() []Session {
 | 
			
		|||
				MTU:         sinfo.getMTU(),
 | 
			
		||||
				BytesSent:   sinfo.bytesSent,
 | 
			
		||||
				BytesRecvd:  sinfo.bytesRecvd,
 | 
			
		||||
				Uptime:      time.Now().Sub(sinfo.timeOpened),
 | 
			
		||||
				WasMTUFixed: sinfo.wasMTUFixed,
 | 
			
		||||
			}
 | 
			
		||||
			copy(session.PublicKey[:], sinfo.theirPermPub[:])
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,6 +34,7 @@ type sessionInfo struct {
 | 
			
		|||
	theirMTU       uint16                   //
 | 
			
		||||
	myMTU          uint16                   //
 | 
			
		||||
	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
 | 
			
		||||
	mtuTime        time.Time                // time myMTU was last changed
 | 
			
		||||
	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.myMTU = 1280
 | 
			
		||||
	now := time.Now()
 | 
			
		||||
	sinfo.timeOpened = now
 | 
			
		||||
	sinfo.time = now
 | 
			
		||||
	sinfo.mtuTime = now
 | 
			
		||||
	sinfo.pingTime = now
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue