torrent

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package torrent provides convenient functions for Torrent type

Index

Constants

View Source
const FileExtension = ".torrent.json"

FileExtension is the default torrent file extension

Variables

View Source
var FileSizeMismatchError = errors.New("recorded file size in torrent does not match the actual one")
View Source
var File_pkg_torrent_torrent_proto protoreflect.FileDescriptor

Functions

func Verify

func Verify(file *os.File, torrent *Torrent) error

Verify checks if given file is indeed a torrent data file

func Write

func Write(writer io.Writer, torrent *Torrent) error

Write writes given torrent to a writer

Types

type Torrent

type Torrent struct {
	FileName       string   `protobuf:"bytes,1,opt,name=file_name,json=fileName,proto3" json:"file_name,omitempty"`
	FileHash       string   `protobuf:"bytes,2,opt,name=file_hash,json=fileHash,proto3" json:"file_hash,omitempty"`
	FileSize       int64    `protobuf:"varint,3,opt,name=file_size,json=fileSize,proto3" json:"file_size,omitempty"`
	PieceSize      int64    `protobuf:"varint,4,opt,name=piece_size,json=pieceSize,proto3" json:"piece_size,omitempty"`
	PieceHashes    []string `protobuf:"bytes,5,rep,name=piece_hashes,json=pieceHashes,proto3" json:"piece_hashes,omitempty"`
	TrackerAddress string   `protobuf:"bytes,6,opt,name=tracker_address,json=trackerAddress,proto3" json:"tracker_address,omitempty"`
	// contains filtered or unexported fields
}

func Create

func Create(file *os.File, pieceSize int64, trackerAddr string) (*Torrent, error)

Create makes a new torrent from file

func Read

func Read(reader io.Reader) (*Torrent, error)

Read reads torrent from a reader

func (*Torrent) Descriptor deprecated

func (*Torrent) Descriptor() ([]byte, []int)

Deprecated: Use Torrent.ProtoReflect.Descriptor instead.

func (*Torrent) GetFileHash

func (x *Torrent) GetFileHash() string

func (*Torrent) GetFileName

func (x *Torrent) GetFileName() string

func (*Torrent) GetFileSize

func (x *Torrent) GetFileSize() int64

func (*Torrent) GetPieceHashes

func (x *Torrent) GetPieceHashes() []string

func (*Torrent) GetPieceSize

func (x *Torrent) GetPieceSize() int64

func (*Torrent) GetTrackerAddress

func (x *Torrent) GetTrackerAddress() string

func (*Torrent) ProtoMessage

func (*Torrent) ProtoMessage()

func (*Torrent) ProtoReflect

func (x *Torrent) ProtoReflect() protoreflect.Message

func (*Torrent) Reset

func (x *Torrent) Reset()

func (*Torrent) String

func (x *Torrent) String() string

Jump to

Keyboard shortcuts

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