Documentation ¶
Index ¶
- Variables
- func ConcurrentDownloads(concurrent int) func(*Client) error
- func DownloadCap(bytesPerSecond int) func(*Client) error
- func NotifyWhenDownloadComplete(notifier chan *Client) func(*Client) error
- func NotifyWhenStopped(notifier chan *Client) func(*Client) error
- func PeersWanted(wanted int) func(*Client) error
- func SeedDuration(duration time.Duration) func(*Client) error
- func UploadCap(bytesPerSecond int) func(*Client) error
- type Client
- func (c *Client) ExternalIP() string
- func (c *Client) HandleConnection(conn net.Conn, logger *slog.Logger, _ dispatcher.ProtocolExtensions, ...)
- func (c *Client) Logger() *slog.Logger
- func (c *Client) Status() *Status
- func (c *Client) Stop(timeout time.Duration)
- func (c *Client) TorrentFile() *tfs.File
- type State
- type Status
Constants ¶
This section is empty.
Variables ¶
var ( // TrackerUserAgent will be used as the http client user agent header if // not empty. TrackerUserAgent = "" )
Functions ¶
func ConcurrentDownloads ¶
ConcurrentDownloads sets the number of peers to actively download from at the same time. Default is 4.
func DownloadCap ¶
DownloadCap sets the maximum download speed of the client, subject to the dispatcher's overall limit. Default is no limit.
func NotifyWhenDownloadComplete ¶
NotifyWhenDownloadComplete sets a channel to notify when the download is verified and completes.
func NotifyWhenStopped ¶
NotifyWhenStopped sets a channel to notify when the client is stopped.
func PeersWanted ¶
PeersWanted sets the number of peers to ask the tracker for. Default is 32.
func SeedDuration ¶
SeedDuration sets the maximum amount of time to seed. Default is 4 days.
Types ¶
type Client ¶
type Client struct { InRate rate.Limiter OutRate rate.Limiter // contains filtered or unexported fields }
Client provides the ability to download and/or seed a torrent.
func NewClient ¶
func NewClient(d *dispatcher.Dispatcher, torrentFile *tfs.File, options ...func(*Client) error) (*Client, error)
NewClient creates and starts a new client for a torrent.
func (*Client) ExternalIP ¶ added in v1.0.3
ExternalIP returns our external IP address.
func (*Client) HandleConnection ¶
func (c *Client) HandleConnection(conn net.Conn, logger *slog.Logger, _ dispatcher.ProtocolExtensions, infoHash tfs.InfoHash, sendHandshake bool)
HandleConnection is called by the dispatcher for new connections.
func (*Client) Stop ¶
Stop the torrent. Does not return until the torrent has stopped or the timeout has been hit.
func (*Client) TorrentFile ¶
TorrentFile returns the client's torrent file.
type Status ¶
type Status struct { SeedingStopsAt time.Time State State PercentComplete float64 TotalBytes int64 RemainingBytes int64 UploadBytesPerSecond int DownloadBytesPerSecond int PeersDownloading int PeersConnected int Leechers int Seeders int }
Status holds the status information for a torrent.