summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2024-07-05 17:00:54 +0530
committersinanmohd <sinan@sinanmohd.com>2024-07-05 18:02:53 +0530
commitbd99f6b4d67c386daf604c94999e5de72584f883 (patch)
tree11d8434fc5691c163c939c4cf3eacff4cf9bdec4 /cmd
parente2f67996a608346ea3f3525ef2febf6ca5d2b78c (diff)
bpf/usage: log to database
Diffstat (limited to 'cmd')
-rw-r--r--cmd/redq/main.go23
1 files changed, 17 insertions, 6 deletions
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)
}