metainfo

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 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:"-"`
	TotalLength int64    `bencode:"-" json:"-"`
	NumPieces   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.

func (*Info) HashOf added in v0.6.0

func (i *Info) HashOf(index uint32) []byte

func (*Info) MultiFile

func (i *Info) MultiFile() bool

type MetaInfo

type MetaInfo struct {
	Info         *Info
	AnnounceList []string
	URLList      []string
}

MetaInfo file dictionary

func New

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

New returns a torrent from bencoded stream.

Jump to

Keyboard shortcuts

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