Improve logging and make linter happy

This commit is contained in:
Daniel
2023-07-21 16:05:57 +02:00
parent f0ebc6e72f
commit 07f4253e0b
12 changed files with 47 additions and 30 deletions

View File

@@ -142,6 +142,9 @@ func reportBandwidth(ctx context.Context, objs bpfObjects, bandwidthUpdates chan
case bandwidthUpdates <- update:
case <-ctx.Done():
return
default:
log.Warning("ebpf: bandwidth update queue is full, skipping rest of batch")
return
}
}
}

View File

@@ -8,6 +8,7 @@ import (
"fmt"
"net"
"sync/atomic"
"time"
"github.com/cilium/ebpf/link"
"github.com/cilium/ebpf/ringbuf"
@@ -112,6 +113,7 @@ func ConnectionListenerWorker(ctx context.Context, packets chan packet.Packet) e
Src: convertArrayToIPv4(event.Saddr, packet.IPVersion(event.IpVersion)),
Dst: convertArrayToIPv4(event.Daddr, packet.IPVersion(event.IpVersion)),
PID: int(event.Pid),
SeenAt: time.Now(),
})
if isEventValid(event) {
// DEBUG: