From bd99f6b4d67c386daf604c94999e5de72584f883 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Fri, 5 Jul 2024 17:00:54 +0530 Subject: bpf/usage: log to database --- cmd/redq/main.go | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'cmd') diff --git a/cmd/redq/main.go b/cmd/redq/main.go index d8b9b58..4231b52 100644 --- a/cmd/redq/main.go +++ b/cmd/redq/main.go @@ -1,17 +1,28 @@ package main import ( + "context" "log" "net" - redqbpf "sinanmohd.com/redq/bpf" + "github.com/jackc/pgx/v5" + "sinanmohd.com/redq/bpf" + "sinanmohd.com/redq/db" ) func main() { - iface, err := net.InterfaceByName("wlan0") - if err != nil { - log.Fatalf("lookup network: %s", err) - } + iface, err := net.InterfaceByName("wlan0") + if err != nil { + log.Fatalf("lookup network: %s", err) + } - redqbpf.Run(iface) + ctx := context.Background() + conn, err := pgx.Connect(ctx, "user=redq_ebpf dbname=redq_ebpf") + if err != nil { + log.Fatalf("connecting database: %s", err) + } + defer conn.Close(ctx) + queries := db.New(conn) + + bpf.Run(iface, queries, ctx) } -- cgit v1.2.3