Documentation ¶
Index ¶
- type Batch
- type Builder
- func (b *Builder) AddAnnounceGroup(group []string)
- func (b *Builder) AddDhtNodes(group []string)
- func (b *Builder) AddFile(filename string)
- func (b *Builder) AddWebSeedURL(url string)
- func (b *Builder) SetComment(comment string)
- func (b *Builder) SetCreatedBy(createdby string)
- func (b *Builder) SetCreationDate(date time.Time)
- func (b *Builder) SetEncoding(encoding string)
- func (b *Builder) SetName(name string)
- func (b *Builder) SetPieceLength(length int64)
- func (b *Builder) SetPrivate(v bool)
- func (b *Builder) Submit() (*Batch, error)
- type FileInfo
- type Info
- type InfoEx
- type MetaInfo
- type Piece
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
Batch represents a snapshot of a builder state, ready for transforming it into a torrent file. Note that Batch contains two accessor methods you might be interested in. The TotalSize is the total size of all the files queued for hashing, you will use it for status reporting. The DefaultName is an automatically determined name of the torrent metainfo, you might want to use it for naming the .torrent file itself.
func (*Batch) DefaultName ¶
Get an automatically determined name of the future torrent metainfo. You can use it for a .torrent file in case user hasn't provided it specifically.
func (*Batch) Start ¶
Starts a process of building the torrent file. This function does everything in a separate goroutine and uses up to 'nworkers' of goroutines to perform SHA1 hashing. Therefore it will return almost immedately. It returns two channels, the first one is for completion awaiting, the second one is for getting status reports. Status report is a number of bytes hashed, you can get the total amount of bytes by inspecting the Batch.TotalSize method return value.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
The Builder type is responsible for .torrent files construction. Just instantiate it, call necessary methods and then call the .Build method. While waiting for completion you can use 'status' channel to get status reports.
func (*Builder) AddAnnounceGroup ¶
Add announce URL group. TODO: better explanation.
func (*Builder) AddDhtNodes ¶
Add DHT nodes URLs for trackerless mode
func (*Builder) AddWebSeedURL ¶
Add WebSeed URL to the list.
func (*Builder) SetComment ¶
Sets the comment. The default is no comment.
func (*Builder) SetCreatedBy ¶
Sets the "created by" parameter. The default is "libtorgo".
func (*Builder) SetCreationDate ¶
Sets creation date. The default is time.Now() when the .Build method was called.
func (*Builder) SetEncoding ¶
Sets the "encoding" parameter. The default is "UTF-8".
func (*Builder) SetName ¶
Defines a name of the future torrent file. For single file torrents it's the recommended name of the contained file. For multiple files torrents it's the recommended name of the directory in which all of them will be stored. Calling this function is not required. In case if no name was specified, the builder will try to automatically assign it. It will use the name of the file if there is only one file in the queue or it will try to find the rightmost common directory of all the queued files and use its name as a torrent name. In case if name cannot be assigned automatically, it will use "unknown" as a torrent name.
func (*Builder) SetPieceLength ¶
Sets the length of a piece in the torrent file in bytes. The default is 256kb.
func (*Builder) SetPrivate ¶
Sets the "private" flag. The default is false.
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) 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 ¶
The info dictionary with its hash and raw bytes exposed, as these are important to Bittorrent.
func (InfoEx) MarshalBencode ¶
func (*InfoEx) UnmarshalBencode ¶
type MetaInfo ¶
type MetaInfo struct { Info InfoEx `bencode:"info"` Announce string `bencode:"announce,omitempty"` AnnounceList [][]string `bencode:"announce-list,omitempty"` Nodes [][]string `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.