mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-10 07:30:27 +00:00
Track TX/RX bytes over session and if MTU was adjusted, add to admin socket getSession
This commit is contained in:
parent
546c5f1412
commit
ec371af84f
@ -374,6 +374,9 @@ func (a *admin) getData_getSessions() []admin_nodeInfo {
|
||||
{"IP", net.IP(sinfo.theirAddr[:]).String()},
|
||||
{"coords", fmt.Sprint(sinfo.coords)},
|
||||
{"MTU", fmt.Sprint(sinfo.getMTU())},
|
||||
{"wasMTUFixed", fmt.Sprint(sinfo.wasMTUFixed)},
|
||||
{"bytesSent", fmt.Sprint(sinfo.bytesSent)},
|
||||
{"bytesRecvd", fmt.Sprint(sinfo.bytesRecvd)},
|
||||
}
|
||||
infos = append(infos, info)
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ type sessionInfo struct {
|
||||
myNonce boxNonce
|
||||
theirMTU uint16
|
||||
myMTU uint16
|
||||
wasMTUFixed bool // Was the MTU fixed by a receive error?
|
||||
time time.Time // Time we last received a packet
|
||||
coords []byte // coords of destination
|
||||
packet []byte // a buffered packet, sent immediately on ping/pong
|
||||
@ -32,6 +33,8 @@ type sessionInfo struct {
|
||||
mtuTime time.Time // time myMTU was last changed
|
||||
pingTime time.Time // time the first ping was sent since the last received packet
|
||||
pingSend time.Time // time the last ping was sent
|
||||
bytesSent uint64 // Bytes of real traffic sent in this session
|
||||
bytesRecvd uint64 // Bytes of real traffic received in this session
|
||||
}
|
||||
|
||||
type sessionPing struct {
|
||||
@ -384,6 +387,7 @@ func (sinfo *sessionInfo) doSend(bs []byte) {
|
||||
payload: payload,
|
||||
}
|
||||
packet := p.encode()
|
||||
sinfo.bytesSent += uint64(len(bs))
|
||||
sinfo.core.router.out(packet)
|
||||
}
|
||||
|
||||
@ -411,6 +415,7 @@ func (sinfo *sessionInfo) doRecv(p *wire_trafficPacket) {
|
||||
//sinfo.core.log.Println("DEBUG set MTU to:", sinfo.myMTU)
|
||||
sinfo.core.sessions.sendPingPong(sinfo, false)
|
||||
sinfo.mtuTime = time.Now()
|
||||
sinfo.wasMTUFixed = true
|
||||
}
|
||||
}
|
||||
go func() { sinfo.core.router.admin <- fixSessionMTU }()
|
||||
@ -427,5 +432,6 @@ func (sinfo *sessionInfo) doRecv(p *wire_trafficPacket) {
|
||||
go func() { sinfo.core.router.admin <- fixSessionMTU }()
|
||||
sinfo.updateNonce(&p.nonce)
|
||||
sinfo.time = time.Now()
|
||||
sinfo.bytesRecvd += uint64(len(bs))
|
||||
sinfo.core.router.recvPacket(bs, &sinfo.theirAddr, &sinfo.theirSubnet)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user