config

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2025 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init() error

func RegisterStorageFactory added in v0.11.0

func RegisterStorageFactory(storageType string, factory StorageConfigFactory)

func ReloadConfig added in v0.9.0

func ReloadConfig() error

func Set added in v0.9.0

func Set(key string, value any)

Types

type AlistStorageConfig added in v0.11.0

type AlistStorageConfig struct {
	NewStorageConfig
	URL      string `toml:"url" mapstructure:"url" json:"url"`
	Username string `toml:"username" mapstructure:"username" json:"username"`
	Password string `toml:"password" mapstructure:"password" json:"password"`
	Token    string `toml:"token" mapstructure:"token" json:"token"`
	BasePath string `toml:"base_path" mapstructure:"base_path" json:"base_path"`
	TokenExp int64  `toml:"token_exp" mapstructure:"token_exp" json:"token_exp"`
}

func (*AlistStorageConfig) GetName added in v0.11.0

func (a *AlistStorageConfig) GetName() string

func (*AlistStorageConfig) GetType added in v0.11.0

func (a *AlistStorageConfig) GetType() types.StorageType

func (*AlistStorageConfig) Validate added in v0.11.0

func (a *AlistStorageConfig) Validate() error

type Config

type Config struct {
	Workers      int  `toml:"workers" mapstructure:"workers"`
	Retry        int  `toml:"retry" mapstructure:"retry"`
	NoCleanCache bool `toml:"no_clean_cache" mapstructure:"no_clean_cache" json:"no_clean_cache"`
	Threads      int  `toml:"threads" mapstructure:"threads" json:"threads"`
	Stream       bool `toml:"stream" mapstructure:"stream" json:"stream"`

	Users []userConfig `toml:"users" mapstructure:"users" json:"users"`

	Temp     tempConfig      `toml:"temp" mapstructure:"temp"`
	Log      logConfig       `toml:"log" mapstructure:"log"`
	DB       dbConfig        `toml:"db" mapstructure:"db"`
	Telegram telegramConfig  `toml:"telegram" mapstructure:"telegram"`
	Storages []StorageConfig `toml:"-" mapstructure:"-" json:"storages"`
	// Deprecated
	DeprecatedStorage deprecatedStorageConfig `toml:"storage" mapstructure:"storage"`
}
var Cfg *Config

func (*Config) GetStorageByName added in v0.11.0

func (c *Config) GetStorageByName(name string) StorageConfig

func (*Config) GetStorageNamesByUserID added in v0.11.0

func (c *Config) GetStorageNamesByUserID(userID int64) []string

func (*Config) GetStoragesByType added in v0.11.0

func (c *Config) GetStoragesByType(storageType types.StorageType) []StorageConfig

func (*Config) GetUsersID added in v0.11.0

func (c *Config) GetUsersID() []int64

func (*Config) HasStorage added in v0.11.0

func (c *Config) HasStorage(userID int64, storageName string) bool

type LocalStorageConfig added in v0.11.0

type LocalStorageConfig struct {
	NewStorageConfig
	BasePath string `toml:"base_path" mapstructure:"base_path" json:"base_path"`
}

func (*LocalStorageConfig) GetName added in v0.11.0

func (l *LocalStorageConfig) GetName() string

func (*LocalStorageConfig) GetType added in v0.11.0

func (l *LocalStorageConfig) GetType() types.StorageType

func (*LocalStorageConfig) Validate added in v0.11.0

func (l *LocalStorageConfig) Validate() error

type NewStorageConfig added in v0.11.0

type NewStorageConfig struct {
	Name      string                 `toml:"name" mapstructure:"name" json:"name"`
	Type      string                 `toml:"type" mapstructure:"type" json:"type"`
	Enable    bool                   `toml:"enable" mapstructure:"enable" json:"enable"`
	RawConfig map[string]interface{} `toml:"-" mapstructure:",remain"`
}

Base storage config

type StorageConfig added in v0.11.0

type StorageConfig interface {
	Validate() error
	GetType() types.StorageType
	GetName() string
}

func LoadStorageConfigs added in v0.11.0

func LoadStorageConfigs(v *viper.Viper) ([]StorageConfig, error)

type StorageConfigFactory added in v0.11.0

type StorageConfigFactory func(cfg *NewStorageConfig) (StorageConfig, error)

type WebdavStorageConfig added in v0.11.0

type WebdavStorageConfig struct {
	NewStorageConfig
	URL      string `toml:"url" mapstructure:"url" json:"url"`
	Username string `toml:"username" mapstructure:"username" json:"username"`
	Password string `toml:"password" mapstructure:"password" json:"password"`
	BasePath string `toml:"base_path" mapstructure:"base_path" json:"base_path"`
}

func (*WebdavStorageConfig) GetName added in v0.11.0

func (w *WebdavStorageConfig) GetName() string

func (*WebdavStorageConfig) GetType added in v0.11.0

func (w *WebdavStorageConfig) GetType() types.StorageType

func (*WebdavStorageConfig) Validate added in v0.11.0

func (w *WebdavStorageConfig) Validate() error

Jump to

Keyboard shortcuts

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