tstor/config/model.go
Antonio Navarro Perez ddda39b22a
Server implementation. (#90)
* Server implementation.

- Share the content of a folder as a magnet file.
- Web interface with all data needed for sharing data.
- New configuration to add several servers
- Every time the content of the server folder is changed, the magnet
file will be generated again.

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>

* Update dependencies

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>

* Use boltdb piece completion storage.

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
2021-11-21 14:03:18 +01:00

82 lines
1.8 KiB
Go

package config
// Root is the main yaml config object
type Root struct {
HTTPGlobal *HTTPGlobal `yaml:"http"`
WebDAV *WebDAVGlobal `yaml:"webdav"`
Torrent *TorrentGlobal `yaml:"torrent"`
Fuse *FuseGlobal `yaml:"fuse"`
Log *Log `yaml:"log"`
Routes []*Route `yaml:"routes"`
Servers []*Server `yaml:"servers"`
}
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"`
}
type TorrentGlobal struct {
AddTimeout int `yaml:"add_timeout,omitempty"`
GlobalCacheSize int64 `yaml:"global_cache_size,omitempty"`
MetadataFolder string `yaml:"metadata_folder,omitempty"`
DisableIPv6 bool `yaml:"disable_ipv6,omitempty"`
}
type WebDAVGlobal struct {
Port int `yaml:"port"`
User string `yaml:"user"`
Pass string `yaml:"pass"`
}
type HTTPGlobal struct {
Port int `yaml:"port"`
}
type FuseGlobal struct {
AllowOther bool `yaml:"allow_other,omitempty"`
Path string `yaml:"path"`
}
type Route struct {
Name string `yaml:"name"`
Torrents []*Torrent `yaml:"torrents"`
}
type Server struct {
Name string `yaml:"name"`
Path string `yaml:"path"`
Trackers []string `yaml:"trackers"`
TrackerURL string `yaml:"tracker_url"`
}
type Torrent struct {
MagnetURI string `yaml:"magnet_uri,omitempty"`
TorrentPath string `yaml:"torrent_path,omitempty"`
}
func AddDefaults(r *Root) *Root {
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{}
}
if r.Fuse.Path == "" {
r.Fuse.Path = mountFolder
}
return r
}