Documentation
¶
Overview ¶
Package config holds the daemon settings and their JSON persistence.
Index ¶
Constants ¶
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.
const ( DefaultUpdateCheckMinutes = 60 MinUpdateCheckMinutes = 5 MaxUpdateCheckMinutes = 14 * 24 * 60 // setInterval in the page cannot wait longer than about 24 days )
Limits of how often updates are looked for: often enough to be of use, rarely enough to be kind to GitHub.
Variables ¶
var LabelPalette = []string{"violet", "purple", "pink", "cyan", "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).
Functions ¶
func SystemDownloads ¶ added in v1.0.17
func SystemDownloads() string
SystemDownloads is ~/Downloads when it exists, or "" otherwise.
func ValidLabelColor ¶
ValidLabelColor tells whether id is one of LabelPalette.
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"`
// Preallocate reserves the full file size on disk when a torrent is added.
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"`
// SpeedUnit is how speeds are shown: "bytes" (КБ/с, МБ/с) or "bits" (Кб/с, Мб/с).
SpeedUnit string `json:"speedUnit"`
// 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"`
// UpdateCheckMinutes is how often that check repeats (0 = the default, an hour). The first one is made
// shortly after the start.
UpdateCheckMinutes int `json:"updateCheckMinutes"`
}
Settings is everything the user can tune. Speeds are in KiB/s, 0 means unlimited.
func (Settings) UpdateCheckEvery ¶ added in v1.0.19
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.