engine

package
v0.0.0-...-5356b51 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ForbidRuntimeChange uint8 = 1 << iota
	NeedEngineReConfig
	NeedRestartWatch
	NeedUpdateTracker
	NeedLoadWaitList
	NeedUpdateRSS
)
View Source
const (
	CachedTorrentDir = ".cachedTorrents"
	TrashTorrentDir  = ".trashTorrents"
)

Variables

View Source
var (
	ErrTaskExists    = errors.New("Task already exists")
	ErrWaitListEmpty = errors.New("Wait list empty")
	ErrMaxConnTasks  = errors.New("Max conncurrent task reached")
)

Functions

func NewSyncList

func NewSyncList() *syncList

func SetLoggerFlag

func SetLoggerFlag(flag int)

Types

type Config

type Config struct {
	AutoStart               bool          `yaml:"AutoStart"`
	EngineDebug             bool          `yaml:"EngineDebug"`
	MuteEngineLog           bool          `yaml:"MuteEngineLog"`
	ObfsPreferred           bool          `yaml:"ObfsPreferred"`
	ObfsRequirePreferred    bool          `yaml:"ObfsRequirePreferred"`
	DisableTrackers         bool          `yaml:"DisableTrackers"`
	DisableIPv6             bool          `yaml:"DisableIPv6"`
	NoDefaultPortForwarding bool          `yaml:"NoDefaultPortForwarding"`
	DisableUTP              bool          `yaml:"DisableUTP"`
	DownloadDirectory       string        `yaml:"DownloadDirectory"`
	WatchDirectory          string        `yaml:"WatchDirectory"`
	EnableUpload            bool          `yaml:"EnableUpload"`
	EnableSeeding           bool          `yaml:"EnableSeeding"`
	IncomingPort            int           `yaml:"IncomingPort"`
	DoneCmd                 string        `yaml:"DoneCmd"`
	SeedRatio               float32       `yaml:"SeedRatio"`
	SeedTime                time.Duration `yaml:"SeedTime"`
	UploadRate              string        `yaml:"UploadRate"`
	DownloadRate            string        `yaml:"DownloadRate"`
	TrackerList             string        `yaml:"TrackerList"`
	AlwaysAddTrackers       bool          `yaml:"AlwaysAddTrackers"`
	ProxyURL                string        `yaml:"ProxyURL"`
	RssURL                  string        `yaml:"RssURL"`
	ScraperURL              string        `yaml:"ScraperURL"`
	MaxConcurrentTask       int           `yaml:"MaxConcurrentTask"`
	AllowRuntimeConfigure   bool          `yaml:"AllowRuntimeConfigure"`
}

func InitConf

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

func (*Config) DownloadLimiter

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

func (*Config) GetCmdConfig

func (c *Config) GetCmdConfig() (string, []string, error)

func (*Config) NormlizeConfigDir

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

func (*Config) SyncViper

func (c *Config) SyncViper(nc Config)

func (*Config) UploadLimiter

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

func (*Config) Validate

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

func (*Config) WriteDefault

func (c *Config) WriteDefault() error

func (*Config) WriteYaml

func (c *Config) WriteYaml(cf string) error

type Engine

type Engine struct {
	sync.RWMutex // race condition on ts,client

	TsChanged chan struct{}
	Trackers  []string
	// 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) ConnStat

func (e *Engine) ConnStat() torrent.ConnStats

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) ManualStartTorrent

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

func (*Engine) NewMagnet

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

NewMagnet -> newTorrentBySpec

func (*Engine) NewTorrentByFilePath

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

NewTorrentByFilePath -> newTorrentBySpec

func (*Engine) NewTorrentByReader

func (e *Engine) NewTorrentByReader(r io.Reader) error

NewTorrentByReader -> newTorrentBySpec

func (*Engine) NextWaitTask

func (e *Engine) NextWaitTask() error

func (*Engine) ParseTrackerList

func (e *Engine) ParseTrackerList() error

func (*Engine) PushWaitTask

func (e *Engine) PushWaitTask(ih string) error

func (*Engine) RemoveCache

func (e *Engine) RemoveCache(infohash string)

func (*Engine) RestoreCacheDir

func (e *Engine) RestoreCacheDir()

func (*Engine) RestoreTask

func (e *Engine) RestoreTask(fn string) error

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) StartTorrentWatcher

func (e *Engine) StartTorrentWatcher() error

func (*Engine) StopFile

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

func (*Engine) StopTorrent

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

func (*Engine) TorrentCacheFileName

func (e *Engine) TorrentCacheFileName(infohash string) string

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 FileSizePair

type FileSizePair struct {
	// contains filtered or unexported fields
}

type Server

type Server interface {
	GetStrAttribute(name string) string
	GetBoolAttribute(name string) bool
}

type Torrent

type Torrent struct {
	sync.Mutex

	//anacrolix/torrent
	InfoHash   string
	Name       string
	Magnet     string
	Loaded     bool
	Downloaded int64
	Uploaded   int64
	Size       int64
	Files      []*File

	//cloud torrent
	Stats          *torrent.TorrentStats
	Started        bool
	Done           bool
	DoneCmdCalled  bool
	IsQueueing     bool
	IsSeeding      bool
	ManualStarted  bool
	IsAllFilesDone bool
	Percent        float32
	DownloadRate   float32
	UploadRate     float32
	SeedRatio      float32
	AddedAt        time.Time
	StartedAt      time.Time
	FinishedAt     time.Time
	StoppedAt      time.Time
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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