Documentation ¶
Index ¶
- Constants
- Variables
- func AddMagnet(path string, magnet string) int
- func AddTorrent(file string) int
- func AddTorrentFromBytes(path string, buf []byte) int
- func AddTorrentFromURL(path string, url string) int
- func CheckTorrent(i int)
- func Close()
- func CloseMetaInfo()
- func Count() int
- func Create() bool
- func CreateMetaInfo(root string) int
- func CreateTorrentFile(root string) []byte
- func CreateTorrentFileFromMetaInfo() []byte
- func CreateTorrentFromMetaInfo() int
- func DownloadMetadata(i int) bool
- func Error() string
- func GetTorrent(i int) []byte
- func HashMetaInfo(piece int) bool
- func ListenAddr() string
- func LoadTorrent(path string, buf []byte) int
- func MetaTorrent(i int) bool
- func Pause()
- func Paused() bool
- func PendingCompleted(i int) bool
- func Port(i int) string
- func PortCheck() bool
- func PortCount() int
- func RemoveTorrent(i int)
- func Resume()
- func SaveTorrent(i int) []byte
- func SetClientVersion(str string)
- func SetDefaultAnnouncesList(str string)
- func StartTorrent(i int) bool
- func StopTorrent(i int)
- func TorrentActive(i int) bool
- func TorrentBytesCompleted(i int) int64
- func TorrentBytesLength(i int) int64
- func TorrentFileRename(i int, f int, n string) bool
- func TorrentFilesCheck(i int, p int, b bool)
- func TorrentFilesCount(i int) int
- func TorrentHash(i int) string
- func TorrentMagnet(i int) string
- func TorrentMetainfo(i int) *metainfo.MetaInfo
- func TorrentName(i int) string
- func TorrentPeersCount(i int) int
- func TorrentPendingBytesCompleted(i int) int64
- func TorrentPendingBytesLength(i int) int64
- func TorrentPieceLength(i int) int64
- func TorrentPiecesCompact(i int, p int) int32
- func TorrentPiecesCompactCount(i int, size int) int
- func TorrentPiecesCount(i int) int
- func TorrentRename(i int, n string) bool
- func TorrentSetName(i int, n string)
- func TorrentStatus(i int) int32
- func TorrentTrackerAdd(i int, addr string)
- func TorrentTrackerRemove(i int, url string)
- func TorrentTrackersCount(i int) int
- func WaitAll() bool
- type BytesInfo
- type File
- type InfoTorrent
- type Int64Slice
- type LPDConn
- type LPDServer
- type Peer
- type StatsTorrent
- type TorrentState
- type Tracker
Constants ¶
Variables ¶
var ( SocketsPerTorrent int = 40 BindAddr string = ":53007" )
var ActiveCount = 3
var QueueTimeout = (30 * time.Minute).Nanoseconds()
var (
RefreshPort = (1 * time.Minute).Nanoseconds()
)
Functions ¶
func AddTorrentFromBytes ¶
func CheckTorrent ¶
func CheckTorrent(i int)
CheckTorrent
Check torrent file consisteny (pices hases) on a disk. Pause torrent if downloading, resume after.
func CloseMetaInfo ¶
func CloseMetaInfo()
func CreateMetaInfo ¶
func CreateTorrentFile ¶
func CreateTorrentFileFromMetaInfo ¶
func CreateTorrentFileFromMetaInfo() []byte
func CreateTorrentFromMetaInfo ¶
func CreateTorrentFromMetaInfo() int
func DownloadMetadata ¶
Download only metadata from magnet link and stop torrent
func HashMetaInfo ¶
func ListenAddr ¶
func ListenAddr() string
func MetaTorrent ¶
func PendingCompleted ¶
func SaveTorrent ¶
SaveTorrent
Every torrent application restarts it require to check files consistency. To avoid this, and save machine time we need to store torrents runtime states completed pieces and other information externaly.
Save runtime torrent data to state file
func SetClientVersion ¶
func SetClientVersion(str string)
func SetDefaultAnnouncesList ¶
func SetDefaultAnnouncesList(str string)
func StartTorrent ¶
Separate load / create torrent from network activity.
Start announce torrent, seed/download
func TorrentActive ¶
func TorrentBytesCompleted ¶
func TorrentBytesLength ¶
func TorrentFileRename ¶
TorrentFileRename
To implement this we need to keep two Metainfo one for network operations, and second for local file storage.
func TorrentFilesCheck ¶
func TorrentFilesCount ¶
func TorrentHash ¶
func TorrentMetainfo ¶
func TorrentName ¶
func TorrentPeersCount ¶
func TorrentPendingBytesCompleted ¶
Get total bytes downloaded by pending pieces list
func TorrentPendingBytesLength ¶
Get total bytes for pending pieces list
func TorrentPieceLength ¶
func TorrentPiecesCompact ¶
func TorrentPiecesCount ¶
func TorrentRename ¶
func TorrentSetName ¶
func TorrentStatus ¶
func TorrentTrackerAdd ¶
func TorrentTrackerRemove ¶
func TorrentTrackersCount ¶
Types ¶
type InfoTorrent ¶
type InfoTorrent struct { Creator string CreateOn int64 Comment string DateAdded int64 DateCompleted int64 }
func TorrentInfo ¶
func TorrentInfo(i int) *InfoTorrent
type Int64Slice ¶
type Int64Slice []int64
func (Int64Slice) Len ¶
func (p Int64Slice) Len() int
func (Int64Slice) Less ¶
func (p Int64Slice) Less(i, j int) bool
func (Int64Slice) Sort ¶
func (p Int64Slice) Sort()
func (Int64Slice) Swap ¶
func (p Int64Slice) Swap(i, j int)
type Peer ¶
type Peer struct { Id [20]byte Name string Addr string Source string // Peer is known to support encryption. SupportsEncryption bool PiecesCompleted int // how many data we downloaded/uploaded from peer Downloaded int64 Uploaded int64 }
func TorrentPeers ¶
type StatsTorrent ¶
func TorrentStats ¶
func TorrentStats(i int) *StatsTorrent
type TorrentState ¶
type TorrentState struct { Version int `json:"version"` // metainfo or these InfoHash *metainfo.Hash `json:"hash,omitempty"` Name string `json:"name,omitempty"` Trackers [][]string `json:"trackers,omitempty"` MetaInfo *metainfo.MetaInfo `json:"metainfo,omitempty"` Pieces []bool `json:"pieces,omitempty"` Root string `json:root,omitempty` Checks []bool `json:"checks,omitempty"` // Stats bytes Downloaded int64 `json:"downloaded,omitempty"` Uploaded int64 `json:"uploaded,omitempty"` // dates AddedDate int64 `json:"added_date,omitempty"` CompletedDate int64 `json:"completed_date,omitempty"` // time DownloadingTime int64 `json:"downloading_time,omitempty"` SeedingTime int64 `json:"seeding_time,omitempty"` // .torrent Comment string `json:"comment,omitempty"` Creator string `json:"creator,omitempty"` CreatedOn int64 `json:"created_on,omitempty"` }