metainfo

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package metainfo support for reading and writing torrent files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileDict

type FileDict struct {
	Length int64    `bencode:"length" json:"length"`
	Path   []string `bencode:"path" json:"path"`
}

type Info

type Info struct {
	PieceLength uint32     `bencode:"piece length" json:"piece_length"`
	Pieces      []byte     `bencode:"pieces" json:"pieces"`
	Private     byte       `bencode:"private" json:"private"`
	Name        string     `bencode:"name" json:"name"`
	Length      int64      `bencode:"length" json:"length"` // Single File Mode
	Files       []FileDict `bencode:"files" json:"files"`   // Multiple File mode

	// Calculated fileds
	Hash        [20]byte `bencode:"-" json:"-"`
	PieceHashes [][]byte `bencode:"-" json:"-"`
	TotalLength int64    `bencode:"-" json:"-"`
	NumPieces   uint32   `bencode:"-" json:"-"`
	MultiFile   bool     `bencode:"-" json:"-"`
	InfoSize    uint32   `bencode:"-" json:"-"`
	Bytes       []byte   `bencode:"-" json:"-"`
}

Info contains information about torrent.

func NewInfo

func NewInfo(b []byte) (*Info, error)

NewInfo returns info from bencoded bytes in b.

func (*Info) GetFiles

func (i *Info) GetFiles() []FileDict

GetFiles returns the files in torrent as a slice, even if there is a single file.

type MetaInfo

type MetaInfo struct {
	Info         *Info              `bencode:"-"`
	RawInfo      bencode.RawMessage `bencode:"info" json:"-"`
	Announce     string             `bencode:"announce"`
	AnnounceList [][]string         `bencode:"announce-list"`
	CreationDate int64              `bencode:"creation date"`
	Comment      string             `bencode:"comment"`
	CreatedBy    string             `bencode:"created by"`
	Encoding     string             `bencode:"encoding"`
}

MetaInfo file dictionary

func New

func New(r io.Reader) (*MetaInfo, error)

New returns a torrent from bencoded stream.

func (*MetaInfo) GetTrackers

func (m *MetaInfo) GetTrackers() []string

Jump to

Keyboard shortcuts

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