bitTorrent

package
v0.0.0-...-3638f0a Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PieceSize       = 262144
	TimeWait        = 3 * time.Second
	SHA1Len         = 20
	WorkQueueBuffer = 128
	AfterLoginSleep = time.Second
	AfterQuitSleep  = time.Second

	UploadTimeout   = time.Second
	DownloadTimeout = time.Second

	RetryTime = 2

	UploadInterval        = 100 * time.Millisecond
	DownloadInterval      = 100 * time.Millisecond
	DownloadWriteInterval = time.Second
	UploadFileInterval    = time.Second
)

Variables

This section is empty.

Functions

func GenerateAddr

func GenerateAddr(addr string, port int) string

func GetLocalIP

func GetLocalIP() string

func MakeMagnet

func MakeMagnet(infoHash string) string

func NewNode

func NewNode(port int) dhtNode

func Open

func Open(path string) (*bencodeTorrent, error)

func PiecesHash

func PiecesHash(piece DataPiece, index int) ([SHA1Len]byte, error)

func Welcome

func Welcome()

Types

type Client

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

func (*Client) Create

func (ptr *Client) Create()

func (*Client) DownLoad

func (this *Client) DownLoad(keyPackage *KeyPackage) (bool, []byte)

func (*Client) DownLoadByMagnet

func (c *Client) DownLoadByMagnet(magnet string, savePath string)

func (*Client) DownLoadByTorrent

func (ptr *Client) DownLoadByTorrent(torrentPath string, savePath string)

func (*Client) Init

func (ptr *Client) Init(port int)

func (*Client) Join

func (ptr *Client) Join(address string)

func (*Client) Quit

func (ptr *Client) Quit()

func (*Client) Upload

func (this *Client) Upload(filePath, torrentPath string)

func (*Client) UploadPackage

func (c *Client) UploadPackage(key *KeyPackage, data *DataPackage) bool

type DataPackage

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

type DataPiece

type DataPiece []byte

type KeyPackage

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

type KeyPiece

type KeyPiece [SHA1Len]byte

type Worker

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

Jump to

Keyboard shortcuts

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