torrent

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: GPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTorrentNotFound = errors.New("torrent not found")

Functions

func GetOrCreatePeerID added in v0.9.0

func GetOrCreatePeerID(p string) ([20]byte, error)

func NewClient

func NewClient(st storage.ClientImpl, fis bep44.Store, cfg *config.TorrentGlobal, id [20]byte) (*torrent.Client, error)

Types

type ByName

type ByName []*RouteStats

func (ByName) Len

func (a ByName) Len() int

func (ByName) Less

func (a ByName) Less(i, j int) bool

func (ByName) Swap

func (a ByName) Swap(i, j int)

type FileItemStore

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

func NewFileItemStore

func NewFileItemStore(path string, itemsTTL time.Duration) (*FileItemStore, error)

func (*FileItemStore) Close

func (fis *FileItemStore) Close() error

func (*FileItemStore) Del

func (fis *FileItemStore) Del(t bep44.Target) error

func (*FileItemStore) Get

func (fis *FileItemStore) Get(t bep44.Target) (*bep44.Item, error)

func (*FileItemStore) Put

func (fis *FileItemStore) Put(i *bep44.Item) error

type GlobalTorrentStats

type GlobalTorrentStats struct {
	DownloadedBytes int64   `json:"downloadedBytes"`
	UploadedBytes   int64   `json:"uploadedBytes"`
	TimePassed      float64 `json:"timePassed"`
}

type HTTPFS added in v0.8.0

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

func NewHTTPFS added in v0.8.0

func NewHTTPFS(fs dfs.Filesystem) *HTTPFS

func (*HTTPFS) Open added in v0.8.0

func (fs *HTTPFS) Open(name string) (http.File, error)

type PieceChunk

type PieceChunk struct {
	Status    PieceStatus `json:"status"`
	NumPieces int         `json:"numPieces"`
}

type PieceStatus

type PieceStatus string
const (
	Checking PieceStatus = "H"
	Partial  PieceStatus = "P"
	Complete PieceStatus = "C"
	Waiting  PieceStatus = "W"
	Error    PieceStatus = "?"
)

type RouteStats

type RouteStats struct {
	Name         string          `json:"name"`
	TorrentStats []*TorrentStats `json:"torrentStats"`
}

type Server added in v0.8.0

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

func NewServer added in v0.8.0

func NewServer(c *torrent.Client, pc storage.PieceCompletion, cfg *config.Server) *Server

func (*Server) Close added in v0.8.0

func (s *Server) Close() error

func (*Server) Info added in v0.8.0

func (s *Server) Info() *ServerInfo

func (*Server) Start added in v0.8.0

func (s *Server) Start() error

type ServerInfo added in v0.8.0

type ServerInfo struct {
	Magnet    string `json:"magnetUri"`
	UpdatedAt int64  `json:"updatedAt"`
	Name      string `json:"name"`
	Folder    string `json:"folder"`
	State     string `json:"state"`
	Peers     int    `json:"peers"`
	Seeds     int    `json:"seeds"`
}

type ServerState added in v0.8.0

type ServerState int
const (
	UNKNOWN ServerState = iota
	SEEDING
	READING
	UPDATING
	STOPPED
	ERROR
)

func (ServerState) String added in v0.8.0

func (ss ServerState) String() string

type Service

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

func NewService

func NewService(loaders []loader.Loader, db loader.LoaderAdder, stats *Stats, c *torrent.Client, addTimeout, readTimeout int, continueWhenAddTimeout bool) *Service

func (*Service) AddMagnet

func (s *Service) AddMagnet(r, m string) error

func (*Service) Load

func (s *Service) Load() (map[string]fs.Filesystem, error)

func (*Service) RemoveFromHash

func (s *Service) RemoveFromHash(r, h string) error

type Stats

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

func NewStats

func NewStats() *Stats

func (*Stats) Add

func (s *Stats) Add(route string, t *torrent.Torrent)

func (*Stats) AddRoute added in v0.8.0

func (s *Stats) AddRoute(route string)

func (*Stats) Del

func (s *Stats) Del(route, hash string)

func (*Stats) GlobalStats

func (s *Stats) GlobalStats() *GlobalTorrentStats

func (*Stats) RoutesStats

func (s *Stats) RoutesStats() []*RouteStats

func (*Stats) Stats

func (s *Stats) Stats(hash string) (*TorrentStats, error)

type TorrentStats

type TorrentStats struct {
	Name            string        `json:"name"`
	Hash            string        `json:"hash"`
	DownloadedBytes int64         `json:"downloadedBytes"`
	UploadedBytes   int64         `json:"uploadedBytes"`
	Peers           int           `json:"peers"`
	Seeders         int           `json:"seeders"`
	TimePassed      float64       `json:"timePassed"`
	PieceChunks     []*PieceChunk `json:"pieceChunks"`
	TotalPieces     int           `json:"totalPieces"`
	PieceSize       int64         `json:"pieceSize"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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