config

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 7 Imported by: 0 modules, 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 config holds the daemon settings and their JSON persistence.

Index

Constants

View Source
const (
	EncryptionPrefer  = "prefer"  // use it when the peer supports it (default)
	EncryptionRequire = "require" // refuse peers that do not encrypt
	EncryptionOff     = "off"     // do not ask for it
)

Encryption policies for peer connections.

View Source
const UpdateCheckInterval = 15 * time.Minute

UpdateCheckInterval is how often the automatic update check repeats (the first one is made shortly after the start). It is not a setting: often enough to be of use, rarely enough to be kind to GitHub (4 requests an hour). An "updateCheckMinutes" left in the settings file by an older version is ignored.

Variables

View Source
var LabelPalette = []string{"cyan", "pink", "violet", "olive", "coral", "purple", "brown"}

LabelPalette lists the colours a label can have. They are chosen so that none of them looks like a state colour of the interface: green (downloading), blue (seeding), yellow (checking), grey (stopped) and red (error). The order is the one new labels take them in: each next colour is far from the ones before it.

View Source
var LimitKeys = []string{"down", "up", "altDown", "altUp"}

LimitKeys are the speed limits a unit can be chosen for.

View Source
var LimitUnitIDs = []string{"KB", "MB", "kbit", "Mbit"}

LimitUnitIDs are the units a speed limit can be typed in: kilobytes and megabytes (binary, as sizes are shown), kilobits and megabits (decimal, as networks count them) per second.

Functions

func AssignLabelColors added in v1.0.40

func AssignLabelColors(colors map[string]string, labels []string) map[string]string

AssignLabelColors gives each of labels (in this order) the colour of the palette fewest labels of colors have, the earlier in the palette on a tie, and returns the map (made when colors is nil).

func SystemDownloads added in v1.0.17

func SystemDownloads() string

SystemDownloads is ~/Downloads when it exists, or "" otherwise.

func ValidLabelColor

func ValidLabelColor(id string) bool

ValidLabelColor tells whether id is one of LabelPalette.

func ValidLimitKey added in v1.0.25

func ValidLimitKey(key string) bool

ValidLimitKey tells whether key is one of LimitKeys.

func ValidLimitUnit added in v1.0.25

func ValidLimitUnit(id string) bool

ValidLimitUnit tells whether id is one of LimitUnitIDs.

Types

type AddDefaults

type AddDefaults struct {
	Paused          bool   `json:"paused"`
	Sequential      bool   `json:"sequential"`
	EdgePieces      bool   `json:"edgePieces"` // prioritise the first and last pieces of files
	SkipCheck       bool   `json:"skipCheck"`  // do not hash files that are already on disk
	MoveDoneEnabled bool   `json:"moveDoneEnabled"`
	MoveDone        string `json:"moveDone"`
}

AddDefaults are the initial choices of the "Add torrents" dialog.

type AltSchedule

type AltSchedule struct {
	Enabled bool   `json:"enabled"`
	From    string `json:"from"`
	To      string `json:"to"`
	Days    []int  `json:"days"`
}

AltSchedule switches the turtle mode on and off by the clock. The window runs from From to To (HH:MM, may cross midnight) on the listed weekdays (0 = Sunday; empty = every day). For a window crossing midnight the day is the one it starts on.

type CopyRemovePolicy

type CopyRemovePolicy string

CopyRemovePolicy decides when the saved .torrent copy is deleted.

const (
	// CopyRemoveWithData deletes the copy only when the torrent is removed together with its data.
	CopyRemoveWithData CopyRemovePolicy = "with_data"
	// CopyRemoveAlways deletes the copy on any removal.
	CopyRemoveAlways CopyRemovePolicy = "always"
	// CopyRemoveNever keeps the copy forever.
	CopyRemoveNever CopyRemovePolicy = "never"
)

type Network

