goTorrent

package
v0.0.0-...-89f9343 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2017 License: GPL-2.0 Imports: 20 Imported by: 2

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

func NewTorrentFromFile(file string) (*GoTorrent, error)

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

func (*GoTorrent) Wait

func (t *GoTorrent) Wait()

Wait reads from a channel which means that the torrent is downloaded

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

Jump to

Keyboard shortcuts

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