Add statistics

This commit is contained in:
2021-04-20 10:28:03 +02:00
parent 69de9ba8da
commit 10e940126d
6 changed files with 55 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import (
"flag"
"fmt"
"github.com/maride/afl-transmit/logistic"
"github.com/maride/afl-transmit/stats"
"io"
"io/ioutil"
"log"
@@ -82,6 +83,9 @@ func handle(conn net.Conn, outputDirectory string) {
log.Printf("Encountered error processing packet from %s: %s", conn.RemoteAddr().String(), unpackErr)
}
// Push read bytes to stats
stats.PushStat(stats.Stat{ReceivedBytes: uint64(len(cont))})
return
} else {
// We encountered an error on that connection

View File

@@ -2,6 +2,7 @@ package net
import (
"fmt"
"github.com/maride/afl-transmit/stats"
"log"
"net"
"regexp"
@@ -44,12 +45,15 @@ func (p *Peer) SendToPeer(content []byte) {
}
// Send
_, writeErr := tcpConn.Write(content)
written, writeErr := tcpConn.Write(content)
if writeErr != nil {
log.Printf("Unable to write to peer %s: %s", tcpConn.RemoteAddr().String(), writeErr)
return
}
// Push written bytes to stats
stats.PushStat(stats.Stat{SentBytes: uint64(written)})
// Close connection
tcpConn.Close()
}