torrent

package
v0.0.0-...-d842a55 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventStarted   = "started"
	EventCompleted = "completed"
	EventStopped   = "stopped"
)

Variables

This section is empty.

Functions

func CalculateSha1

func CalculateSha1(b []byte) []byte

func PingTracker

func PingTracker(t Torrent) []byte

Types

type File

type File struct {
	Length int      `bencode:"length"`
	Path   []string `bencode:"path"`
	Name   string   `bencode:"name"`
}

type Info

type Info struct {
	Name        string `bencode:"name"`
	PieceLength int    `bencode:"piece length"`
	Pieces      string `bencode:"pieces"`
	Length      int    `bencode:"length"` //length of the file in bytes
	Files       []File `bencode:"files"`
	Private     int    `bencode:"private"`
	Entropy     string `bencode:"entropy"`
	Source      string `bencode:"source"`
	XCrossSeed  string `bencode:"x cross seed"`
}

type Peer

type Peer struct {
	// does not appear in compact mode
	ID   string `bencode:"peer id"` // 20 bytes + 3 bytes bencoding overhead
	IP   net.IP `bencode:"ip"`      // max 225 bytes + 4bytes bencoding overhead
	Port uint16 `bencode:"port"`    // max 7 bytes +
}

comapct form - each peer is represented using only 6 bytes first 4 byte contain the 32-bit ipv4 address last 2 byte contain the port number network byte order is used

func ParsePeerList

func ParsePeerList(tr TrackerResponse) []Peer

type Torrent

type Torrent struct {
	Announce     string        `bencode:"announce"`
	AnnounceList []interface{} `bencode:"announce-list"`
	Comment      string        `bencode:"comment"`
	CreationDate int           `bencode:"creation date"`
	InfoByte     []byte        `bencode:"info"`
	Info         Info
	HTTPSeeds    []interface{} `bencode:"http seeds"`
	Checksum     string        `bencode:"checksum"`
	CreatedBy    string        `bencode:"created by"`
	Encoding     string        `bencode:"encoding"`
}

type TrackerRequest

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

type TrackerResponse

type TrackerResponse struct {
	FailureReason string `bencode:"failureReason"`
	Interval      int    `bencode:"interval"`
	PeerData      string `bencode:"peers"`
	Peers         []Peer
}

func ParseTrackerResponse

func ParseTrackerResponse(b []byte) TrackerResponse

Jump to

Keyboard shortcuts

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