mirror of
https://github.com/PeernetOfficial/Cmd.git
synced 2026-07-18 19:37:51 +01:00
Add RTT to output
This commit is contained in:
@@ -167,13 +167,17 @@ func userCommands() {
|
||||
fmt.Printf("%-35s %s\n", address.String(), multicastIP.String())
|
||||
}
|
||||
|
||||
fmt.Printf("\nPeer ID Sent Received IP \n")
|
||||
fmt.Printf("\nPeer ID Sent Received IP RTT \n")
|
||||
for _, peer := range core.PeerlistGet() {
|
||||
addressA := "N/A"
|
||||
rttA := "N/A"
|
||||
if connectionsActive := peer.GetConnections(true); len(connectionsActive) > 0 {
|
||||
addressA = connectionsActive[0].Address.String()
|
||||
addressA = addressToA(connectionsActive[0].Address)
|
||||
}
|
||||
fmt.Printf("%-66s %-8d %-8d %-30s \n", hex.EncodeToString(peer.PublicKey.SerializeCompressed()), peer.StatsPacketSent, peer.StatsPacketReceived, addressA)
|
||||
if rtt := peer.GetRTT(); rtt > 0 {
|
||||
rttA = rtt.Round(time.Millisecond).String()
|
||||
}
|
||||
fmt.Printf("%-66s %-8d %-8d %-35s %-6s \n", hex.EncodeToString(peer.PublicKey.SerializeCompressed()), peer.StatsPacketSent, peer.StatsPacketReceived, addressA, rttA)
|
||||
}
|
||||
|
||||
fmt.Printf("\n")
|
||||
@@ -316,7 +320,7 @@ func textPeerConnections(peer *core.PeerInfo) (text string) {
|
||||
|
||||
sort.Strings(listAdapters)
|
||||
|
||||
text += " Status Local -> Remote Last Packet In Last Packet Out \n"
|
||||
text += " Status Local -> Remote Last Packet In Last Packet Out RTT \n"
|
||||
|
||||
for _, adapterName := range listAdapters {
|
||||
text += " -- adapter '" + adapterName + "' --\n"
|
||||
@@ -324,13 +328,21 @@ func textPeerConnections(peer *core.PeerInfo) (text string) {
|
||||
list, _ := mapConnectionsA[adapterName]
|
||||
for _, c := range list {
|
||||
listenAddress, _, _ := c.Network.GetListen()
|
||||
text += fmt.Sprintf(" %-9s %-50s -> %-50s %-19s %-19s\n", connectionStatusToA(c.Status), listenAddress.String(), addressToA(c.Address), c.LastPacketIn.Format(dateFormat), c.LastPacketOut.Format(dateFormat))
|
||||
rttA := "N/A"
|
||||
if c.RoundTripTime > 0 {
|
||||
rttA = c.RoundTripTime.Round(time.Millisecond).String()
|
||||
}
|
||||
text += fmt.Sprintf(" %-9s %-50s -> %-50s %-19s %-19s %-6s \n", connectionStatusToA(c.Status), listenAddress.String(), addressToA(c.Address), c.LastPacketIn.Format(dateFormat), c.LastPacketOut.Format(dateFormat), rttA)
|
||||
}
|
||||
|
||||
list, _ = mapConnectionsI[adapterName]
|
||||
for _, c := range list {
|
||||
listenAddress, _, _ := c.Network.GetListen()
|
||||
text += fmt.Sprintf(" %-9s %-50s -> %-50s %-19s %-19s\n", connectionStatusToA(c.Status), listenAddress.String(), addressToA(c.Address), c.LastPacketIn.Format(dateFormat), c.LastPacketOut.Format(dateFormat))
|
||||
rttA := "N/A"
|
||||
if c.RoundTripTime > 0 {
|
||||
rttA = c.RoundTripTime.Round(time.Millisecond).String()
|
||||
}
|
||||
text += fmt.Sprintf(" %-9s %-50s -> %-50s %-19s %-19s %-6s \n", connectionStatusToA(c.Status), listenAddress.String(), addressToA(c.Address), c.LastPacketIn.Format(dateFormat), c.LastPacketOut.Format(dateFormat), rttA)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
go.mod
2
go.mod
@@ -2,4 +2,4 @@ module github.com/PeernetOfficial/Cmd
|
||||
|
||||
go 1.16
|
||||
|
||||
require github.com/PeernetOfficial/core v0.0.0-20210418195030-00db57aed8e9
|
||||
require github.com/PeernetOfficial/core v0.0.0-20210419133214-8bb1a3bdf767
|
||||
|
||||
4
go.sum
4
go.sum
@@ -1,5 +1,5 @@
|
||||
github.com/PeernetOfficial/core v0.0.0-20210418195030-00db57aed8e9 h1:fGdNCh5jtHDinuZcY9s96QxcrMtqFIlObKb06wRVM98=
|
||||
github.com/PeernetOfficial/core v0.0.0-20210418195030-00db57aed8e9/go.mod h1:D5dvzEaJ1Bg8slj35NExK6w6Q/2yEPbh4QyczY5tb14=
|
||||
github.com/PeernetOfficial/core v0.0.0-20210419133214-8bb1a3bdf767 h1:82MFLQPr0xbV9kBw/8z/tuurR3zKTom0XOaxmaEwYws=
|
||||
github.com/PeernetOfficial/core v0.0.0-20210419133214-8bb1a3bdf767/go.mod h1:D5dvzEaJ1Bg8slj35NExK6w6Q/2yEPbh4QyczY5tb14=
|
||||
github.com/PeernetOfficial/core/dht v0.0.0-20210410140655-6a9d16717779 h1:P21VQkgh7qrNuXG/tiXC56BNv2cjGI6z/CYpfrCAVCk=
|
||||
github.com/PeernetOfficial/core/dht v0.0.0-20210410140655-6a9d16717779/go.mod h1:sb2H21VIVTohCXVrDFo/Skl2tN8Yzba+MXSS6NgCYXw=
|
||||
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
|
||||
|
||||
Reference in New Issue
Block a user