.env.example, addr config, working on banned mime types

This commit is contained in:
2026-11-15 11:22:50 -05:00
parent 93da714ed0
commit e1e0c8042e
5 changed files with 28 additions and 4 deletions
+18
View File
@@ -0,0 +1,18 @@
# directory where uploads are stored
MINIBIN_UPLOAD_DIR=uploads
MINIBIN_DATABASE_PATH=minibin.sqlite
# the public host of minibin
MINIBIN_HOST=https://example.tld
# the address minibin binds to
MINIBIN_ADDR=localhost:8080
# max size uploadable in KiB, 97657 is around 100 MB
MINIBIN_MAX_PASTE_KIB=97657
MINIBIN_MAX_FILE_KIB=97657
# allowed expiries, shown in the order they are written
# syntax: h(our),d(ay),w(eek),mo(nth),y(ear), 0 = indefinite/no expiry
MINIBIN_EXPIRIES=1h,12h,1d,7d,2w,1mo,6mo,1y,5y,0
# when set to true, will normalize mime types
# the browser could execute to text/plain to prevent it
MINIBIN_NORMALIZE_MIME_TYPES=true
# prevents uploads with these mime types, separated by commas
MINIBIN_BANNED_MIME_TYPES="application/vnd.microsoft.portable-executable,application/java-archive,application/x-executable"
+1
View File
@@ -20,6 +20,7 @@
!/templates/** !/templates/**
!/static/** !/static/**
!.prettierrc !.prettierrc
!.env.example
# !Makefile # !Makefile
+5 -1
View File
@@ -16,10 +16,12 @@ type Config struct {
MaxFileBytes int64 MaxFileBytes int64
Expiries []Expiry Expiries []Expiry
NormalizeMIMETypes bool NormalizeMIMETypes bool
BannedMIMETypes []string
DatabasePath string DatabasePath string
// public host like "https://bin.zip", NOT the address minbin listens on // public host like "https://bin.zip", NOT the address minbin listens on
Host string Host string
Addr string
} }
func loadConfig() (Config, error) { func loadConfig() (Config, error) {
@@ -61,10 +63,12 @@ func loadConfig() (Config, error) {
MaxPasteBytes: maxPasteKiB * 1024, MaxPasteBytes: maxPasteKiB * 1024,
MaxFileBytes: maxFileKiB * 1024, MaxFileBytes: maxFileKiB * 1024,
Expiries: expiries, Expiries: expiries,
NormalizeMIMETypes: envOrDefault("MINIBIN_NORMALIZE_MIME_TYPE", "true") == "true", NormalizeMIMETypes: envOrDefault("MINIBIN_NORMALIZE_MIME_TYPES", "true") == "true",
BannedMIMETypes: strings.Split(envOrDefault("MINIBIN_BANNED_MIME_TYPES", ""), ","),
DatabasePath: envOrDefault("MINIBIN_DATABASE_PATH", "minibin.sqlite"), DatabasePath: envOrDefault("MINIBIN_DATABASE_PATH", "minibin.sqlite"),
Host: envOrDefault("MINIBIN_HOST", "http://localhost:8080"), Host: envOrDefault("MINIBIN_HOST", "http://localhost:8080"),
Addr: envOrDefault("MINIBIN_ADDR", "localhost:8080"),
}, nil }, nil
} }
+2 -2
View File
@@ -131,9 +131,9 @@ func main() {
mux.HandleFunc("POST /{id}/delete", deleteHandler(db, config)) mux.HandleFunc("POST /{id}/delete", deleteHandler(db, config))
mux.HandleFunc("GET /health", health) mux.HandleFunc("GET /health", health)
log.Println("listening on http://localhost:8080") log.Println("listening on", config.Addr)
err = http.ListenAndServe("localhost:8080", mux) err = http.ListenAndServe(config.Addr, mux)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
+2 -1
View File
@@ -26,7 +26,8 @@ goals:
- [ ] size based expiry - [ ] size based expiry
- exclusions if below a certain size (like 5mb) - exclusions if below a certain size (like 5mb)
- [x] delete content endpoints - [x] delete content endpoints
- [x] return a page for nojs clients, such as on delete or upload - [ ] return a page for nojs clients, such as on delete or upload
- need to return one on failures as well 💔💔💔
- [ ] max total storage usage - [ ] max total storage usage
- [x] normalize mime types (like html) - [x] normalize mime types (like html)
- converts specific mime types to text/plain to prevent rendering - converts specific mime types to text/plain to prevent rendering