summaryrefslogtreecommitdiff
path: root/db/query.sql.go
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2024-07-07 15:04:52 +0530
committersinanmohd <sinan@sinanmohd.com>2024-07-07 15:07:34 +0530
commit60aa1b7adbd133a5b1679ab2feac4ec17e3b48b5 (patch)
tree082f64ac3ef625fb364227c138a99ba5c571016b /db/query.sql.go
parent38bf443cb2f52bd4cc822e69f9339094d846396f (diff)
dns: block blacklisted domains in the database
Diffstat (limited to 'db/query.sql.go')
-rw-r--r--db/query.sql.go41
1 files changed, 40 insertions, 1 deletions
diff --git a/db/query.sql.go b/db/query.sql.go
index d6304a7..80c6469 100644
--- a/db/query.sql.go
+++ b/db/query.sql.go
@@ -11,6 +11,19 @@ import (
"github.com/jackc/pgx/v5/pgtype"
)
+const enterDnsBlackList = `-- name: EnterDnsBlackList :exec
+INSERT INTO DnsBlackList (
+ Name
+) VALUES (
+ $1
+)
+`
+
+func (q *Queries) EnterDnsBlackList(ctx context.Context, name string) error {
+ _, err := q.db.Exec(ctx, enterDnsBlackList, name)
+ return err
+}
+
const enterUsage = `-- name: EnterUsage :exec
INSERT INTO Usage (
HardwareAddr, StartTime, StopTime, Egress, Ingress
@@ -38,8 +51,34 @@ func (q *Queries) EnterUsage(ctx context.Context, arg EnterUsageParams) error {
return err
}
+const getDnsBlackList = `-- name: GetDnsBlackList :many
+SELECT name
+FROM DnsBlackList
+`
+
+func (q *Queries) GetDnsBlackList(ctx context.Context) ([]string, error) {
+ rows, err := q.db.Query(ctx, getDnsBlackList)
+ if err != nil {
+ return nil, err
+ }
+ defer rows.Close()
+ var items []string
+ for rows.Next() {
+ var name string
+ if err := rows.Scan(&name); err != nil {
+ return nil, err
+ }
+ items = append(items, name)
+ }
+ if err := rows.Err(); err != nil {
+ return nil, err
+ }
+ return items, nil
+}
+
const getUsage = `-- name: GetUsage :one
-SELECT SUM(Ingress) AS Ingress, SUM(Egress) AS Egress FROM Usage
+SELECT SUM(Ingress) AS Ingress, SUM(Egress) AS Egress
+FROM Usage
`
type GetUsageRow struct {