From 0f45bce4815295f11c34542dbf990e36e8dc2e41 Mon Sep 17 00:00:00 2001 From: ZizzyDizzyMC Date: Sat, 27 Feb 2021 21:37:06 -0500 Subject: [PATCH] Default Random Filename flag. --- server.go | 2 ++ templates.go | 1 + templates/index.html | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/server.go b/server.go index 07508c6..985c769 100644 --- a/server.go +++ b/server.go @@ -78,6 +78,7 @@ var Config struct { maxDurationTime uint64 maxDurationSize int64 disableAccessKey bool + defaultRandomFilename bool } var Templates = make(map[string]*pongo2.Template) @@ -315,6 +316,7 @@ func main() { flag.Uint64Var(&Config.maxDurationTime, "max-duration-time", 0, "Time till expiry for files over max-duration-size") flag.Int64Var(&Config.maxDurationSize, "max-duration-size", 4*1024*1024*1024, "Size of file before max-duration-time is used to determine expiry max time.") flag.BoolVar(&Config.disableAccessKey, "disable-access-key", false, "Disables access key usage") + flag.BoolVar(&Config.defaultRandomFilename, "default-random-filename", true, "Makes it so the random filename is not default if set false. Default true.") iniflags.Parse() mux := setup() diff --git a/templates.go b/templates.go index 51e9433..458af90 100644 --- a/templates.go +++ b/templates.go @@ -91,6 +91,7 @@ func renderTemplate(tpl *pongo2.Template, context pongo2.Context, r *http.Reques context["extra_footer_text"] = Config.extraFooterText // Add the context for Config.disableAccessKey context["disable_access_key"] = Config.disableAccessKey + context["default_randomize"] = Config.defaultRandomFilename var a string if Config.authFile == "" { diff --git a/templates/index.html b/templates/index.html index 294ec40..01ec49e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -21,7 +21,7 @@ + {% if default_randomized && !(forcerandom) %} checked {% endif %} /> Randomize filename