type Network struct {
	MaxConnsPerTorrent    int    `json:"maxConnsPerTorrent"`    // established peers per torrent
	MaxHalfOpenPerTorrent int    `json:"maxHalfOpenPerTorrent"` // simultaneous connection attempts per torrent
	DHT                   bool   `json:"dht"`
	PEX                   bool   `json:"pex"`
	UTP                   bool   `json:"utp"`
	TCP                   bool   `json:"tcp"`
	IPv6                  bool   `json:"ipv6"`
	Webseeds              bool   `json:"webseeds"`
	AcceptIncoming        bool   `json:"acceptIncoming"`
	Encryption            string `json:"encryption"`
}

Network holds the connection settings. MaxConnsPerTorrent applies at once; the other fields are read when the engine starts, so changing them needs a restart.

type Settings

type Settings struct {
	// DataDir is where new torrents are saved unless they are given another folder.
	DataDir string `json:"dataDir"`
	// MoveCompletedDir, if set, is where a torrent is moved once its download has finished
	// (download in one place, keep the finished files in another).
	MoveCompletedDir string `json:"moveCompletedDir"`
	// WatchDir is scanned for new .torrent files, which are added automatically (empty = off).
	WatchDir string `json:"watchDir"`
	// Add holds what the "Add torrents" dialog starts with.
	Add AddDefaults `json:"add"`
	// LabelPaths maps a label to the folder for new torrents added with that label.
	LabelPaths map[string]string `json:"labelPaths,omitempty"`
	// LabelColors maps a label to the colour of its dot (an id from LabelPalette).
	LabelColors map[string]string `json:"labelColors,omitempty"`

	// Copy of every added .torrent file is stored here (empty disables the feature).
	TorrentCopyDir   string           `json:"torrentCopyDir"`
	CopyRemovePolicy CopyRemovePolicy `json:"copyRemovePolicy"`

	ListenPort int     `json:"listenPort"`
	Network    Network `json:"network"`
	// PortMapping keeps the port forwarded on the router (UPnP / NAT-PMP) and renews it.
	PortMapping bool `json:"portMapping"`
	// RouterAddress is where NAT-PMP asks for the port when the router is not the default gateway (a container on
	// Umbrel or Docker) and is not found on its own. Empty = find it.
	RouterAddress string `json:"routerAddress,omitempty"`

	// Preallocate checks, when a torrent is added, that the disk has room for it together with what every other
	// active torrent on the same disk still has left to download, and refuses early if not; each file is then set
	// to its final size up front (sparse, unless PreallocateZeroFill), so the check does not by itself hold that
	// space against anything outside Equinox that might use the disk in the meantime.
	Preallocate bool `json:"preallocate"`
	// PreallocateZeroFill additionally writes zeros so the space is physically allocated.
	PreallocateZeroFill bool `json:"preallocateZeroFill"`

	DownLimitKBps int `json:"downLimitKBps"`
	UpLimitKBps   int `json:"upLimitKBps"`

	// "Turtle" mode: alternative limits toggled with one click.
	AltDownLimitKBps int         `json:"altDownLimitKBps"`
	AltUpLimitKBps   int         `json:"altUpLimitKBps"`
	AltSpeedActive   bool        `json:"altSpeedActive"`
	AltSchedule      AltSchedule `json:"altSchedule"`

	// MaxActiveDownloads limits simultaneous downloads; the rest wait in the queue (0 = no limit).
	MaxActiveDownloads int `json:"maxActiveDownloads"`
	// MaxActiveSeeds limits how many finished torrents share at the same time; the rest wait for a free
	// place (0 = no limit). Those with someone to give to come first, then the queue order.
	MaxActiveSeeds int `json:"maxActiveSeeds"`

	// Default stop-seeding ratio, 0 disables. A torrent may override it.
	RatioLimit float64 `json:"ratioLimit"`

	// Default stop-seeding time in minutes, 0 disables. A torrent may override it.
	SeedTimeLimitMinutes int `json:"seedTimeLimitMinutes"`

	// MaxConcurrentChecks limits how many torrents have their local files checked at once; the rest wait
	// in a line (0 = no limit).
	MaxConcurrentChecks int `json:"maxConcurrentChecks"`

	// MaxConcurrentMoves limits how many torrents have their files being moved to another folder at
	// once (a manual move, or the "move completed torrents to" folder); the rest wait in a line
	// (0 = no limit). Several large torrents moving at once, each seeking all over a disk, is exactly
	// the kind of thrashing a spinning HDD suffers from, so the default is the most conservative: one
	// at a time.
	MaxConcurrentMoves int `json:"maxConcurrentMoves"`

	// SpeedUnit is how speeds are shown: "bytes" (КБ/с, МБ/с) or "bits" (Кб/с, Мб/с).
	SpeedUnit string `json:"speedUnit"`
	// TrackerIcons lets the program fetch the icon of the site of each tracker (a request to that site), for the side panel.
	TrackerIcons bool `json:"trackerIcons"`

	// Language is the language of the interface: "" as in the system, "ru" or "en". The page keeps its own copy of the
	// choice (it needs it before it can ask); this one is for what the program says itself, the tray and the notifications.
	Language string `json:"language,omitempty"`

	// LimitUnits maps a speed limit ("down", "up", "altDown", "altUp") to the unit its field was typed in: one
	// of LimitUnitIDs. A limit that is not there is shown in the unit of SpeedUnit. The limits themselves are
	// always kept in KiB/s (the *LimitKBps fields), whatever they were typed in.
	LimitUnits map[string]string `json:"limitUnits,omitempty"`

	// NotifyOnComplete makes the desktop application show a Windows notification when a download finishes.
	NotifyOnComplete bool `json:"notifyOnComplete"`

	// Desktop application behaviour. StartHidden: the autostart entry opens the app in the tray only.
	// CloseToTray: closing the window keeps the app running in the tray (otherwise it exits).
	// MinimizeToTray: minimising the window sends it to the tray.
	StartHidden    bool `json:"startHidden"`
	CloseToTray    bool `json:"closeToTray"`
	MinimizeToTray bool `json:"minimizeToTray"`
	// RememberWindow: the window opens at the size and place it had when it was closed (off: the default size
	// of the interface density, in the middle of the screen).
	RememberWindow bool `json:"rememberWindow"`

	// SetupDone is set once the first-run setup guide was finished or skipped.
	SetupDone bool `json:"setupDone"`

	// Streaming: how many pieces at each end of a file get top priority.
	EdgePieces int `json:"edgePieces"`
	// Streaming: size of the sliding window (in pieces) for sequential mode.
	SequentialWindow int `json:"sequentialWindow"`

	// AutoUpdateCheck periodically asks GitHub for a newer release (manual checks always work).
	AutoUpdateCheck bool `json:"autoUpdateCheck"`
}

Settings is everything the user can tune. Speeds are in KiB/s, 0 means unlimited.

func Default

func Default(dir string) Settings

Default returns settings with sane values; dir is the daemon's state directory.

func (Settings) UpdateCheckEvery added in v1.0.19

func (s Settings) UpdateCheckEvery() time.Duration

UpdateCheckEvery is the period of the automatic update check.

type Store

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

Store is a concurrency-safe settings holder backed by a JSON file.

func Load

func Load(path, stateDir string) (*Store, error)

Load reads path, creating it with defaults when missing.

func (*Store) Fresh added in v1.0.17

func (st *Store) Fresh() bool

Fresh tells whether Load found no settings file and made one from the defaults, that is, whether this is the first start on this state directory.

func (*Store) Get

func (st *Store) Get() Settings

Get returns a copy of the current settings.

func (*Store) Update

func (st *Store) Update(fn func(*Settings)) error

Update applies fn to the settings and persists the result.

Jump to

Keyboard shortcuts

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