meta

package
v0.0.0-...-fb43f42 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2017 License: MIT Imports: 22 Imported by: 0

Documentation

Index

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 CheckPiece

func CheckPiece(piece []byte, m *MetaInfo, pieceIndex int) (good bool, err error)

func CheckPieces

func CheckPieces(fs file.FileStore, totalLength int64, m *MetaInfo) (good, bad int, goodBits *bitset.Bitset, err error)

func SaveMetaInfo

func SaveMetaInfo(metadata string) (err error)

func WriteMetaInfoBytes

func WriteMetaInfoBytes(root, tracker string, w io.Writer) (err error)

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)

func (*FileStoreFileAdapter) ReadAt

func (f *FileStoreFileAdapter) ReadAt(p []byte, off int64) (n int, err error)

func (*FileStoreFileAdapter) WriteAt

func (f *FileStoreFileAdapter) WriteAt(p []byte, off int64) (n int, 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

func (*FileStoreFileSystemAdapter) Open

func (f *FileStoreFileSystemAdapter) Open(name []string, length int64) (file file.File, err error)

type MetaDataExchange

type MetaDataExchange struct {
	Transferring bool
	Pieces       [][]byte
}

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 GetMetaInfo(dialer proxy.Dialer, torrent string) (metaInfo *MetaInfo, err error)

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) Bencode

func (m *MetaInfo) Bencode(w io.Writer) (err error)

Encode to Bencode, but only encode non-default values.

func (*MetaInfo) UpdateInfoHash

func (m *MetaInfo) UpdateInfoHash(metaInfo *MetaInfo) (err error)

Updates the InfoHash field. Call this after manually changing the Info data.

type MetaInfoFile

type MetaInfoFile interface {
	io.Closer
	io.Reader
	io.ReaderAt
	Readdirnames(n int) (names []string, err error)
	Stat() (os.FileInfo, error)
}

type MetaInfoFileSystem

type MetaInfoFileSystem interface {
	Open(name string) (MetaInfoFile, error)
	Stat(name string) (os.FileInfo, error)
}

type OSMetaInfoFileSystem

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

func (*OSMetaInfoFileSystem) Open

func (o *OSMetaInfoFileSystem) Open(name string) (MetaInfoFile, error)

func (*OSMetaInfoFileSystem) Stat

func (o *OSMetaInfoFileSystem) Stat(name string) (os.FileInfo, error)

type SessionInfo

type SessionInfo struct {
	PeerID       string
	Port         uint16
	OurAddresses map[string]bool //List of addresses that resolve to ourselves.
	Uploaded     uint64
	Downloaded   uint64
	Left         uint64

	UseDHT      bool
	FromMagnet  bool
	HaveTorrent bool

	OurExtensions map[int]string
	ME            *MetaDataExchange
}

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)

Jump to

Keyboard shortcuts

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