got key loading to work, removed config file for now

pull/1/head
Adam Veldhousen 3 years ago
parent 8d564e441a
commit 03ccb0c08c
Signed by: adam
GPG Key ID: 6DB29003C6DD1E4B

@ -6,7 +6,10 @@ WORKDIR /build/client
RUN apk add --no-cache make
COPY . /build/
RUN npm install && npm run build && mkdir -p /build/.bin/static && cp -R ./public /build/.bin/static
RUN npm install \
&& npm run build \
&& mkdir -p /build/.bin/static \
&& cp -R ./public /build/.bin/static
# DNS/API SERVER BUILD
FROM golang:alpine as build-server
@ -34,6 +37,8 @@ COPY --chown=gopherhole:gopherhole --from=build-server /build/.bin/gopherhole /o
USER gopherhole
EXPOSE 53/udp 53/tcp 80/tcp
VOLUME "/data"
ENTRYPOINT /opt/gopherhole

@ -1,7 +1,6 @@
<script lang="ts">
import { onMount } from "svelte";
import { navigate } from "svelte-routing";
import { getUnixTime, isEqual, sub } from "date-fns";
import { getUnixTime, sub } from "date-fns";
import { buildQueryParams, fromUnixTimeSafe } from "../api/util";
import { getLogs, getStats, LogPayload, StatSearchKey } from "../api";
@ -22,8 +21,12 @@
export let end: Date = fromUnixTimeSafe(params.get("end")) || new Date();
export let filter: string = params.get("filter") || "";
const aggKey = params.get("key");
const fixed = aggKey[0].toUpperCase() + aggKey.substr(1);
export let chartKey: StatSearchKey =
StatSearchKey[params.get("key")] || StatSearchKey.Domain;
StatSearchKey[fixed] || StatSearchKey.Domain;
export let chartInterval: number = 30;
export let logPage: number = 0;

@ -100,13 +100,11 @@ func (ss *Sqlite) GetLogAggregate(la LogAggregateInput) (LogAggregate, error) {
return LogAggregate{}, fmt.Errorf("more than one page available: %v", logs.PageCount)
}
lut := [][]StatsDataPoint{}
buckets := map[string][]StatsDataPoint{}
for _, l := range logs.Logs {
k := GetAggregateColumnHeader(l, LogAggregateColumn(la.Column))
if _, ok := buckets[k]; !ok {
buckets[k] = make([]StatsDataPoint, sampleCount)
lut = append(lut, buckets[k])
buckets[k] = make([]StatsDataPoint, sampleCount+1)
}
dataset := buckets[k]

@ -3,11 +3,8 @@ package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"regexp"
"strings"
"time"
"github.com/adamveld12/gopherhole/client/public"
@ -16,22 +13,21 @@ import (
)
var (
configFilePath = flag.String("config", "./config.json", "Config file")
// dbPath = flag.String("db-path", ".", "Directory to write database files to")
// httpAddr = flag.String("http-address", ":8080", "Bind address for http server")
// dnsAddr = flag.String("dns-address", ":53", "Bind address for dns server")
dbPath = flag.String("db-path", ".", "Directory to write database files to")
httpAddr = flag.String("http-address", ":80", "Bind address for http server")
dnsAddr = flag.String("dns-address", ":53", "Bind address for dns server")
)
func main() {
flag.Parse()
log.SetFlags(log.LUTC | log.Lshortfile)
var conf StartupConfig
if err := LoadStartupConfig(&conf, *configFilePath); err != nil {
log.Fatalf("%+v", err)
conf := StartupConfig{
HTTPAddr: *httpAddr,
DNSAddr: *dnsAddr,
DatabaseURL: *dbPath,
}
// conf.HTTPAddr = *httpAddr
// conf.DNSAddr = *dnsAddr
log.Printf("%+v", conf)
store := &internal.Sqlite{
Path: conf.DatabaseURL,
@ -61,7 +57,7 @@ func main() {
Storage: store,
RuleEvaluator: re,
Recursors: internal.Recursor{
Upstreams: cleanRecursors(conf.Recursors),
Upstreams: []string{"1.1.1.1:53"},
Client: dnsClient,
},
}
@ -78,23 +74,3 @@ func main() {
log.Fatal(err)
}
}
func cleanRecursors(recursors []string) []string {
cr := []string{}
reg := regexp.MustCompile(`^((?:\d{1,4}\.?){4})(?::(\d{0,5}))?`)
for _, r := range recursors {
if !reg.MatchString(r) {
log.Fatalf("%s is not a valid DNS server. Must be in ip:addr format.", r)
}
cleanedIPAddr := r
if !strings.Contains(r, ":") {
cleanedIPAddr = fmt.Sprintf("%s:53", r)
}
cr = append(cr, cleanedIPAddr)
}
log.Println(cr)
return cr
}

@ -1,10 +1,10 @@
build: clobber .bin/client/public .bin/gopherhole
dev: clean .bin/gopherhole .bin/config.json
cd .bin && ./gopherhole -config config.json
dev: clean .bin/gopherhole
cd .bin && ./gopherhole -dns-address=:5353 -http-address=:8000
clean:
@rm -rf .bin/gopherhole .bin/config.json .bin/client
@rm -rf .bin/gopherhole .bin/client
clobber: clean
@rm -rf .bin ./client/node_modules ./client/public/build
@ -27,9 +27,6 @@ test:
.bin/gopherhole: .bin
@go build --tags "fts5" -v -o .bin/gopherhole .
.bin/config.json:
@cp ./config.example.json .bin/config.json
client-dev: client/node_modules
cd ./client && npm run dev

Loading…
Cancel
Save