Documentation ¶
Index ¶
- type FileInfo
- type Hash
- type Info
- func (info *Info) BuildFromFilePath(root string) (err error)
- func (info *Info) GeneratePieces(open func(fi FileInfo) (io.ReadCloser, error)) error
- func (info *Info) IsDir() bool
- func (info *Info) NumPieces() int
- func (info *Info) TotalLength() (ret int64)
- func (info *Info) UpvertedFiles() []FileInfo
- type InfoEx
- type Magnet
- type MetaInfo
- type Node
- type Piece
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hash ¶
type Hash [20]byte
20-byte SHA1 hash used for info and pieces.
func (*Hash) FromHexString ¶
type Info ¶
type Info struct { PieceLength int64 `bencode:"piece length"` Pieces []byte `bencode:"pieces"` Name string `bencode:"name"` Length int64 `bencode:"length,omitempty"` Private *bool `bencode:"private,omitempty"` Files []FileInfo `bencode:"files,omitempty"` }
The info dictionary.
func (*Info) BuildFromFilePath ¶
This is a helper that sets Files and Pieces from a root path and its children.
func (*Info) GeneratePieces ¶
Set info.Pieces by hashing info.Files.
func (*Info) TotalLength ¶
func (*Info) UpvertedFiles ¶
The files field, converted up from the old single-file in the parent info dict if necessary. This is a helper to avoid having to conditionally handle single and multi-file torrent infos.
type InfoEx ¶
type InfoEx struct { Info // Set when unmarshalling, and used when marshalling. Call .UpdateBytes to // set it by bencoding Info. Bytes []byte }
A wrapper around Info that exposes the Bytes directly, in case marshalling and unmarshalling Info doesn't produce the same bytes.
func (*InfoEx) MarshalBencode ¶
func (*InfoEx) UnmarshalBencode ¶
func (*InfoEx) UpdateBytes ¶
func (ie *InfoEx) UpdateBytes()
Marshals .Info, and sets .Bytes with the result.
type Magnet ¶
Magnet link components.
func ParseMagnetURI ¶
ParseMagnetURI parses Magnet-formatted URIs into a Magnet instance
type MetaInfo ¶
type MetaInfo struct { Info InfoEx `bencode:"info"` Announce string `bencode:"announce,omitempty"` AnnounceList [][]string `bencode:"announce-list,omitempty"` Nodes []Node `bencode:"nodes,omitempty"` CreationDate int64 `bencode:"creation date,omitempty"` Comment string `bencode:"comment,omitempty"` CreatedBy string `bencode:"created by,omitempty"` Encoding string `bencode:"encoding,omitempty"` URLList interface{} `bencode:"url-list,omitempty"` }
func LoadFromFile ¶
Convenience function for loading a MetaInfo from a file.
func (*MetaInfo) SetDefaults ¶
func (mi *MetaInfo) SetDefaults()
Set good default values in preparation for creating a new MetaInfo file.