meta

package
v0.0.0-...-d617ca5 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HashSize = 20
)

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context, key string) interface{}

Types

type File

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

File is file

type FileInfo

type FileInfo struct {
	Path     []string `bencode:"path"`
	PathUTF8 []string `bencode:"path.utf-8,omitempty"`
	Length   int64    `bencode:"length"`
	Ed2k     ed2k     `bencode:"ed2k,omitempty"`
	Filehash fileHash `bencode:"filehash,omitempty"`
	Download bool     `bencode:"-"`
}

func (*FileInfo) String

func (f *FileInfo) String() string

type Hash

type Hash [sha1.Size]byte

Hash is sha1 hash for Info and piece

func (Hash) String

func (h Hash) String() string

type Info

type Info struct {
	Hash             Hash       `bencode:"-"`
	Files            []FileInfo `bencode:"files,omitempty"`
	PieceLength      int        `bencode:"piece length"`
	Pieces           []byte     `bencode:"pieces"`
	Name             string     `bencode:"name,omitempty"`
	Length           int64      `bencode:"length,omitempty"`
	Private          int        `bencode:"private,omitempty"`
	Publisher        string     `bencode:"publisher"`
	PublisherUTF8    string     `bencode:"publisher.utf-8"`
	PublisherURL     string     `bencode:"publisher-url"`
	PublisherURLUTF8 string     `bencode:"publisher-url.utf-8"`
}

func (*Info) FileList

func (i *Info) FileList() []File

FileList return a list of file will download

func (*Info) UnmarshalBencode

func (i *Info) UnmarshalBencode(data []byte) error

type Node

type Node struct {
	IP   net.IP
	Port int
}

func (*Node) UnmarshalBencode

func (n *Node) UnmarshalBencode(data []byte) error

type Piece

type Piece struct {
	bytes.Buffer
	// contains filtered or unexported fields
}

Piece is a block of a file

type Torrent

type Torrent struct {
	Announce     string     `bencode:"announce,omitempty"`
	AnnounceList [][]string `bencode:"announce-list,omitempty"`
	Comment      string     `bencode:"comment,omitempty"`
	CommentUTF8  string     `bencode:"comment.utf-8,omitempty"`
	Created      string     `bencode:"created by,omitempty"`
	Date         uint       `bencode:"creation date,omitempty"`
	Encoding     string     `bencode:"encoding,omitempty"`
	Info         Info
	Nodes        []Node `bencode:"node,omitempty"`
}

Torrent load a btorrent metofile from file to memory

func NewTorrent

func NewTorrent(path string) (*Torrent, error)

NewTorrent create a torrent

func (*Torrent) SetDownload

func (t *Torrent) SetDownload(index int) error

func (*Torrent) SetFile

func (t *Torrent) SetFile(index int, download bool) error

func (*Torrent) SetIgnore

func (t *Torrent) SetIgnore(index int) error

func (*Torrent) ToContext

func (t *Torrent) ToContext(ctx context.Context) context.Context

type UnmarshalError

type UnmarshalError struct {
	Struct string
	Field  string
}

An UnmarshalError describes a fail unmarshal

func (*UnmarshalError) Error

func (e *UnmarshalError) Error() string

Jump to

Keyboard shortcuts

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