Documentation ¶
Index ¶
- Constants
- func CheckPiece(piece []byte, m *MetaInfo, pieceIndex int) (good bool, err error)
- func CheckPieces(fs file.FileStore, totalLength int64, m *MetaInfo) (good, bad int, goodBits *bitset.Bitset, err error)
- func SaveMetaInfo(metadata string) (err error)
- func WriteMetaInfoBytes(root, tracker string, w io.Writer) (err error)
- type ExclusionPattern
- type FileStoreFileAdapter
- type FileStoreFileSystemAdapter
- type MetaDataExchange
- type MetaInfo
- type MetaInfoFile
- type MetaInfoFileSystem
- type OSMetaInfoFileSystem
- type SessionInfo
- type TrackerResponse
Constants ¶
View Source
const MinimumPieceLength = 16 * 1024
View Source
const TargetPieceCountLog2 = 10
View Source
const TargetPieceCountMax = TargetPieceCountMin << 1
Target piece count should be < TargetPieceCountMax
View Source
const TargetPieceCountMin = 1 << TargetPieceCountLog2
Variables ¶
This section is empty.
Functions ¶
func CheckPieces ¶
func SaveMetaInfo ¶
Types ¶
type ExclusionPattern ¶
type ExclusionPattern struct {
// contains filtered or unexported fields
}
ExclusionPattern defines a slice of patterns that will be excluded when filtering the files to add to the .torrent:
func DefaultExPattern ¶
func DefaultExPattern() *ExclusionPattern
func (*ExclusionPattern) Add ¶
func (e *ExclusionPattern) Add(pattern ...string)
func (*ExclusionPattern) Matches ¶
func (e *ExclusionPattern) Matches(path string) bool
Matches retruns true if any of the stored patterns match the string
type FileStoreFileAdapter ¶
type FileStoreFileAdapter struct {
// contains filtered or unexported fields
}
func (*FileStoreFileAdapter) Close ¶
func (f *FileStoreFileAdapter) Close() (err error)
type FileStoreFileSystemAdapter ¶
type FileStoreFileSystemAdapter struct {
// contains filtered or unexported fields
}
Adapt a MetaInfoFileSystem into a torrent file store FileSystem
func (*FileStoreFileSystemAdapter) Close ¶
func (f *FileStoreFileSystemAdapter) Close() error
type MetaDataExchange ¶
type MetaInfo ¶
type MetaInfo struct { Info file.InfoDict InfoHash string Announce string AnnounceList [][]string `bencode:"announce-list"` CreationDate string `bencode:"creation date"` Comment string CreatedBy string `bencode:"created by"` Encoding string }
func GetMetaInfo ¶
func Index ¶
func Index(fileSystem MetaInfoFileSystem, root, tracker string, pieceLength int64, wantMD5Sum bool) (*MetaInfo, error)
Create a MetaInfo for a given file and file system. If fs is nil then the OSMetaInfoFileSystem will be used. If pieceLength is 0 then an optimal piece length will be chosen.
func (*MetaInfo) UpdateInfoHash ¶
Updates the InfoHash field. Call this after manually changing the Info data.
type MetaInfoFile ¶
type MetaInfoFileSystem ¶
type OSMetaInfoFileSystem ¶
type OSMetaInfoFileSystem struct {
// contains filtered or unexported fields
}
func (*OSMetaInfoFileSystem) Open ¶
func (o *OSMetaInfoFileSystem) Open(name string) (MetaInfoFile, error)
type SessionInfo ¶
type TrackerResponse ¶
type TrackerResponse struct { FailureReason string `bencode:"failure reason"` WarningMessage string `bencode:"warning message"` Interval uint MinInterval uint `bencode:"min interval"` TrackerId string `bencode:"tracker id"` Complete uint Incomplete uint Peers string Peers6 string }
func TrackerInfo ¶
func TrackerInfo(dialer proxy.Dialer, url string) (tr *TrackerResponse, err error)
Click to show internal directories.
Click to hide internal directories.