diff --git a/config/config.go b/config/config.go index 528efda..1e018b0 100644 --- a/config/config.go +++ b/config/config.go @@ -3,21 +3,24 @@ package config import "flag" type Config struct { - Port int `json:"port"` - LogPath string `json:"logPath"` - DatabasePath string `json:"databasePath"` + Port int `json:"port"` + LogPath string `json:"logPath"` + DatabasePath string `json:"databasePath"` + AdminPassword string `json:"adminPassword"` } func ParseFlags() Config { port := flag.Int("Port", 8080, "Listen port") logPath := flag.String("LogPath", "logs", "Path to log files") databasePath := flag.String("DatabasePath", "badgerdb", "Path to the database directory") + adminPassword := flag.String("AdminPassword", "", "Admin password for the web interface, disabled if empty") flag.Parse() return Config{ - Port: *port, - LogPath: *logPath, - DatabasePath: *databasePath, + Port: *port, + LogPath: *logPath, + DatabasePath: *databasePath, + AdminPassword: *adminPassword, } } diff --git a/go.mod b/go.mod index 2d7d2a4..2d949c0 100644 --- a/go.mod +++ b/go.mod @@ -2,14 +2,16 @@ module pool-stats go 1.24.3 -require github.com/ostafen/clover/v2 v2.0.0-alpha.3.0.20250212110647-35f6fd38bde2 +require ( + github.com/gofrs/uuid/v5 v5.3.1 + github.com/ostafen/clover/v2 v2.0.0-alpha.3.0.20250212110647-35f6fd38bde2 +) require ( github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/dgraph-io/badger/v4 v4.5.1 // indirect github.com/dgraph-io/ristretto/v2 v2.1.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect - github.com/gofrs/uuid/v5 v5.3.1 // indirect github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect github.com/google/flatbuffers v25.2.10+incompatible // indirect github.com/google/orderedcode v0.0.1 // indirect diff --git a/main.go b/main.go index 2fa0102..9733b76 100644 --- a/main.go +++ b/main.go @@ -34,7 +34,7 @@ func main() { currentDayStatsRecalcJob := jobs.NewRecalculateCurrentDayStatsJob(db) go currentDayStatsRecalcJob.Run() - webServer := web.NewWebServer(db, config.Port) + webServer := web.NewWebServer(db, config.Port, config.AdminPassword) if err := webServer.Start(); err != nil { log.Fatalf("Failed to start web server: %v", err) } diff --git a/templates/layout.html b/templates/layout.html index f8f831c..c5b5b08 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -6,12 +6,50 @@