server

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLocalIP

func GetLocalIP() string

GetLocalIP returns the local IP address

func StatsSocketHandler

func StatsSocketHandler(sharedDir string, allowedOrigins []string, disableSystemStats bool, maxStorage int64) http.HandlerFunc

StatsSocketHandler handles WebSocket connections for real-time stats updates It fetches fresh stats from the database and system on each interval and sends them to the client

Types

type ExtendedStats

type ExtendedStats struct {
	Downloads       int                 `json:"downloads"`
	Requests        int                 `json:"requests"`
	Uploads         int                 `json:"uploads"`
	BytesUploaded   int64               `json:"bytesUploaded"`
	BytesDownloaded int64               `json:"bytesDownloaded"`
	StartTime       time.Time           `json:"startTime"`
	Storage         StorageUsage        `json:"storage"`
	System          *system.SystemStats `json:"system,omitempty"`
}

ExtendedStats contains both database stats, system stats, and storage usage.

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(sharedDir string, flags config.Flags) *Server

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the server and all managed resources. It drains in-flight HTTP requests within the given context deadline, then closes the rate limiter, orphan cleaner, database, and logger.

func (*Server) Start

func (s *Server) Start() error

type StorageUsage added in v0.2.10

type StorageUsage struct {
	// UsedBytes is the total bytes consumed by files in the shared directory
	// (excluding internal .beamdrop metadata directories).
	UsedBytes uint64 `json:"usedBytes"`
	// TotalBytes is the total capacity of the filesystem where the shared directory lives.
	TotalBytes uint64 `json:"totalBytes"`
	// FreeBytes is the free space on that filesystem.
	FreeBytes uint64 `json:"freeBytes"`
	// AllocatedBytes is the storage cap set via -max-storage (0 = unlimited).
	AllocatedBytes int64 `json:"allocatedBytes"`
	// AvailableBytes is the effective space available for new uploads:
	//   - If maxStorage is set: max(0, allocatedBytes - usedBytes)
	//   - If unlimited: free space on disk
	AvailableBytes uint64 `json:"availableBytes"`
	// UsagePercent is the percentage of the effective limit used:
	//   - If maxStorage is set: usedBytes / allocatedBytes * 100
	//   - If unlimited: usedBytes / totalBytes * 100
	UsagePercent float64 `json:"usagePercent"`
}

StorageUsage provides Beamdrop-specific storage metrics. It includes the actual disk usage of the shared directory, filesystem capacity, and any max-storage allocation set via the -max-storage flag.

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

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