bt

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2016 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDownloadRateLimit = 50 * 1024 * 1024
View Source
const DefaultUploadRateLimit = 50 * 1024 * 1024 // 50Mb/s

Variables

View Source
var (
	ErrBtEngineNotStart = fmt.Errorf("BT engine not started")
	ErrIdNotExist       = fmt.Errorf("ID not exist")
)

Functions

This section is empty.

Types

type BtEngine

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

BtEngine backed by anacrolix/torrent

func NewBtEngine

func NewBtEngine(root string, trackers []string, c *Config) *BtEngine

func (*BtEngine) DeleteTorrent

func (e *BtEngine) DeleteTorrent(id string) error

func (*BtEngine) GetAllStatus

func (e *BtEngine) GetAllStatus() ([]Status, error)

func (*BtEngine) GetDownloadRateLimit

func (e *BtEngine) GetDownloadRateLimit() (int, error)

func (*BtEngine) GetFilePath

func (e *BtEngine) GetFilePath(id string) string

func (*BtEngine) GetStatus

func (e *BtEngine) GetStatus(id string) (*Status, error)

func (*BtEngine) GetTorrent

func (e *BtEngine) GetTorrent(id string) ([]byte, error)

func (*BtEngine) GetTorrentFilePath

func (e *BtEngine) GetTorrentFilePath(id string) string

func (*BtEngine) GetTorrents

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

GetTorrents moves torrents out of the anacrolix/torrent and into the local cache

func (*BtEngine) GetUploadRateLimit

func (e *BtEngine) GetUploadRateLimit() (int, error)

func (*BtEngine) RootDir

func (e *BtEngine) RootDir() string

func (*BtEngine) Run

func (e *BtEngine) Run() error

func (*BtEngine) SetDownloadRateLimit

func (e *BtEngine) SetDownloadRateLimit(download int) error

func (*BtEngine) SetUploadRateLimit

func (e *BtEngine) SetUploadRateLimit(upload int) error

func (*BtEngine) StartLeecher

func (e *BtEngine) StartLeecher(id string, torrentData []byte, p *ProgressDownload) error

func (*BtEngine) StartSeed

func (e *BtEngine) StartSeed(id string) error

func (*BtEngine) Started

func (e *BtEngine) Started() bool

func (*BtEngine) StopTorrent

func (e *BtEngine) StopTorrent(id string) error

type Config

type Config struct {
	DisableEncryption bool
	EnableUpload      bool
	EnableSeeding     bool
	IncomingPort      int
	UploadRateLimit   int
	DownloadRateLimit int
}

type ProgressDownload

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

func NewProgressDownload

func NewProgressDownload(id string, size int, output io.Writer) *ProgressDownload

type State

type State int
const (
	Started State = iota + 1
	Dropped
)

func (State) String

func (s State) String() string

type Status

type Status struct {
	Id        string `json:"id"`
	State     string `json:"state"`
	Completed int64  `json:"completed"`
	TotalLen  int64  `json:"totallength"`
	Seeding   bool   `json:"seeding"`
}

type Torrent

type Torrent struct {
	// invariant
	InfoHash string
	Name     string

	State        State
	Loaded       bool
	Seeding      bool
	Size         int64
	Downloaded   int64
	Percent      float32
	DownloadRate float32
	// contains filtered or unexported fields
}

func (*Torrent) Update

func (t *Torrent) Update()

Jump to

Keyboard shortcuts

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