config

package
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PORT = 7777

	ConfigDirName = ".beamdrop"

	// MaxUploadSize defines the maximum upload file size (500MB by default)
	MaxUploadSize int64 = 500 * 1024 * 1024 // 500MB in bytes //TODO: Will fix this,

	MultipartFormMaxMemory int64 = 10 << 30 // 10GB in bytes, for parsing multipart forms
)

Variables

View Source
var (
	VERSION   = "0.0.1" // All these are set during the build
	Commit    = "unknown"
	BuildDate = "unknown"
)

Set via -ldflags at build time

View Source
var (
	DBName = "beamdrop.db"
	DBPath string
	// AllowedMIMETypes defines the allowed MIME types for uploads
	// Empty list means all types are allowed
	AllowedMIMETypes = []string{

		"image/jpeg", "image/png", "image/gif", "image/webp", "image/svg+xml", "image/bmp",

		"application/pdf", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
		"application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
		"application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation",
		"text/plain", "text/csv", "text/html", "text/css", "text/javascript",

		"application/zip", "application/x-rar-compressed", "application/x-7z-compressed",
		"application/x-tar", "application/gzip",

		"audio/mpeg", "audio/wav", "audio/ogg", "audio/mp4", "audio/webm", "audio/flac",

		"video/mp4", "video/mpeg", "video/webm", "video/ogg", "video/x-msvideo", "video/quicktime",

		"application/json", "application/xml", "application/javascript",

		"application/octet-stream",
	}
)
View Source
var DefaultPorts = []int{
	7777,
	8080,
	8888,
	9000,
	9999,
	3000,
	4000,
	5000,
	6000,
	8000,
	2020,
	3030,
	4040,
	5050,
	6060,
	7070,
	8181,
	8443,
	9090,
	9191,
}

DefaultPorts is a list of ports to try if the primary port is unavailable

Functions

func CreateTrashBin

func CreateTrashBin(sharedDir string) error

CreateTrashBin creates the trash bin directory if it doesn't exist inside the sharedDir

func FindAvailablePort

func FindAvailablePort() (int, error)

FindAvailablePort tries to find an available port from the default ports list

func InitDataDir added in v0.2.5

func InitDataDir(sharedDir string)

InitDataDir sets DBPath to <sharedDir>/.beamdrop/beamdrop.db and ensures the directory exists. Must be called after flags are parsed.

func IsPortAvailable

func IsPortAvailable(port int) bool

IsPortAvailable checks if a port is available for use

func SetDBPath

func SetDBPath(path string)

Types

type Config

type Config struct {
	PORT int
}

func GetConfig

func GetConfig() Config

type Flags

type Flags struct {
	SharedDir          string
	QR                 bool
	Port               int
	Help               bool
	Password           string
	TLSCert            string
	TLSKey             string
	AllowedOrigins     string        // Comma-separated list of allowed CORS origins
	APIAuth            bool          // Enable API key authentication for S3-like API
	LogLevel           string        // "debug", "info", "warn", "error" (default "info")
	RateLimit          int           // General rate limit in requests/min (0 = disabled)
	ShutdownTimeout    time.Duration // Graceful shutdown timeout (default 30s)
	DBPath             string        // Path to database file (default: <sharedDir>/.beamdrop/beamdrop.db)
	MaxStorage         int64         // Maximum total storage in bytes (0 = unlimited)
	TrustedProxies     string        // Comma-separated list of trusted proxy IPs/CIDRs
	JWTSecret          string        // Explicit JWT signing secret (min 32 bytes; empty = auto-generate and persist)
	DisableCSP         bool          // Skip setting Content-Security-Policy header
	DisableCSRF        bool          // Skip CSRF token validation
	DisableSystemStats bool          // Hide server disk/memory/CPU stats from the usage dashboard
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL