Documentation
¶
Index ¶
- Constants
- Variables
- func ToSpeed(speed uint64) string
- func ToSz(sz uint64) string
- type ADNLProofScheme
- type AddUpdate
- type Connector
- func (c *Connector) CreateDownloader(ctx context.Context, t *Torrent) (_ TorrentDownloader, err error)
- func (c *Connector) GetADNLPrivateKey() ed25519.PrivateKey
- func (c *Connector) GetDownloadLimit() uint64
- func (c *Connector) GetUploadLimit() uint64
- func (c *Connector) SetDownloadLimit(bytesPerSec uint64)
- func (c *Connector) SetUploadLimit(bytesPerSec uint64)
- func (c *Connector) ThrottleDownload(ctx context.Context, sz uint64) error
- func (c *Connector) ThrottleUpload(ctx context.Context, sz uint64) error
- type DHT
- type DownloadResult
- type Event
- type FDesc
- type FECInfoNone
- type FS
- type FSController
- type FSFile
- type FileIndex
- type FileInfo
- type FileRef
- type GetPiece
- type GetTest
- type GetTorrentInfo
- type NetConnector
- type Ok
- type OpenMode
- type PeerConnection
- type PeerInfo
- type Piece
- type PieceInfo
- type PiecesInfo
- type Ping
- type Pong
- type PreFetcher
- type Progress
- type Server
- type State
- type Storage
- type Test
- type Torrent
- func (t *Torrent) DownloadedPiecesNum() int
- func (t *Torrent) GetActiveFilesIDs() []uint32
- func (t *Torrent) GetConnector() NetConnector
- func (t *Torrent) GetFileOffsets(name string) (*FileInfo, error)
- func (t *Torrent) GetFileOffsetsByID(i uint32) (*FileInfo, error)
- func (t *Torrent) GetFilesInPiece(piece uint32) ([]*FileInfo, error)
- func (t *Torrent) GetLastVerifiedAt() (bool, time.Time)
- func (t *Torrent) GetPeer(id []byte) *PeerInfo
- func (t *Torrent) GetPeers() map[string]PeerInfo
- func (t *Torrent) GetPiece(id uint32) (*Piece, error)
- func (t *Torrent) GetPieceProof(id uint32) ([]byte, error)
- func (t *Torrent) GetUploadStats() uint64
- func (t *Torrent) InitMask()
- func (t *Torrent) IsActive() (activeDownload, activeUpload bool)
- func (t *Torrent) IsActiveRaw() (activeDownload, activeUpload bool)
- func (t *Torrent) IsCompleted() bool
- func (t *Torrent) IsDownloadAll() bool
- func (t *Torrent) IsDownloadOrdered() bool
- func (t *Torrent) ListFiles() ([]string, error)
- func (t *Torrent) LoadActiveFilesIDs() error
- func (t *Torrent) PiecesMask() []byte
- func (t *Torrent) PiecesNum() uint32
- func (t *Torrent) RemovePeer(id []byte)
- func (t *Torrent) ResetDownloadPeer(id []byte)
- func (t *Torrent) SetActiveFiles(names []string) error
- func (t *Torrent) SetActiveFilesIDs(ids []uint32) error
- func (t *Torrent) SetInfoStats(headerData, rootHash []byte, fileSize, headerSize uint64, description string)
- func (t *Torrent) SetUploadStats(val uint64)
- func (t *Torrent) Start(withUpload, downloadAll, downloadOrdered bool) (err error)
- func (t *Torrent) Stop()
- func (t *Torrent) TouchPeer(peer *storagePeer) *PeerInfo
- func (t *Torrent) UpdateDownloadedPeer(peer *storagePeer, bytes uint64)
- func (t *Torrent) UpdateUploadedPeer(peer *storagePeer, bytes uint64)
- type TorrentDownloader
- type TorrentHeader
- type TorrentInfo
- type TorrentInfoContainer
- type TorrentServer
- type TorrentStats
- type UpdateHavePieces
- type UpdateInit
- type UpdateState
Constants ¶
View Source
const ( EventErr = "ERR" EventBagResolved = "BAG_RESOLVED" EventFileDownloaded = "FILE_DOWNLOADED" EventDone = "DONE" EventPieceDownloaded = "PIECE_DOWNLOADED" EventProgress = "PROGRESS" )
Variables ¶
View Source
var DownloadMaxInflightScore = int32(400)
View Source
var DownloadPrefetch = 200
View Source
var DownloadThreads = 32
View Source
var ErrFileNotExist = errors.New("file is not exists in torrent")
View Source
var Logger = func(...any) {}
Functions ¶
Types ¶
type ADNLProofScheme ¶ added in v0.5.0
type ADNLProofScheme struct {
Key []byte `tl:"int256"`
}
type Connector ¶
type Connector struct { TorrentServer // contains filtered or unexported fields }
func NewConnector ¶
func NewConnector(srv TorrentServer) *Connector
func (*Connector) CreateDownloader ¶
func (*Connector) GetADNLPrivateKey ¶ added in v0.5.0
func (c *Connector) GetADNLPrivateKey() ed25519.PrivateKey
func (*Connector) GetDownloadLimit ¶
func (*Connector) GetUploadLimit ¶
func (*Connector) SetDownloadLimit ¶
func (*Connector) SetUploadLimit ¶
func (*Connector) ThrottleDownload ¶
type DHT ¶
type DHT interface { StoreAddress(ctx context.Context, addresses address.List, ttl time.Duration, ownerKey ed25519.PrivateKey, copies int) (int, []byte, error) FindAddresses(ctx context.Context, key []byte) (*address.List, ed25519.PublicKey, error) FindOverlayNodes(ctx context.Context, overlayId []byte, continuation ...*dht.Continuation) (*overlay.NodesList, *dht.Continuation, error) Close() }
type DownloadResult ¶
type FECInfoNone ¶
type FECInfoNone struct{}
type FSController ¶
type FSController struct {
// contains filtered or unexported fields
}
FSController caches files descriptors to avoid unnecessary open/close of most used files
func NewFSController ¶
func NewFSController() *FSController
type FileRef ¶ added in v0.2.0
type FileRef interface { GetName() string GetSize() uint64 CreateReader() (io.ReadCloser, error) }
type GetTorrentInfo ¶
type GetTorrentInfo struct{}
type NetConnector ¶
type NetConnector interface { GetADNLPrivateKey() ed25519.PrivateKey SetDownloadLimit(bytesPerSec uint64) SetUploadLimit(bytesPerSec uint64) GetUploadLimit() uint64 GetDownloadLimit() uint64 ThrottleDownload(ctx context.Context, sz uint64) error ThrottleUpload(ctx context.Context, sz uint64) error CreateDownloader(ctx context.Context, t *Torrent) (_ TorrentDownloader, err error) TorrentServer }
type PeerConnection ¶
type PeerConnection struct {
// contains filtered or unexported fields
}
func (*PeerConnection) CloseFor ¶
func (c *PeerConnection) CloseFor(peer *storagePeer)
func (*PeerConnection) FailedFor ¶ added in v0.7.0
func (c *PeerConnection) FailedFor(peer *storagePeer, failed bool)
func (*PeerConnection) GetFor ¶
func (c *PeerConnection) GetFor(id []byte) *storagePeer
func (*PeerConnection) UseFor ¶
func (c *PeerConnection) UseFor(peer *storagePeer)
type PeerInfo ¶
type PeerInfo struct { Addr string LastSeenAt time.Time Uploaded uint64 Downloaded uint64 // contains filtered or unexported fields }
func (*PeerInfo) GetDownloadSpeed ¶
func (*PeerInfo) GetUploadSpeed ¶
type PiecesInfo ¶
type PreFetcher ¶
type PreFetcher struct {
// contains filtered or unexported fields
}
func NewPreFetcher ¶
func NewPreFetcher(ctx context.Context, torrent *Torrent, downloader TorrentDownloader, report func(Event), downloaded uint64, threads, prefetch int, pieces []uint32) *PreFetcher
func (*PreFetcher) Free ¶
func (f *PreFetcher) Free(piece uint32)
func (*PreFetcher) Stop ¶
func (f *PreFetcher) Stop()
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) GetADNLPrivateKey ¶ added in v0.5.0
func (s *Server) GetADNLPrivateKey() ed25519.PrivateKey
func (*Server) GetPeerIfActive ¶
func (s *Server) GetPeerIfActive(id []byte) *PeerConnection
func (*Server) SetStorage ¶
func (*Server) StartPeerSearcher ¶
type Storage ¶
type Storage interface { GetFS() FS GetAll() []*Torrent GetTorrentByOverlay(overlay []byte) *Torrent SetTorrent(torrent *Torrent) error SetActiveFiles(bagId []byte, ids []uint32) error GetActiveFiles(bagId []byte) ([]uint32, error) GetPiece(bagId []byte, id uint32) (*PieceInfo, error) RemovePiece(bagId []byte, id uint32) error SetPiece(bagId []byte, id uint32, p *PieceInfo) error PiecesMask(bagId []byte, num uint32) []byte UpdateUploadStats(bagId []byte, val uint64) error }
type Torrent ¶
type Torrent struct { BagID []byte Path string Info *TorrentInfo Header *TorrentHeader CreatedAt time.Time // contains filtered or unexported fields }
func CreateTorrent ¶
func NewTorrent ¶
func NewTorrent(path string, db Storage, connector NetConnector) *Torrent
func (*Torrent) DownloadedPiecesNum ¶ added in v0.3.0
func (*Torrent) GetActiveFilesIDs ¶
func (*Torrent) GetConnector ¶
func (t *Torrent) GetConnector() NetConnector
func (*Torrent) GetFileOffsetsByID ¶
func (*Torrent) GetFilesInPiece ¶
func (*Torrent) GetLastVerifiedAt ¶ added in v0.6.0
func (*Torrent) GetPieceProof ¶ added in v0.2.0
func (*Torrent) GetUploadStats ¶ added in v0.3.0
func (*Torrent) IsActiveRaw ¶ added in v0.4.0
func (*Torrent) IsCompleted ¶ added in v0.3.0
func (*Torrent) IsDownloadAll ¶
func (*Torrent) IsDownloadOrdered ¶ added in v0.2.0
func (*Torrent) LoadActiveFilesIDs ¶
func (*Torrent) PiecesMask ¶
func (*Torrent) RemovePeer ¶
func (*Torrent) ResetDownloadPeer ¶
func (*Torrent) SetActiveFiles ¶
func (*Torrent) SetActiveFilesIDs ¶
func (*Torrent) SetInfoStats ¶ added in v0.7.0
func (*Torrent) SetUploadStats ¶ added in v0.3.0
func (*Torrent) UpdateDownloadedPeer ¶
func (*Torrent) UpdateUploadedPeer ¶
type TorrentDownloader ¶
type TorrentHeader ¶
type TorrentInfo ¶
type TorrentInfoContainer ¶
type TorrentInfoContainer struct {
Data []byte `tl:"bytes"`
}
type TorrentServer ¶
type TorrentServer interface { GetADNLPrivateKey() ed25519.PrivateKey StartPeerSearcher(t *Torrent) }
type TorrentStats ¶ added in v0.3.0
type TorrentStats struct {
Uploaded uint64
}
type UpdateHavePieces ¶
type UpdateHavePieces struct {
PieceIDs []int32 `tl:"vector int"`
}
type UpdateInit ¶
type UpdateState ¶
type UpdateState struct {
State State `tl:"struct boxed"`
}
Click to show internal directories.
Click to hide internal directories.