summaryrefslogtreecommitdiff
path: root/cmd/redq/main.go
blob: 8807105e871ee495140733b90ea104101e9bd0a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main

import (
	"context"
	"log"
	"net"

	"github.com/jackc/pgx/v5"
	"sinanmohd.com/redq/usage"
	"sinanmohd.com/redq/db"
)

func main() {
	u := &usage.Usage {
		Data : make(usage.UsageMap),
	}

	iface, err := net.InterfaceByName("wlan0")
	if err != nil {
		log.Fatalf("lookup network: %s", err)
	}

	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)

	u.Run(iface, queries, ctx)
}