mirror of
https://github.com/PeernetOfficial/Cmd.git
synced 2026-07-17 02:47:52 +01:00
Add NAT flag, User Agent, Port internal/external to output
This commit is contained in:
@@ -138,7 +138,12 @@ func userCommands() {
|
||||
if peer.IsRootPeer {
|
||||
info = " [root peer]"
|
||||
}
|
||||
fmt.Printf("* %s%s\n%s Packets sent: %d\n Packets received: %d\n\n", hex.EncodeToString(peer.PublicKey.SerializeCompressed()), info, textPeerConnections(peer), peer.StatsPacketSent, peer.StatsPacketReceived)
|
||||
if peer.IsBehindNAT() {
|
||||
info += " [NAT]"
|
||||
}
|
||||
userAgent := strings.ToValidUTF8(peer.UserAgent, "?")
|
||||
|
||||
fmt.Printf("* %s%s\n User Agent: %s\n\n%s Packets sent: %d\n Packets received: %d\n\n", hex.EncodeToString(peer.PublicKey.SerializeCompressed()), info, userAgent, textPeerConnections(peer), peer.StatsPacketSent, peer.StatsPacketReceived)
|
||||
}
|
||||
|
||||
case "chat all", "chat":
|
||||
@@ -196,6 +201,9 @@ func userCommands() {
|
||||
if peer.IsRootPeer {
|
||||
flagsA = "R"
|
||||
}
|
||||
if peer.IsBehindNAT() {
|
||||
flagsA += "N"
|
||||
}
|
||||
fmt.Printf("%-66s %-8d %-8d %-35s %-6s %-6s\n", hex.EncodeToString(peer.PublicKey.SerializeCompressed()), peer.StatsPacketSent, peer.StatsPacketReceived, addressA, flagsA, rttA)
|
||||
}
|
||||
|
||||
@@ -340,7 +348,7 @@ func textPeerConnections(peer *core.PeerInfo) (text string) {
|
||||
|
||||
sort.Strings(listAdapters)
|
||||
|
||||
text += " Status Local -> Remote Last Packet In Last Packet Out RTT \n"
|
||||
text += " Status Local -> Remote Last Packet In Last Packet Out RTT Port I Port E \n"
|
||||
|
||||
for _, adapterName := range listAdapters {
|
||||
text += " -- adapter '" + adapterName + "' --\n"
|
||||
@@ -352,7 +360,13 @@ func textPeerConnections(peer *core.PeerInfo) (text string) {
|
||||
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)
|
||||
|
||||
portEA := ""
|
||||
if c.PortExternal > 0 {
|
||||
portEA = strconv.Itoa(int(c.PortExternal))
|
||||
}
|
||||
|
||||
text += fmt.Sprintf(" %-9s %-50s -> %-50s %-19s %-19s %-6s %-7d %-7s \n", connectionStatusToA(c.Status), listenAddress.String(), addressToA(c.Address), c.LastPacketIn.Format(dateFormat), c.LastPacketOut.Format(dateFormat), rttA, c.PortInternal, portEA)
|
||||
}
|
||||
|
||||
list, _ = mapConnectionsI[adapterName]
|
||||
@@ -362,7 +376,13 @@ func textPeerConnections(peer *core.PeerInfo) (text string) {
|
||||
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)
|
||||
|
||||
portEA := ""
|
||||
if c.PortExternal > 0 {
|
||||
portEA = strconv.Itoa(int(c.PortExternal))
|
||||
}
|
||||
|
||||
text += fmt.Sprintf(" %-9s %-50s -> %-50s %-19s %-19s %-6s %-7d %-7s \n", connectionStatusToA(c.Status), listenAddress.String(), addressToA(c.Address), c.LastPacketIn.Format(dateFormat), c.LastPacketOut.Format(dateFormat), rttA, c.PortInternal, portEA)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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-20210503120507-f3c9d5e17fcf
|
||||
require github.com/PeernetOfficial/core v0.0.0-20210503231311-0fe2ce60ec21
|
||||
|
||||
4
go.sum
4
go.sum
@@ -1,5 +1,5 @@
|
||||
github.com/PeernetOfficial/core v0.0.0-20210503120507-f3c9d5e17fcf h1:AxpUZWHwtdG1f57NeUISVNXl+9ERtDBHzlXU58z1KGg=
|
||||
github.com/PeernetOfficial/core v0.0.0-20210503120507-f3c9d5e17fcf/go.mod h1:aixWDMb5EZsrqSwKPVrOyfIp3yZTvvQPEvlj3lncjiA=
|
||||
github.com/PeernetOfficial/core v0.0.0-20210503231311-0fe2ce60ec21 h1:2T7ctkpdee7HvHv1eZrw+jkASIX+pQ1El8RmsnqlAmQ=
|
||||
github.com/PeernetOfficial/core v0.0.0-20210503231311-0fe2ce60ec21/go.mod h1:aixWDMb5EZsrqSwKPVrOyfIp3yZTvvQPEvlj3lncjiA=
|
||||
github.com/PeernetOfficial/core/dht v0.0.0-20210425014452-611dfa3b1ce9 h1:kcjoWZl9GZ9uSajS6t0tiKDpaatUQ64tl3OqXPc+YsY=
|
||||
github.com/PeernetOfficial/core/dht v0.0.0-20210425014452-611dfa3b1ce9/go.mod h1:sb2H21VIVTohCXVrDFo/Skl2tN8Yzba+MXSS6NgCYXw=
|
||||
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
|
||||
|
||||
Reference in New Issue
Block a user