cmd/client/main.go | 2 +- cmd/client/stats.go | 4 +++- cmd/server/main.go | 8 ++++---- cmd/server/peer.go | 11 +++++++++++ cmd/server/stats.go | 12 ------------ diff --git a/cmd/client/main.go b/cmd/client/main.go index f33814f53bdf4e64756fc2e76774fd76a5548cf3427bf7740f98570d8a54ff01..118a7fed55b076517fd8339680307bfa1ad0c03d59dc976006d5903715de0d1e 100644 --- a/cmd/client/main.go +++ b/cmd/client/main.go @@ -362,7 +362,7 @@ if subtle.ConstantTimeCompare( tag[:vors.TagLen], buf[len(buf)-vors.TagLen:], ) != 1 { - log.Println("decrypt:", stream.name, "tag differs") + stream.stats.bads++ continue } pkt = buf[4 : len(buf)-vors.TagLen] diff --git a/cmd/client/stats.go b/cmd/client/stats.go index 24e3f9941f10d4499450c23f230b8c6cff529d1a11aa8014949caad63c1c81b4..795dfbf2b7fd73b556d31ebc13ab126930ddeeda6ea581b928b947cfd049f48a 100644 --- a/cmd/client/stats.go +++ b/cmd/client/stats.go @@ -30,6 +30,7 @@ type Stats struct { pkts int64 bytes uint64 + bads int64 lost int64 reorder int64 last time.Time @@ -62,9 +63,10 @@ GUI.DeleteView(name + "-vol") return case now = <-tick: s := fmt.Sprintf( - "%s | %s | L/R: %s / %s", + "%s | %s | B/L/R: %s/%s/%s", humanize.Comma(stats.pkts), humanize.IBytes(stats.bytes), + humanize.Comma(stats.bads), humanize.Comma(stats.lost), humanize.Comma(stats.reorder), ) diff --git a/cmd/server/main.go b/cmd/server/main.go index 17c9ce3daecaf66a17ffd27dc99ed892e04e60262e1f76e2e71f89ed98af2980..fd60e914b190568e27db7e55096cb07083e2813f65e07933b736316f0dd9c2fb 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -256,10 +256,11 @@ GUI.DeleteView(peer.name) return case now = <-tick: s := fmt.Sprintf( - "%s | Rx/Tx: %s / %s | %s / %s", + "%s | Rx/Tx/Bad: %s / %s / %s | %s / %s", peer.addr, humanize.Comma(stats.pktsRx), humanize.Comma(stats.pktsTx), + humanize.Comma(stats.bads), humanize.IBytes(stats.bytesRx), humanize.IBytes(stats.bytesTx), ) @@ -394,7 +395,7 @@ if n == 1 { continue } if n <= 4+vors.TagLen { - slog.Info("too small", "peer", peer.name, "len", n) + peer.stats.bads++ continue } @@ -415,8 +416,7 @@ if subtle.ConstantTimeCompare( tag[:vors.TagLen], buf[n-vors.TagLen:n], ) != 1 { - log.Println("decrypt:", peer.name, "tag differs") - slog.Info("MAC failed", "peer", peer.name, "len", n) + peer.stats.bads++ continue } diff --git a/cmd/server/peer.go b/cmd/server/peer.go index ef0693b6d86846ced607c9289f2ae6aecfea0e26e75588ed924d60460cced056..960d5b2dbbd225fb38e3b75d8b48415ca5db851368d359b25adbd3fecc0af8d1 100644 --- a/cmd/server/peer.go +++ b/cmd/server/peer.go @@ -4,10 +4,21 @@ import ( "log/slog" "net" "sync" + "time" "github.com/flynn/noise" vors "go.stargrave.org/vors/internal" ) + +type Stats struct { + pktsRx int64 + pktsTx int64 + bytesRx uint64 + bytesTx uint64 + bads int64 + last time.Time + alive chan struct{} +} type Peer struct { name string diff --git a/cmd/server/stats.go b/cmd/server/stats.go deleted file mode 100644 index 86c010e61dae851da0c8f5b7142e3039ada609d70023cbf5d13d778910d9ee97..0000000000000000000000000000000000000000 --- a/cmd/server/stats.go +++ /dev/null @@ -1,12 +0,0 @@ -package main - -import "time" - -type Stats struct { - pktsRx int64 - pktsTx int64 - bytesRx uint64 - bytesTx uint64 - last time.Time - alive chan struct{} -}