2020-04-27 16:46:23 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
// Root is the main yaml config object
|
|
|
|
type Root struct {
|
2021-04-04 17:24:58 +00:00
|
|
|
HTTPGlobal *HTTPGlobal `yaml:"http"`
|
|
|
|
WebDAV *WebDAVGlobal `yaml:"webdav"`
|
|
|
|
Torrent *TorrentGlobal `yaml:"torrent"`
|
|
|
|
Fuse *FuseGlobal `yaml:"fuse"`
|
2020-04-27 16:46:23 +00:00
|
|
|
|
2021-04-04 17:24:58 +00:00
|
|
|
Routes []*Route `yaml:"routes"`
|
2021-03-01 18:04:59 +00:00
|
|
|
}
|
|
|
|
|
2021-04-04 17:24:58 +00:00
|
|
|
type TorrentGlobal struct {
|
|
|
|
GlobalCacheSize int64 `yaml:"global_cache_size,omitempty"`
|
|
|
|
MetadataFolder string `yaml:"metadata_folder,omitempty"`
|
|
|
|
DisableIPv6 bool `yaml:"disable_ipv6,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type WebDAVGlobal struct {
|
2021-10-11 16:50:18 +00:00
|
|
|
Port int `yaml:"port"`
|
|
|
|
User string `yaml:"user"`
|
|
|
|
Pass string `yaml:"pass"`
|
2021-04-04 17:24:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type HTTPGlobal struct {
|
|
|
|
Port int `yaml:"port"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type FuseGlobal struct {
|
|
|
|
AllowOther bool `yaml:"allow_other,omitempty"`
|
|
|
|
Path string `yaml:"path"`
|
2020-04-27 16:46:23 +00:00
|
|
|
}
|
|
|
|
|
2021-04-04 17:24:58 +00:00
|
|
|
type Route struct {
|
|
|
|
Name string `yaml:"name"`
|
2021-03-01 18:04:59 +00:00
|
|
|
Torrents []*Torrent `yaml:"torrents"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Torrent struct {
|
2021-04-04 17:24:58 +00:00
|
|
|
MagnetURI string `yaml:"magnet_uri,omitempty"`
|
|
|
|
TorrentPath string `yaml:"torrent_path,omitempty"`
|
2020-04-27 16:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func AddDefaults(r *Root) *Root {
|
2021-04-04 17:24:58 +00:00
|
|
|
if r.Torrent == nil {
|
|
|
|
r.Torrent = &TorrentGlobal{}
|
|
|
|
}
|
|
|
|
if r.Torrent.GlobalCacheSize == 0 {
|
|
|
|
r.Torrent.GlobalCacheSize = 1024 // 1GB
|
|
|
|
}
|
|
|
|
|
|
|
|
if r.Torrent.MetadataFolder == "" {
|
|
|
|
r.Torrent.MetadataFolder = metadataFolder
|
|
|
|
}
|
|
|
|
|
|
|
|
if r.Fuse == nil {
|
|
|
|
r.Fuse = &FuseGlobal{}
|
2020-04-27 16:46:23 +00:00
|
|
|
}
|
2021-04-04 17:24:58 +00:00
|
|
|
if r.Fuse.Path == "" {
|
|
|
|
r.Fuse.Path = mountFolder
|
2020-04-27 16:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return r
|
|
|
|
}
|