Documentation
¶
Overview ¶
Package config loads, validates, and persists librarr's server configuration and runtime settings.
Index ¶
- Variables
- func NormalizeBaseURL(raw string) string
- type Config
- func (c *Config) ActiveTorrentClient() string
- func (c *Config) HasAPIKey() bool
- func (c *Config) HasAudiobookshelf() bool
- func (c *Config) HasAuth() bool
- func (c *Config) HasBookTracker() bool
- func (c *Config) HasCalibre() bool
- func (c *Config) HasDeluge() bool
- func (c *Config) HasFlibusta() bool
- func (c *Config) HasKavita() bool
- func (c *Config) HasKomga() bool
- func (c *Config) HasOIDC() bool
- func (c *Config) HasOIDCProxyHeaders() bool
- func (c *Config) HasProwlarr() bool
- func (c *Config) HasQBittorrent() bool
- func (c *Config) HasSABnzbd() bool
- func (c *Config) HasTorrentClient() bool
- func (c *Config) HasTransmission() bool
- func (c *Config) HasZLibrary() bool
Constants ¶
This section is empty.
Variables ¶
var BaseURLSettingKeys = []string{
"qb_url",
"transmission_url",
"prowlarr_url",
"sabnzbd_url",
"abs_url",
"abs_public_url",
"kavita_url",
"kavita_public_url",
"komga_url",
"calibre_url",
"flibusta_url",
}
BaseURLSettingKeys lists the settings.json keys that hold a service base URL — the subset of settings normalizeServiceURLs repairs at load time. The settings API normalizes the same keys on write, so the value the UI shows after a save matches the one the runtime will use.
Functions ¶
func NormalizeBaseURL ¶ added in v1.2.0
NormalizeBaseURL cleans a service base URL that came from an env var or the settings file: trims whitespace and trailing slashes, and prepends "http://" when no scheme is present.
Issue #92: a scheme-less value such as "audiobookshelf:13378" reaches net/http as a relative URL, so every request against it fails with the opaque `unsupported protocol scheme ""`. The user-visible symptoms are a library page stuck on "Failed to load library" and an "abs scan failed" log line, neither of which points at the URL as the cause. Repairing the value once, at load time, fixes every consumer at once.
A non-http scheme is left alone — if someone configures "unix://…" that's their call, and mangling it into "http://unix://…" would be worse than the original error.
Types ¶
type Config ¶
type Config struct {
// Server
Port int
DBPath string
// TrustedProxies lists CIDRs/IPs of reverse proxies whose forwarded
// headers (X-Forwarded-Proto) may be trusted. Empty = trust none.
TrustedProxies []string
// qBittorrent
QBUrl string
QBUser string
QBPass string
QBSavePath string
QBCategory string
QBAudiobookSavePath string
QBAudiobookCategory string
QBMangaSavePath string
QBMangaCategory string
// Prowlarr
ProwlarrURL string
ProwlarrAPIKey string
// File Organization
FileOrgEnabled bool
EbookDir string
AudiobookDir string
MangaDir string
IncomingDir string
MangaIncomingDir string
// Torznab
TorznabAPIKey string
// Anna's Archive
AnnasArchiveDomain string
AnnasArchiveSecretKey string // AA account secret key for /dyn/api/fast_download.json
// Sources is the runtime indexer-endpoint registry. Drivers read URLs,
// mirrors, and per-site config from here instead of from hardcoded
// constants. Always non-nil after Load() returns.
Sources *sources.Registry
// Circuit Breaker
CircuitBreakerThreshold int
CircuitBreakerTimeout int // seconds
// Download Settings
MaxRetries int
RetryBackoffSeconds int
// Search Filtering
MinTorrentSizeBytes int64
MaxTorrentSizeBytes int64
// Library Import Targets
CalibreLibraryPath string
CalibreURL string
KavitaURL string
KavitaUser string
KavitaPass string
KavitaLibraryPath string
KavitaMangaLibraryPath string
ABSURL string
ABSToken string
ABSLibraryID string
ABSEbookLibraryID string
// Authentication
AuthUsername string
AuthPassword string
APIKey string
// Komga
KomgaURL string
KomgaUser string
KomgaPass string
KomgaLibraryID string
KomgaLibraryPath string
// ABS Public URL (for external links)
ABSPublicURL string
// Kavita Public URL (for external links)
KavitaPublicURL string
// SABnzbd (Usenet)
SABnzbdURL string
SABnzbdAPIKey string
SABnzbdCategory string
// Download client priority (lower = preferred)
QBPriority int
SABPriority int
// Post-import torrent handling
RemoveTorrentAfterImport bool
// Flibusta
FlibustaURL string
FlibustaEnabled bool
// Z-Library
ZLibraryURL string
ZLibraryEmail string
ZLibraryPassword string
ZLibraryEnabled bool
// ThePirateBay
TPBEnabled bool
// BookTracker
BookTrackerURL string
BookTrackerUser string
BookTrackerPass string
BookTrackerEnabled bool
// Search filtering
ForeignLangFilter bool // filter out non-English titles (default: true for backward compat)
// Feature toggles
RateLimitEnabled bool
MetricsEnabled bool
WebNovelEnabled bool
MangaDexEnabled bool
// lightnovel-crawler container name (for docker exec)
LNCrawlContainer string
// Settings persistence
SettingsFile string
// OIDC / SSO
OIDCEnabled bool
OIDCProviderName string
OIDCIssuer string
OIDCClientID string
OIDCClientSecret string
OIDCRedirectURI string
OIDCAutoCreateUsers bool
OIDCDefaultRole string
OIDCRequireEmailVerified bool
OIDCProxyHeaders bool
// Deluge
DelugeURL string
DelugePassword string
// Transmission
TransmissionURL string
TransmissionUser string
TransmissionPass string
// TorrentClient explicitly selects the active torrent backend
// ("qbittorrent" or "transmission"). Empty means auto-detect.
TorrentClient string
// User Agent
UserAgent string
// Webhooks (env-based defaults)
WebhookURL string
WebhookType string // "discord" or "generic"
// Scheduler
SchedulerEnabled bool
SchedulerIntervalHours int
SchedulerAutoDownload bool
SchedulerMinScore int
// Wishlist cleanup removes wishlist rows that are already present in the
// library. It is intentionally opt-in and dry-run by default.
WishlistCleanupEnabled bool
WishlistCleanupIntervalHours int
WishlistCleanupDryRun bool
// Quality Profiles
AutoUpgradeEnabled bool
// Rename on Import
RenameEnabled bool
RenamePattern string
// Author Monitoring
AuthorMonitorEnabled bool
AuthorCheckIntervalDays int
}
Config holds all application configuration loaded from environment variables.
func Load ¶
func Load() *Config
Load reads configuration from environment variables with sensible defaults, then applies overrides from the settings file (if present) so values saved from the UI persist across restarts.
func (*Config) ActiveTorrentClient ¶ added in v1.1.3
ActiveTorrentClient resolves which torrent backend handles torrents:
- an explicit, configured TORRENT_CLIENT wins ("qbittorrent"/"qbit"/"qb" or "transmission");
- otherwise qBittorrent is preferred for backward compatibility;
- otherwise Transmission if it alone is configured;
- else "" (no torrent client).
func (*Config) HasAudiobookshelf ¶
HasAudiobookshelf returns true if ABS is configured.
func (*Config) HasBookTracker ¶ added in v1.1.0
HasBookTracker returns true if BookTracker is configured and enabled.
func (*Config) HasCalibre ¶
HasCalibre returns true if Calibre library path is configured.
func (*Config) HasFlibusta ¶ added in v1.1.0
HasFlibusta returns true if Flibusta is configured and enabled.
func (*Config) HasOIDCProxyHeaders ¶ added in v1.1.2
HasOIDCProxyHeaders returns true when reverse-proxy SSO headers should be trusted.
func (*Config) HasProwlarr ¶
HasProwlarr returns true if Prowlarr is configured.
func (*Config) HasQBittorrent ¶
HasQBittorrent returns true if qBittorrent is configured.
func (*Config) HasSABnzbd ¶
HasSABnzbd returns true if SABnzbd is configured.
func (*Config) HasTorrentClient ¶ added in v1.1.3
HasTorrentClient returns true if any torrent download backend is configured.
func (*Config) HasTransmission ¶
HasTransmission returns true if Transmission is configured.
func (*Config) HasZLibrary ¶ added in v1.1.0
HasZLibrary returns true if Z-Library is configured and enabled.