.env.example, addr config, working on banned mime types
This commit is contained in:
@@ -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"
|
||||
@@ -20,6 +20,7 @@
|
||||
!/templates/**
|
||||
!/static/**
|
||||
!.prettierrc
|
||||
!.env.example
|
||||
|
||||
# !Makefile
|
||||
|
||||
|
||||
@@ -16,10 +16,12 @@ type Config struct {
|
||||
MaxFileBytes int64
|
||||
Expiries []Expiry
|
||||
NormalizeMIMETypes bool
|
||||
BannedMIMETypes []string
|
||||
|
||||
DatabasePath string
|
||||
// public host like "https://bin.zip", NOT the address minbin listens on
|
||||
Host string
|
||||
Addr string
|
||||
}
|
||||
|
||||
func loadConfig() (Config, error) {
|
||||
@@ -61,10 +63,12 @@ func loadConfig() (Config, error) {
|
||||
MaxPasteBytes: maxPasteKiB * 1024,
|
||||
MaxFileBytes: maxFileKiB * 1024,
|
||||
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"),
|
||||
Host: envOrDefault("MINIBIN_HOST", "http://localhost:8080"),
|
||||
Addr: envOrDefault("MINIBIN_ADDR", "localhost:8080"),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -131,9 +131,9 @@ func main() {
|
||||
mux.HandleFunc("POST /{id}/delete", deleteHandler(db, config))
|
||||
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 {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@ goals:
|
||||
- [ ] size based expiry
|
||||
- exclusions if below a certain size (like 5mb)
|
||||
- [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
|
||||
- [x] normalize mime types (like html)
|
||||
- converts specific mime types to text/plain to prevent rendering
|
||||
|
||||
Reference in New Issue
Block a user