metainfo

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package metainfo support for reading and writing torrent files.

Index

Constants

This section is empty.

Variables

View Source
var Creator string

Creator is the string that is put into the created torrent by NewBytes function.

Functions

func NewBytes

func NewBytes(info []byte, trackers [][]string, webseeds []string, comment string) ([]byte, error)

NewBytes creates a new torrent metadata file from given information.

func NewInfoBytes

func NewInfoBytes(root string, paths []string, private bool, pieceLength uint32, name string, log logger.Logger) ([]byte, error)

NewInfoBytes creates a new Info dictionary by reading and hashing the files on the disk.

Types

type File

type File struct {
	Length int64
	Path   string
}

File represents a file inside a Torrent.

type Info

type Info struct {
	PieceLength uint32
	Name        string
	Hash        [20]byte
	Length      int64
	NumPieces   uint32
	Bytes       []byte
	Private     bool
	Files       []File
	// contains filtered or unexported fields
}

Info contains information about torrent.

func NewInfo

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

NewInfo returns info from bencoded bytes in b.

func (*Info) PieceHash

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

PieceHash returns the hash of a piece at index.

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