engine

package
v0.0.0-...-c8a9255 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2020 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ForbidRuntimeChange uint8 = 1 << iota
	NeedEngineReConfig
	NeedRestartWatch
	NeedUpdateTracker
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	AutoStart            bool
	EngineDebug          bool
	MuteEngineLog        bool
	ObfsPreferred        bool
	ObfsRequirePreferred bool
	DisableTrackers      bool
	DisableIPv6          bool
	DownloadDirectory    string
	WatchDirectory       string
	EnableUpload         bool
	EnableSeeding        bool
	IncomingPort         int
	DoneCmd              string
	SeedRatio            float32
	UploadRate           string
	DownloadRate         string
	TrackerListURL       string
	AlwaysAddTrackers    bool
	ProxyURL             string
	RssURL               string
	ScraperURL           string
}

func InitConf

func InitConf(specPath string) (*Config, error)

func (*Config) DownloadLimiter

func (c *Config) DownloadLimiter() *rate.Limiter

func (*Config) NormlizeConfigDir

func (c *Config) NormlizeConfigDir() (bool, error)

func (*Config) SyncViper

func (c *Config) SyncViper(nc Config) error

func (*Config) UploadLimiter

func (c *Config) UploadLimiter() *rate.Limiter

func (*Config) Validate

func (c *Config) Validate(nc *Config) uint8

type Engine

type Engine struct {
	sync.RWMutex // race condition on ts,client
	// contains filtered or unexported fields
}

the Engine Cloud Torrent engine, backed by anacrolix/torrent

func New

func New(s Server) *Engine

func (*Engine) Config

func (e *Engine) Config() Config

func (*Engine) Configure

func (e *Engine) Configure(c Config) error

func (*Engine) DeleteTorrent

func (e *Engine) DeleteTorrent(infohash string) error

func (*Engine) GetTorrents

func (e *Engine) GetTorrents() map[string]*Torrent

GetTorrents just get the local infohash->Torrent map

func (*Engine) IsConfigred

func (e *Engine) IsConfigred() bool

func (*Engine) NewMagnet

func (e *Engine) NewMagnet(magnetURI string) error

NewMagnet -> *Torrent -> addTorrentTask

func (*Engine) NewTorrentByFilePath

func (e *Engine) NewTorrentByFilePath(path string) error

NewTorrentByFilePath -> NewTorrentBySpec

func (*Engine) NewTorrentBySpec

func (e *Engine) NewTorrentBySpec(spec *torrent.TorrentSpec) error

NewTorrentBySpec -> *Torrent -> addTorrentTask

func (*Engine) SetConfig

func (e *Engine) SetConfig(c Config)

func (*Engine) StartFile

func (e *Engine) StartFile(infohash, filepath string) error

func (*Engine) StartTorrent

func (e *Engine) StartTorrent(infohash string) error

func (*Engine) StopFile

func (e *Engine) StopFile(infohash, filepath string) error

func (*Engine) StopTorrent

func (e *Engine) StopTorrent(infohash string) error

func (*Engine) TaskRoutine

func (e *Engine) TaskRoutine()

TaskRoutine called by intevaled background goroutine moves torrents out of the anacrolix/torrent and into the local cache and do condition check and actions on them

func (*Engine) UpdateTrackers

func (e *Engine) UpdateTrackers() error

func (*Engine) WriteStauts

func (e *Engine) WriteStauts(_w io.Writer)

type File

type File struct {
	//anacrolix/torrent
	Path          string
	Size          int64
	Completed     int64
	Done          bool
	DoneCmdCalled bool
	//cloud torrent
	Started bool
	Percent float32
	// contains filtered or unexported fields
}

type Server

type Server interface {
	GetRestAPI() string
	GetIsPendingBoot() bool
}

type Torrent

type Torrent struct {
	//anacrolix/torrent
	InfoHash   string
	Name       string
	Magnet     string
	Loaded     bool
	Downloaded int64
	Uploaded   int64
	Size       int64
	Files      []*File
	//cloud torrent
	Started       bool
	Done          bool
	DoneCmdCalled bool
	Percent       float32
	DownloadRate  float32
	UploadRate    float32
	SeedRatio     float32
	AddedAt       time.Time
	StartedAt     time.Time
	Stats         torrent.TorrentStats
	// contains filtered or unexported fields
}

func (*Torrent) Update

func (torrent *Torrent) Update(t *torrent.Torrent)

Update retrive info from torrent.Torrent

Jump to

Keyboard shortcuts

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