Skip to content

Commit

Permalink
Move file expiry time to config file
Browse files Browse the repository at this point in the history
  • Loading branch information
hgw8 committed Dec 10, 2023
1 parent 579a2ac commit 979c7e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ lport = "5000"
vhost = "hardfiles.org"
dbfile = "dbfile.db"
filelen = 6
folder = "files"
folder = "files"
fileexpiry = 86400
15 changes: 8 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 979c7e3

Please sign in to comment.