metainfo

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 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 added in v0.16.0

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

NewBytes creates a new torrent metadata file from given information.

func NewInfoBytes added in v0.16.0

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 added in v0.16.0

type File struct {
	Length int64
	Path   string
	// https://www.bittorrent.org/beps/bep_0047.html
	Padding bool
}

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, utf8 bool, pad bool) (*Info, error)

NewInfo returns info from bencoded bytes in b.

func (*Info) PieceHash added in v0.16.0

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