From 81d6bc357a7b0d49ba0c5034f77404dc577cf8aa Mon Sep 17 00:00:00 2001 From: clsr Date: Thu, 16 Jun 2016 19:23:18 +0200 Subject: Add --id-charset and --id-length options --- USAGE | 8 ++++++++ main.go | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/USAGE b/USAGE index cffaf48..3cd76a4 100644 --- a/USAGE +++ b/USAGE @@ -51,6 +51,14 @@ Running sets website name to NAME example: --name Example + --id-charset CHARSET + sets the charset for file IDs in URLs to CHARSET; should only include URL-safe characters and no slashes + example: --id-charset 0123456789 + + --id-length LENGTH + sets the length of file IDs in the URLs to LENGTH + example: --id-length 5 + --max-size BYTES sets BYTES as the upload file size limit in bytes example (10 MiB): --bytes 10485760 diff --git a/main.go b/main.go index fc51fe2..ad8711c 100644 --- a/main.go +++ b/main.go @@ -46,6 +46,9 @@ func main() { forbidMime := flag.String("forbid-mime", "application/x-dosexec,application/x-msdos-program", "comma-separated list of forbidden MIME types") forbidExt := flag.String("forbid-ext", "exe,dll,msi,scr,com,pif", "comma-separated list of forbidden file extensions") grill := flag.Bool("grill", false, "enable grills") + idLength := flag.Int("id-length", 6, "length of uploaded file IDs") + idCharset := flag.String("id-charset", "", "charset for uploaded file IDs (default lowercase letters a-z)") + flag.Parse() rand.Seed(time.Now().UnixNano()) @@ -53,6 +56,10 @@ func main() { storage = NewStorage("upload", *maxSize) storage.ForbiddenExt = strings.Split(*forbidExt, ",") storage.ForbiddenMime = strings.Split(*forbidMime, ",") + storage.IdLength = *idLength + if *idCharset != "" { + storage.IdCharset = *idCharset + } http.HandleFunc("/upload.php", handleUpload) http.Handle("/u/", http.StripPrefix("/u/", http.HandlerFunc(handleFile))) -- cgit