mktorrent

package module
v0.0.0-...-4561e0b Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2018 License: GPL-3.0 Imports: 10 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

mktorrent

GoDoc

Everything you need to make torrent files in pure Go.

autotorrent

~/.config/autotorrent.toml will be loaded automatically:

[[profile]]
name = "green"
announce = ["http://localhost/announce"]
source = "GREEN"
private = true
max_piece_length = "16 mb"

[[profile]]
name = "yellow"
announce = ["http://localhost/announce", "udp://localhost:3000"]
source = "YELLOW"
private = false

Create a torrent with profile "green" settings:

$ autotorrent green file/or/directory
 473 / 1100 [================>----------------------]  43.00% 49s

Quick start

GOPATH=/tmp
go get -u github.com/zeebo/bencode \
    github.com/cheggaaa/pb \
    github.com/BurntSushi/toml \
    github.com/c2h5oh/datasize \
    github.com/pkg/errors \
    github.com/varyoo/mktorrent
cd mktorrent/autotorrent
go build
./autotorrent

Documentation

Index

Constants

View Source
const (
	AutoMinPieceLength int64 = 16384    // 2^14
	AutoMaxPieceLength       = 67108864 // 2^26
)

Variables

View Source
var NoProgress *noProgress = nil

Functions

This section is empty.

Types

type Buffer

type Buffer interface {
	WriteTo(io.Writer) error
}

type Digest

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

Digest needs to be constructed by NewHash.

func NewHash

func NewHash(pieceSize, pieceCount int64, goroutines int, pro Progress) *Digest

func (*Digest) Close

func (d *Digest) Close() error

func (*Digest) Complete

func (d *Digest) Complete() ([]byte, error)

Complete completes the hash first by appending to it the last irregular piece. Complete then returns the complete hash or error if any.

func (*Digest) ReadFrom

func (d *Digest) ReadFrom(r io.Reader) (int64, error)

ReadFrom hashes data from r until EOF or error.

It returns the number of bytes read. Any error except io.EOF encountered during the read is also returned.

func (*Digest) String

func (d *Digest) String() string

String returns the hexadecimal encoding of the hash if complete. If not it returns "".

type File

type File struct {
	Length int64    `bencode:"length"`
	Path   []string `bencode:"path"`
}

type Filesystem

type Filesystem struct {
	Torrent

	PieceCount int64
	RealPaths  []string
}

Filesystem can make torrents from your files or directories.

func NewFilesystem

func NewFilesystem(ps Params) (*Filesystem, error)

func (Filesystem) MakeTorrent

func (fs Filesystem) MakeTorrent(goroutines int, pro Progress) (Buffer, error)

func (*Filesystem) NewHash

func (fs *Filesystem) NewHash(goroutines int, pro Progress) *Digest

type Info

type Info struct {
	PieceLength int64  `bencode:"piece length"`
	Pieces      string `bencode:"pieces"`
	Source      string `bencode:"source,omitempty"`
	Private     bool   `bencode:"private,omitempty"`
	Name        string `bencode:"name"`

	Files       []File `bencode:"files,omitempty"`  // multi-file mode only
	TotalLength int64  `bencode:"length,omitempty"` // single-file mode only
}

type Params

type Params struct {
	Path         string
	PieceLength  PieceLength
	Source       string
	Private      bool
	AnnounceList []string
}

type PieceLength

type PieceLength func(length int64) int64

func BoundPieceLength

func BoundPieceLength(min, max int64) PieceLength

func MaxPieceLength

func MaxPieceLength(max int64) PieceLength

type Progress

type Progress interface {
	Increment() int
}

type Torrent

type Torrent struct {
	AnnounceList [][]string `bencode:"announce-list,omitempty"`
	Announce     string     `bencode:"announce,omitempty"`
	CreationDate int64      `bencode:"creation date,omitempty"`
	Comment      string     `bencode:"comment,omitempty"`
	CreatedBy    string     `bencode:"created by,omitempty"`
	UrlList      string     `bencode:"url-list,omitempty"`

	Info `bencode:"info"`
}

func (*Torrent) ReadFrom

func (t *Torrent) ReadFrom(r io.Reader) error

func (*Torrent) WriteTo

func (t *Torrent) WriteTo(w io.Writer) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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