Skip to content

Commit

Permalink
added flagid caching (and fixed flaglifetime bug)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfelber committed Mar 9, 2024
1 parent 1a3e75c commit abdd828
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions services/go-importer/cmd/assembler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ while processing one file (since PCAP-over-IP treats whole connection as one pca

var g_db db.Database

// flagid caching (only once per tick)
var flagids []db.Flagid
var flagidUpdate int64 = 0

// TODO; FIXME; RDJ; this is kinda gross, but this is PoC level code
func reassemblyCallback(entry db.FlowEntry) {
// Parsing HTTP will decode encodings to a plaintext format
Expand All @@ -78,9 +82,14 @@ func reassemblyCallback(entry db.FlowEntry) {

//Apply flagid in / out
if *flagid {
flagids, err := g_db.GetFlagids(flaglifetime)
if err != nil {
log.Fatal(err)
unix := time.Now().Unix()
if flagidUpdate+int64(ticklength) < unix {
flagidUpdate = unix
zwi, err := g_db.GetFlagids(flaglifetime)
if err != nil {
log.Fatal(err)
}
flagids = zwi
}
ApplyFlagids(&entry, flagids)
}
Expand Down Expand Up @@ -178,10 +187,14 @@ func main() {
if err != nil {
log.Println("Error: ", err)
} else {
flaglifetime = zwi * ticklength
flaglifetime = zwi
}
}

if ticklength != -1 && flaglifetime != -1 {
flaglifetime *= ticklength
}

// If no mongo DB was supplied, try the env variable
if *mongodb == "" {
*mongodb = os.Getenv("TULIP_MONGO")
Expand Down

0 comments on commit abdd828

Please sign in to comment.