Merging flush

master
Jean-Louis Huynen 2019-03-12 12:18:08 +00:00
commit c533aa7f58
1 changed files with 11 additions and 7 deletions

View File

@ -51,8 +51,12 @@ var jobQ chan d4tls.TLSSession
var bufferedPagesPerConnection = flag.Int("mbpc", 16, "Max Buffered Pages per Connection.") var bufferedPagesPerConnection = flag.Int("mbpc", 16, "Max Buffered Pages per Connection.")
var bufferedPagesTotal = flag.Int("mbpt", 1024, "Max Total Buffered Pages.") var bufferedPagesTotal = flag.Int("mbpt", 1024, "Max Total Buffered Pages.")
const closeTimeout time.Duration = time.Hour * 24 // Closing inactive: TODO: from CLI // flushing
const timeout time.Duration = time.Minute * 5 // Pending bytes: TODO: from CLI var flushEvery = flag.Int("flush", 5000, "Flush every N packets")
var dtf, _ = time.ParseDuration("5m")
var dtc, _ = time.ParseDuration("48h")
var flushTf = flag.Duration("flushtf", dtf, "Flush older than t")
var flushTc = flag.Duration("flushtc", dtc, "Close older that t")
var assemblerOptions = reassembly.AssemblerOptions{ var assemblerOptions = reassembly.AssemblerOptions{
MaxBufferedPagesPerConnection: *bufferedPagesPerConnection, MaxBufferedPagesPerConnection: *bufferedPagesPerConnection,
@ -231,11 +235,9 @@ func (t *tcpStream) ReassembledSG(sg reassembly.ScatterGather, ac reassembly.Ass
} }
} }
// If the handshake is considered finished and we have not yet outputted it we ship it to output.
if t.tlsSession.HandshakeComplete() && !t.queued { if t.tlsSession.HandshakeComplete() && !t.queued {
t.queueSession() t.queueSession()
} }
} }
} }
} }
@ -377,9 +379,11 @@ func main() {
} }
assembler.AssembleWithContext(packet.NetworkLayer().NetworkFlow(), tcp, &c) assembler.AssembleWithContext(packet.NetworkLayer().NetworkFlow(), tcp, &c)
} }
//ref := packet.Metadata().CaptureInfo.Timestamp if count%*flushEvery == 0{
//flushed, closed := assembler.FlushWithOptions(reassembly.FlushOptions{T: ref.Add(time.Minute * 30), TC: ref.Add(time.Minute * 5)}) ref := packet.Metadata().CaptureInfo.Timestamp
//Debug("Forced flush: %d flushed, %d closed (%s)", flushed, closed, ref) flushed, closed := assembler.FlushWithOptions(reassembly.FlushOptions{T: ref.Add(-*flushTf), TC: ref.Add(-*flushTc)})
Debug("Forced flush: %d flushed, %d closed (%s)", flushed, closed, ref)
}
} }
} }