config

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(path string, isFile bool) error

func Remove

func Remove(key string) error

func Set

func Set(key string, v any) error

Types

type CORS

type CORS struct {
	Credentials   bool     `toml:"credentials"`
	AllowOrigin   []string `toml:"allow_origin"`
	AllowHeaders  []string `toml:"allow_headers"`
	AllowMethods  []string `toml:"allow_methods"`
	ExposeHeaders []string `toml:"expose_headers"`
	MaxAge        int      `toml:"max_age"`
}

type Cache

type Cache struct {
	Path   string `toml:"path"`
	Expire int    `toml:"expire"`
}

type Config

type Config struct {
	Endpoint string `toml:"endpoint"`
	Token    string `toml:"token"`
	Pwd      string `toml:"pwd"`
	Debug    bool   `toml:"debug"`
	Daemon   Daemon `toml:"daemon"`
	FFmpeg   FFmpeg `toml:"ffmpeg"`
	Webdav   Webdav `toml:"webdav"`
}

func GetConfig

func GetConfig() (*Config, error)

type Daemon

type Daemon struct {
	Listen string `toml:"listen"`
}

type FFmpeg

type FFmpeg struct {
	Cache   Cache          `toml:"cache"`
	Options map[string]any `toml:"options"`
}

type Permissions

type Permissions struct {
	Create bool
	Read   bool
	Update bool
	Delete bool
}

func (Permissions) Allowed

func (p Permissions) Allowed(r *http.Request, fileExists func(string) bool) bool

func (Permissions) AllowedDestination

func (p Permissions) AllowedDestination(r *http.Request, fileExists func(string) bool) bool

func (*Permissions) UnmarshalText

func (p *Permissions) UnmarshalText(data []byte) error

type Rule

type Rule struct {
	Permissions Permissions    `toml:"permissions"`
	Path        string         `toml:"path"`
	Regex       *regexp.Regexp `toml:"regex"`
}

func (*Rule) Matches

func (r *Rule) Matches(path string) bool

func (*Rule) Validate

func (r *Rule) Validate() error

type User

type User struct {
	Username    string      `toml:"username"`
	Password    string      `toml:"password"`
	Permissions Permissions `toml:"permissions"`
	Rules       []*Rule     `toml:"rules"`
}

func (User) Allowed

func (u User) Allowed(r *http.Request, fileExists func(string) bool) bool

func (*User) Validate

func (u *User) Validate() error

type Webdav

type Webdav struct {
	Listen string `toml:"listen"`
	Prefix string `toml:"prefix"`
	Cache  Cache  `toml:"cache"`
	CORS   CORS   `toml:"cors"`
	Users  []User `toml:"users"`
}

Jump to

Keyboard shortcuts

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