Back to Site
Loading...
Searching...
No Matches
librats::Bittorrent Class Referencefinal

#include <bittorrent.h>

Inheritance diagram for librats::Bittorrent:
[legend]
Collaboration diagram for librats::Bittorrent:
[legend]

Classes

struct  Config

Public Types

using MetadataCallback

Public Member Functions

 Bittorrent ()=default
 Bittorrent (Config config)
 Bittorrent (const bittorrent::Client::Config &client_config)
 Convenience: configure the underlying client directly, share the node DHT.
 ~Bittorrent () override
 Bittorrent (const Bittorrent &)=delete
Bittorrent & operator= (const Bittorrent &)=delete
void attach (NodeContext &ctx) override
void start () override
void stop () override
bittorrent::Client * client () noexcept
 The underlying client — drive torrents through it (add_magnet, add_torrent_file, add_torrent_for_seeding, …).
const bittorrent::Client * client () const noexcept
bool is_running () const
bool using_node_dht () const noexcept
 True when start() borrowed the node's DHT rather than running DHT-less.
void set_spider_mode (bool enable)
bool is_spider_mode () const
void set_spider_announce_callback (SpiderAnnounceCallback callback)
void set_spider_ignore (bool ignore)
bool is_spider_ignoring () const
void spider_walk ()
size_t spider_pool_size () const
size_t spider_visited_count () const
void clear_spider_state ()
void get_torrent_metadata (const std::string &info_hash_hex, MetadataCallback callback, int timeout_ms=60000)
 Fetch metadata by searching the DHT/trackers for peers that have it.
void get_torrent_metadata_from_peer (const std::string &info_hash_hex, const std::string &ip, uint16_t port, MetadataCallback callback, int timeout_ms=60000)
 Fetch metadata directly from a known peer (the fast path used when a spider announce told us exactly who has it).
Public Member Functions inherited from librats::Subsystem
virtual ~Subsystem ()=default

Detailed Description

Definition at line 44 of file bittorrent.h.

Member Typedef Documentation

◆ MetadataCallback

Initial value:
std::function<void(const bittorrent::TorrentInfo& info, bool success,
const std::string& error)>

Definition at line 103 of file bittorrent.h.

Constructor & Destructor Documentation

◆ Bittorrent() [1/4]

librats::Bittorrent::Bittorrent ( )
default

Referenced by Bittorrent(), and operator=().

◆ Bittorrent() [2/4]

librats::Bittorrent::Bittorrent ( Config config)
explicit

◆ Bittorrent() [3/4]

librats::Bittorrent::Bittorrent ( const bittorrent::Client::Config & client_config)
explicit

Convenience: configure the underlying client directly, share the node DHT.

◆ ~Bittorrent()

librats::Bittorrent::~Bittorrent ( )
override

◆ Bittorrent() [4/4]

librats::Bittorrent::Bittorrent ( const Bittorrent & )
delete

References Bittorrent().

Member Function Documentation

◆ attach()

void librats::Bittorrent::attach ( NodeContext & ctx)
overridevirtual

Implements librats::Subsystem.

◆ clear_spider_state()

void librats::Bittorrent::clear_spider_state ( )

◆ client() [1/2]

const bittorrent::Client * librats::Bittorrent::client ( ) const
inlinenoexcept

Definition at line 69 of file bittorrent.h.

◆ client() [2/2]

bittorrent::Client * librats::Bittorrent::client ( )
inlinenoexcept

The underlying client — drive torrents through it (add_magnet, add_torrent_file, add_torrent_for_seeding, …).

Non-null between start() and stop(); nullptr otherwise.

Definition at line 68 of file bittorrent.h.

◆ get_torrent_metadata()

void librats::Bittorrent::get_torrent_metadata ( const std::string & info_hash_hex,
MetadataCallback callback,
int timeout_ms = 60000 )

Fetch metadata by searching the DHT/trackers for peers that have it.

◆ get_torrent_metadata_from_peer()

void librats::Bittorrent::get_torrent_metadata_from_peer ( const std::string & info_hash_hex,
const std::string & ip,
uint16_t port,
MetadataCallback callback,
int timeout_ms = 60000 )

Fetch metadata directly from a known peer (the fast path used when a spider announce told us exactly who has it).

◆ is_running()

bool librats::Bittorrent::is_running ( ) const
inline

Definition at line 71 of file bittorrent.h.

◆ is_spider_ignoring()

bool librats::Bittorrent::is_spider_ignoring ( ) const

◆ is_spider_mode()

bool librats::Bittorrent::is_spider_mode ( ) const

◆ operator=()

Bittorrent & librats::Bittorrent::operator= ( const Bittorrent & )
delete

References Bittorrent().

◆ set_spider_announce_callback()

void librats::Bittorrent::set_spider_announce_callback ( SpiderAnnounceCallback callback)

◆ set_spider_ignore()

void librats::Bittorrent::set_spider_ignore ( bool ignore)

◆ set_spider_mode()

void librats::Bittorrent::set_spider_mode ( bool enable)

◆ spider_pool_size()

size_t librats::Bittorrent::spider_pool_size ( ) const

◆ spider_visited_count()

size_t librats::Bittorrent::spider_visited_count ( ) const

◆ spider_walk()

void librats::Bittorrent::spider_walk ( )

◆ start()

void librats::Bittorrent::start ( )
overridevirtual

Implements librats::Subsystem.

◆ stop()

void librats::Bittorrent::stop ( )
overridevirtual

Implements librats::Subsystem.

◆ using_node_dht()

bool librats::Bittorrent::using_node_dht ( ) const
inlinenoexcept

True when start() borrowed the node's DHT rather than running DHT-less.

Definition at line 73 of file bittorrent.h.


The documentation for this class was generated from the following file: