diff --git a/probe/endpoint/ebpf.go b/probe/endpoint/ebpf.go index f5604c62f..e77f61eac 100644 --- a/probe/endpoint/ebpf.go +++ b/probe/endpoint/ebpf.go @@ -2,7 +2,6 @@ package endpoint import ( "bufio" - "fmt" "net" "os" "os/exec" @@ -32,7 +31,8 @@ type ConnectionEvent struct { } type EbpfTracker struct { - Cmd *exec.Cmd + Cmd *exec.Cmd + Events []ConnectionEvent } func NewEbpfTracker(bccProgramPath string) *EbpfTracker { @@ -135,6 +135,13 @@ func (t *EbpfTracker) run() { DestPort: dPort, } - fmt.Println(e) + t.Events = append(t.Events, e) + } +} + +// WalkEvents - walk through the connectionEvents +func (t *EbpfTracker) WalkEvents(f func(ConnectionEvent)) { + for _, event := range t.Events { + f(event) } } diff --git a/probe/endpoint/ebpf/main.go b/probe/endpoint/ebpf/main.go index 2290c4def..92fcdbebd 100644 --- a/probe/endpoint/ebpf/main.go +++ b/probe/endpoint/ebpf/main.go @@ -16,7 +16,12 @@ func main() { os.Exit(1) } - time.Sleep(100 * time.Second) + // create some http connection within these 10 seconds + time.Sleep(10 * time.Second) + + tr.WalkEvents(func(e endpoint.ConnectionEvent) { + fmt.Println(e) + }) fmt.Println("done") }