From 979c7e34d45132c143534451a5df3b419a746ef3 Mon Sep 17 00:00:00 2001 From: hgw Date: Sun, 10 Dec 2023 05:32:53 +0000 Subject: [PATCH] Move file expiry time to config file --- config.toml | 3 ++- main.go | 15 ++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/config.toml b/config.toml index a19e287..7ca8b90 100644 --- a/config.toml +++ b/config.toml @@ -3,4 +3,5 @@ lport = "5000" vhost = "hardfiles.org" dbfile = "dbfile.db" filelen = 6 -folder = "files" \ No newline at end of file +folder = "files" +fileexpiry = 86400 \ No newline at end of file diff --git a/main.go b/main.go index e8ce808..dee78fd 100644 --- a/main.go +++ b/main.go @@ -23,12 +23,13 @@ var ( ) type Config struct { - Webroot string `toml:"webroot"` - LPort string `toml:"lport"` - VHost string `toml:"vhost"` - DBFile string `toml:"dbfile"` - FileLen int `toml:"filelen"` - FileFolder string `toml:"folder"` + Webroot string `toml:"webroot"` + LPort string `toml:"lport"` + VHost string `toml:"vhost"` + DBFile string `toml:"dbfile"` + FileLen int `toml:"filelen"` + FileFolder string `toml:"folder"` + FileExpirySeconds int `toml:"fileexpiry"` } func LoadConf() { @@ -120,7 +121,7 @@ func CheckFile(name string) bool { // false if doesn't exist, true if exists func UploadHandler(w http.ResponseWriter, r *http.Request) { // expiry sanitize - twentyfour := int64(86400) + twentyfour := int64(conf.FileExpirySeconds) file, _, err := r.FormFile("file") if err != nil {