Skip to content

Commit c533aa7

Browse files
committed
Merging flush
2 parents e8ea6cb + 65f173d commit c533aa7

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

d4-tlsf.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@ var jobQ chan d4tls.TLSSession
5151
var bufferedPagesPerConnection = flag.Int("mbpc", 16, "Max Buffered Pages per Connection.")
5252
var bufferedPagesTotal = flag.Int("mbpt", 1024, "Max Total Buffered Pages.")
5353

54-
const closeTimeout time.Duration = time.Hour * 24 // Closing inactive: TODO: from CLI
55-
const timeout time.Duration = time.Minute * 5 // Pending bytes: TODO: from CLI
54+
// flushing
55+
var flushEvery = flag.Int("flush", 5000, "Flush every N packets")
56+
var dtf, _ = time.ParseDuration("5m")
57+
var dtc, _ = time.ParseDuration("48h")
58+
var flushTf = flag.Duration("flushtf", dtf, "Flush older than t")
59+
var flushTc = flag.Duration("flushtc", dtc, "Close older that t")
5660

5761
var assemblerOptions = reassembly.AssemblerOptions{
5862
MaxBufferedPagesPerConnection: *bufferedPagesPerConnection,
@@ -231,11 +235,9 @@ func (t *tcpStream) ReassembledSG(sg reassembly.ScatterGather, ac reassembly.Ass
231235
}
232236
}
233237

234-
// If the handshake is considered finished and we have not yet outputted it we ship it to output.
235238
if t.tlsSession.HandshakeComplete() && !t.queued {
236239
t.queueSession()
237240
}
238-
239241
}
240242
}
241243
}
@@ -377,9 +379,11 @@ func main() {
377379
}
378380
assembler.AssembleWithContext(packet.NetworkLayer().NetworkFlow(), tcp, &c)
379381
}
380-
//ref := packet.Metadata().CaptureInfo.Timestamp
381-
//flushed, closed := assembler.FlushWithOptions(reassembly.FlushOptions{T: ref.Add(time.Minute * 30), TC: ref.Add(time.Minute * 5)})
382-
//Debug("Forced flush: %d flushed, %d closed (%s)", flushed, closed, ref)
382+
if count%*flushEvery == 0{
383+
ref := packet.Metadata().CaptureInfo.Timestamp
384+
flushed, closed := assembler.FlushWithOptions(reassembly.FlushOptions{T: ref.Add(-*flushTf), TC: ref.Add(-*flushTc)})
385+
Debug("Forced flush: %d flushed, %d closed (%s)", flushed, closed, ref)
386+
}
383387
}
384388
}
385389

0 commit comments

Comments
 (0)