Documentation ¶
Index ¶
Constants ¶
View Source
const BlockSize = 16384
https://wiki.theory.org/BitTorrentSpecification#request:_.3Clen.3D0013.3E.3Cid.3D6.3E.3Cindex.3E.3Cbegin.3E.3Clength.3E Size of the block to download from a single peer 2^14
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileDict ¶
type FileDict struct { //m.Info.Files[ind].Path Length int64 Path []string Md5sum string FirstPieceInd int64 FirstOffset int64 LastPieceInd int64 LastByteLast int64 File os.File }
FileDict is the struct that contains all the information for a file in the torrent
type GoTorrent ¶
type GoTorrent struct { Meta MetaInfo TrackerIP net.IPAddr Peers []peer Interval int32 // Minimum seconds the local peer should wait before next announce. Leechers int32 Seeders int32 MyID []byte Server *net.UDPConn // contains filtered or unexported fields }
GoTorrent is the main abstraction for a torrent
func NewTorrentFromFile ¶
NewTorrentFromFile creates and returns a GoTorrent struct for the torrent file
func (*GoTorrent) DownloadAll ¶
func (t *GoTorrent) DownloadAll()
DownloadAll does the whole job and contains the logic of the downloading:
- asks for the peers
- connects with them
- starts downloading
type InfoDict ¶
type InfoDict struct { PieceLength int64 `bencode:"piece length"` Pieces string //hashes of all pieces Private int64 Name string // Single File Mode Length int64 Md5sum string // Multiple File mode Files []FileDict }
InfoDict contains information about the torrent like pieces hashes and length
type MetaInfo ¶
type MetaInfo struct { Info InfoDict InfoHash string Announce string AnnounceList [][]string `bencode:"announce-list"` CreationDate string `bencode:"creation date"` Comment string CreatedBy string `bencode:"created by"` Encoding string }
MetaInfo contains information for the torrent and the tracker
Click to show internal directories.
Click to hide internal directories.