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"`
|
2021-11-20 19:57:25 +00:00
|
|
|
Log *Log `yaml:"log"`
|
2020-04-27 16:46:23 +00:00
|
|
|
|
2021-11-21 13:03:18 +00:00
|
|
|
Routes []*Route `yaml:"routes"`
|
|
|
|
Servers []*Server `yaml:"servers"`
|
2021-03-01 18:04:59 +00:00
|
|
|
}
|
|
|
|
|
2021-11-20 19:57:25 +00:00
|
|
|
type Log struct {
|
|
|
|
Debug bool `yaml:"debug"`
|
|
|
|
MaxBackups int `yaml:"max_backups"`
|
|
|
|
MaxSize int `yaml:"max_size"`
|
|
|
|
MaxAge int `yaml:"max_age"`
|
|
|
|
Path string `yaml:"path"`
|
|
|
|
}
|
|
|
|
|
2021-04-04 17:24:58 +00:00
|
|
|
type TorrentGlobal struct {
|
2021-11-20 19:57:25 +00:00
|
|
|
AddTimeout int `yaml:"add_timeout,omitempty"`
|
2021-04-04 17:24:58 +00:00
|
|
|
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 {
|
2021-11-23 12:05:49 +00:00
|
|
|
Port int `yaml:"port"`
|
|
|
|
IP string `yaml:"ip"`
|
|
|
|
HTTPFS bool `yaml:"httpfs"`
|
2021-04-04 17:24:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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"`
|
|
|
|
}
|
|
|
|
|
2021-11-21 13:03:18 +00:00
|
|
|
type Server struct {
|
|
|
|
Name string `yaml:"name"`
|
|
|
|
Path string `yaml:"path"`
|
|
|
|
Trackers []string `yaml:"trackers"`
|
|
|
|
TrackerURL string `yaml:"tracker_url"`
|
|
|
|
}
|
|
|
|
|
2021-03-01 18:04:59 +00:00
|
|
|
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{}
|
|
|
|
}
|
2021-11-23 12:05:49 +00:00
|
|
|
|
|
|
|
if r.Torrent.AddTimeout == 0 {
|
|
|
|
r.Torrent.AddTimeout = 60
|
|
|
|
}
|
|
|
|
|
2021-04-04 17:24:58 +00:00
|
|
|
if r.Torrent.GlobalCacheSize == 0 {
|
2021-11-23 12:05:49 +00:00
|
|
|
r.Torrent.GlobalCacheSize = 2048 // 2GB
|
2021-04-04 17:24:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2021-11-23 12:05:49 +00:00
|
|
|
if r.HTTPGlobal == nil {
|
|
|
|
r.HTTPGlobal = &HTTPGlobal{}
|
|
|
|
}
|
|
|
|
|
|
|
|
if r.HTTPGlobal.IP == "" {
|
|
|
|
r.HTTPGlobal.IP = "0.0.0.0"
|
|
|
|
}
|
|
|
|
|
|
|
|
if r.Log == nil {
|
|
|
|
r.Log = &Log{}
|
|
|
|
}
|
|
|
|
|
2020-04-27 16:46:23 +00:00
|
|
|
return r
|
|
|
|
}
|