diff options
author | sinanmohd <sinan@sinanmohd.com> | 2024-07-08 06:30:30 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2024-07-08 06:33:45 +0530 |
commit | 34ea85ac3ab93e3eb34baf006c6ee0837834b820 (patch) | |
tree | b2f297406f3dde244553160b2012f69f2a848a8c /api/main.go | |
parent | d08ae9402429bfca69d72c7a7d99975aa356539f (diff) |
Diffstat (limited to 'api/main.go')
-rw-r--r-- | api/main.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/api/main.go b/api/main.go index ea2d7f9..1a5821a 100644 --- a/api/main.go +++ b/api/main.go @@ -6,9 +6,10 @@ import ( "log" "net" + "sinanmohd.com/redq/bpf/filter" + "sinanmohd.com/redq/bpf/usage" "sinanmohd.com/redq/db" "sinanmohd.com/redq/dns" - "sinanmohd.com/redq/bpf/usage" ) const ( @@ -43,7 +44,7 @@ func New() (*Api, error) { return &a, nil } -func (a *Api) Run(u *usage.Usage, d *dns.Dns, queries *db.Queries, ctxDb context.Context) { +func (a *Api) Run(u *usage.Usage, d *dns.Dns, f *filter.Filter, queries *db.Queries, ctxDb context.Context) { for { conn, err := a.sock.Accept() if err != nil { @@ -51,11 +52,11 @@ func (a *Api) Run(u *usage.Usage, d *dns.Dns, queries *db.Queries, ctxDb context continue } - go handleConn(conn, u, d, queries, ctxDb) + go handleConn(conn, u, d, f, queries, ctxDb) } } -func handleConn(conn net.Conn, u *usage.Usage, d *dns.Dns, queries *db.Queries, ctxDb context.Context) { +func handleConn(conn net.Conn, u *usage.Usage, d *dns.Dns, f *filter.Filter, queries *db.Queries, ctxDb context.Context) { defer conn.Close() var req ApiReq buf := make([]byte, bufSize) @@ -79,6 +80,8 @@ func handleConn(conn net.Conn, u *usage.Usage, d *dns.Dns, queries *db.Queries, handleUsage(conn, u, queries, ctxDb) case "dns": handleDns(conn, d, req.Arg, req.Action) + case "filter": + handleFilter(conn, f, req.Arg, req.Action) default: log.Printf("invalid request type: %s", req.Type) } |