config

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Delimiter = "."
	Config    *Configuration
	K         = koanf.New(Delimiter)
)

Functions

func GetDefaultConfigDirectory

func GetDefaultConfigDirectory(app string, filename string) string

func Init

func Init(configFilePath string) error

func InitializeTrackerStatuses

func InitializeTrackerStatuses(perTrackerOverrides map[string][]string)

InitializeTrackerStatuses prepares the default status map and processes per-tracker overrides. It should be called once after configuration is loaded.

func ParseTrackerDomain added in v1.16.0

func ParseTrackerDomain(trackerHost string) string

func ShowUsing

func ShowUsing()

func ValidateStruct

func ValidateStruct(s any) []error

Types

type Configuration

type Configuration struct {
	Clients                    map[string]map[string]any
	Filters                    map[string]FilterConfiguration
	Trackers                   tracker.Config
	BypassIgnoreIfUnregistered bool
	TrackerErrors              TrackerErrorsConfig `yaml:"tracker_errors" koanf:"tracker_errors"`
	Notifications              NotificationsConfig `yaml:"notifications" koanf:"notifications"`
}

type DefaultValidator

type DefaultValidator struct {
}

func (DefaultValidator) Validate

func (v DefaultValidator) Validate(val reflect.Value) (bool, error)

type DiscordConfig added in v1.14.0

type DiscordConfig struct {
	WebhookURL string `yaml:"webhook_url" koanf:"webhook_url"`
	Username   string `yaml:"username" koanf:"username"`
	AvatarURL  string `yaml:"avatar_url" koanf:"avatar_url"`
}

type FilterConfiguration

type FilterConfiguration struct {
	MapHardlinksFor []string
	Ignore          []string
	Remove          []string
	Pause           []string
	DeleteData      *bool
	Orphan          struct {
		GracePeriod time.Duration `yaml:"grace_period" koanf:"grace_period"`
		IgnorePaths []string      `yaml:"ignore_paths" koanf:"ignore_paths"`
	} `yaml:"orphan" koanf:"orphan"`
	Label []struct {
		Name   string
		Update []string
	}
	Tag []struct {
		Name     string
		Mode     string
		UploadKb *int `mapstructure:"uploadKb"`
		Update   []string
	}
}

type NotificationService added in v1.14.0

type NotificationService struct {
	Discord DiscordConfig `yaml:"discord" koanf:"discord"`
}

type NotificationsConfig added in v1.14.0

type NotificationsConfig struct {
	Detailed     bool
	SkipEmptyRun bool `yaml:"skip_empty_run" koanf:"skip_empty_run"`
	Service      NotificationService
}

type RequiredValidator

type RequiredValidator struct {
}

func (RequiredValidator) Validate

func (v RequiredValidator) Validate(val reflect.Value) (bool, error)

type Torrent

type Torrent struct {
	// torrent
	Hash                string              `json:"Hash"`
	Name                string              `json:"Name"`
	Path                string              `json:"Path"`
	TotalBytes          int64               `json:"TotalBytes"`
	DownloadedBytes     int64               `json:"DownloadedBytes"`
	State               string              `json:"State"`
	Files               []string            `json:"Files"`
	Tags                map[string]struct{} `json:"Tags"`
	Downloaded          bool                `json:"Downloaded"`
	Seeding             bool                `json:"Seeding"`
	Ratio               float32             `json:"Ratio"`
	AddedSeconds        int64               `json:"AddedSeconds"`
	AddedHours          float32             `json:"AddedHours"`
	AddedDays           float32             `json:"AddedDays"`
	SeedingSeconds      int64               `json:"SeedingSeconds"`
	SeedingHours        float32             `json:"SeedingHours"`
	SeedingDays         float32             `json:"SeedingDays"`
	LastActivitySeconds int64               `json:"LastActivitySeconds"`
	LastActivityHours   float32             `json:"LastActivityHours"`
	LastActivityDays    float32             `json:"LastActivityDays"`
	Label               string              `json:"Label"`
	Seeds               int64               `json:"Seeds"`
	Peers               int64               `json:"Peers"`
	IsPrivate           bool                `json:"IsPrivate"`
	IsPublic            bool                `json:"IsPublic"`
	UpLimit             int64               `json:"UpLimit,omitempty"`

	// set by client on GetCurrentFreeSpace
	FreeSpaceGB  func() float64 `json:"-"`
	FreeSpaceSet bool           `json:"-"`

	// tracker
	TrackerName   string `json:"TrackerName"`
	TrackerStatus string `json:"TrackerStatus"`
	// AllTrackerStatuses stores status messages from all trackers (key: tracker URL, value: status message)
	AllTrackerStatuses map[string]string `json:"AllTrackerStatuses,omitempty"`
	Comment            string            `json:"Comment"`

	RegistrationState TorrentRegistrationState `json:"-"`

	// set by command
	HardlinkedOutsideClient bool `json:"-"`
	APIDividerPrinted       bool `json:"-"`
	// contains filtered or unexported fields
}

func (*Torrent) HasAllTags

func (t *Torrent) HasAllTags(tags ...string) bool

func (*Torrent) HasAnyTag

func (t *Torrent) HasAnyTag(tags ...string) bool

func (*Torrent) HasMissingFiles

func (t *Torrent) HasMissingFiles() bool

func (*Torrent) IsIntermediateStatus added in v1.15.0

func (t *Torrent) IsIntermediateStatus() bool

func (*Torrent) IsTrackerDown

func (t *Torrent) IsTrackerDown() bool

func (*Torrent) IsUnregistered

func (t *Torrent) IsUnregistered(ctx context.Context) bool

func (*Torrent) Log

func (t *Torrent) Log(n float64) float64

func (*Torrent) RegexMatch

func (t *Torrent) RegexMatch(pattern string) bool

RegexMatch delegates to the regex checker

func (*Torrent) RegexMatchAll

func (t *Torrent) RegexMatchAll(patternsStr string) bool

RegexMatchAll checks if the torrent name matches all the provided patterns

func (*Torrent) RegexMatchAny

func (t *Torrent) RegexMatchAny(patternsStr string) bool

RegexMatchAny checks if the torrent name matches any of the provided patterns

func (*Torrent) TagsSlice added in v1.18.0

func (t *Torrent) TagsSlice() []string

TagsSlice converts the internal tags map to a sorted slice for display/API calls

type TorrentRegistrationState added in v1.15.0

type TorrentRegistrationState uint8
const (
	NoRegistrationState TorrentRegistrationState = iota
	UnregisteredState
	RegisteredState
	IntermediateState
)

type TrackerErrorsConfig

type TrackerErrorsConfig struct {
	// PerTrackerUnregisteredStatuses allows overriding the default list of unregistered statuses
	// on a per-tracker basis. The key is the tracker name (case-insensitive),
	// and the value is a list of status strings (case-insensitive, exact match).
	PerTrackerUnregisteredStatuses map[string][]string `yaml:"per_tracker_unregistered_statuses" koanf:"per_tracker_unregistered_statuses"`
}

type Validator

type Validator interface {
	Validate(reflect.Value) (bool, error)
}

Jump to

Keyboard shortcuts

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