From 8ce11fa8247d2a86720cd5b204ca3c64b9113079 Mon Sep 17 00:00:00 2001 From: Balakrishnan Balasubramanian Date: Tue, 9 May 2023 22:05:03 -0400 Subject: [PATCH] Fix initialization of conf for stats --- results/stats.go | 12 +++++++----- results/telemetry.go | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/results/stats.go b/results/stats.go index 0f797d7..38c992b 100644 --- a/results/stats.go +++ b/results/stats.go @@ -21,18 +21,20 @@ type StatsData struct { } var ( - key = []byte(securecookie.GenerateRandomKey(32)) - store = sessions.NewCookieStore(key) - conf = config.LoadedConfig() + store *sessions.CookieStore + conf *config.Config ) -func init() { +func statsInitialize(c *config.Config) { + key := []byte(securecookie.GenerateRandomKey(32)) + store = sessions.NewCookieStore(key) store.Options = &sessions.Options{ - Path: conf.BaseURL+"/stats", + Path: c.BaseURL + "/stats", MaxAge: 3600 * 1, // 1 hour HttpOnly: true, SameSite: http.SameSiteStrictMode, } + conf = c } func Stats(w http.ResponseWriter, r *http.Request) { diff --git a/results/telemetry.go b/results/telemetry.go index f43f0fe..275fa2c 100644 --- a/results/telemetry.go +++ b/results/telemetry.go @@ -87,6 +87,7 @@ type IPInfoResponse struct { } func Initialize(c *config.Config) { + statsInitialize(c) // changed to use Noto Sans instead of OpenSans, due to issue: // https://github.com/golang/freetype/issues/8 fLight, err := freetype.ParseFont(fontLightBytes)