mirror of
https://github.com/maride/afl-transmit.git
synced 2026-04-14 19:15:45 +00:00
Add statistics
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user