store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 25 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package store implements croc's anonymous, encrypted, download-limited temporary storage service. It stores only ciphertext and capability verifiers.

Index

Constants

View Source
const (
	// DefaultExpiration preserves the historical stored-transfer lifetime.
	DefaultExpiration = 24 * time.Hour
	// MinExpiration is the shortest lifetime accepted by clients and servers.
	MinExpiration = time.Minute
	// MaxExpirationSeconds is the longest whole-second lifetime representable
	// by time.Duration.
	MaxExpirationSeconds = int64(math.MaxInt64 / int64(time.Second))
)
View Source
const (
	DefaultMaxTransfer   = int64(1 << 30)
	DefaultMaxTotal      = int64(5 << 30)
	DefaultMinFree       = int64(512 << 20)
	DefaultMaxFiles      = 100
	DefaultMaxDownloads  = 1
	DefaultCreatePerHour = 5
	DefaultActiveUploads = 2
	DefaultUploadTimeout = 5 * time.Minute
	MaxManifestBytes     = int64(256 << 10)
	MaxChunkObjects      = 512
)

Variables

This section is empty.

Functions

func ParseExpiration

func ParseExpiration(value string, allowUnlimited bool) (time.Duration, error)

ParseExpiration parses the stored-transfer duration syntax used by the CLI. Values are whole minutes, hours, days, or weeks. When allowUnlimited is true, an empty value or the literal "0" represents no server policy ceiling.

Types

type Config

type Config struct {
	Root             string
	MaxTransferBytes int64
	MaxTotalBytes    int64
	MinFreeBytes     int64
	MaxFiles         int
	MaxDownloads     int
	MaxExpiration    time.Duration
	CreatePerHour    int
	MaxActiveUploads int
	UploadTimeout    time.Duration
	TrustedProxies   []netip.Prefix
	Now              func() time.Time
	CleanupInterval  time.Duration
	DisableRootLock  bool
}

Config configures a filesystem-backed stored-transfer service.

type PublicConfig

type PublicConfig struct {
	Enabled           bool  `json:"enabled"`
	MaxTransferBytes  int64 `json:"maxTransferBytes"`
	MaxFiles          int   `json:"maxFiles"`
	MaxDownloads      int   `json:"maxDownloads"`
	ExpiresSeconds    int64 `json:"expiresSeconds"`
	MaxExpiresSeconds int64 `json:"maxExpiresSeconds"`
}

PublicConfig is safe to expose to web clients.

type Service

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

Service owns a filesystem store and serves its versioned HTTP API.

func New

func New(config Config) (*Service, error)

New creates or opens a filesystem store and reconstructs quota state.

func (*Service) Close

func (s *Service) Close() error

Close releases the exclusive store-root lock.

func (*Service) PublicConfig

func (s *Service) PublicConfig() PublicConfig

PublicConfig returns browser-safe limits.

func (*Service) RunCleanup

func (s *Service) RunCleanup(ctx context.Context)

RunCleanup sweeps expired data until the context is cancelled.

func (*Service) ServeHTTP

func (s *Service) ServeHTTP(response http.ResponseWriter, request *http.Request)

ServeHTTP serves /api/v1/store/transfers and its descendants.

func (*Service) Sweep

func (s *Service) Sweep() error

Sweep expires incomplete and available transfers and removes old tombstones.

Jump to

Keyboard shortcuts

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