9#ifndef SNBMODULES_INCLUDE_SNBMODULES_INTERFACES_TRANSFER_INTERFACE_BITTORRENT_HPP_
10#define SNBMODULES_INCLUDE_SNBMODULES_INTERFACES_TRANSFER_INTERFACE_BITTORRENT_HPP_
15#include "libtorrent/create_torrent.hpp"
16#include "libtorrent/error_code.hpp"
17#include "libtorrent/torrent_handle.hpp"
18#include "libtorrent/torrent_status.hpp"
20#include "libtorrent/add_torrent_params.hpp"
21#include "libtorrent/alert_types.hpp"
22#include "libtorrent/announce_entry.hpp"
23#include "libtorrent/bdecode.hpp"
24#include "libtorrent/bencode.hpp"
25#include "libtorrent/config.hpp"
26#include "libtorrent/disabled_disk_io.hpp"
27#include "libtorrent/disk_interface.hpp"
28#include "libtorrent/entry.hpp"
29#include "libtorrent/identify_client.hpp"
30#include "libtorrent/ip_filter.hpp"
31#include "libtorrent/load_torrent.hpp"
32#include "libtorrent/magnet_uri.hpp"
33#include "libtorrent/peer_info.hpp"
34#include "libtorrent/read_resume_data.hpp"
35#include "libtorrent/session.hpp"
36#include "libtorrent/session_params.hpp"
37#include "libtorrent/string_view.hpp"
38#include "libtorrent/time.hpp"
39#include "libtorrent/torrent_info.hpp"
40#include "libtorrent/write_resume_data.hpp"
62using clk = std::chrono::steady_clock;
64using std::chrono::duration_cast;
71 std::vector<lt::peer_info>
peers;
95 std::filesystem::path work_dir,
135 char const*
state(lt::torrent_status::state_t s);
137 bool add_magnet(lt::string_view
uri,
const std::filesystem::path& dest);
139 std::string
add_torrent(
const std::string& torrent,
const std::filesystem::path& dest);
141 void set_torrent_params(lt::add_torrent_params& p,
const std::filesystem::path& dest);
142 lt::session_params
set_settings(
const IPFormat& listen_interface,
const std::string& listen_port);
145 static std::string
branch_path(std::string
const& f);
156 const std::string& tracker,
157 const std::string& outfile);
161 void do_work(std::atomic<bool>&);
bool hash_file(TransferMetadata &f_meta) override
static std::string branch_path(std::string const &f)
TransferInterfaceBittorrent(GroupMetadata &config, bool is_client, std::filesystem::path work_dir, const IPFormat &listening_ip)
void set_torrent_params(lt::add_torrent_params &p, const std::filesystem::path &dest)
bool resume_file(TransferMetadata &f_meta) override
~TransferInterfaceBittorrent()
static std::vector< char > load_file(std::string const &filename)
std::filesystem::path m_work_dir
dunedaq::utilities::WorkerThread m_thread
void do_work(std::atomic< bool > &)
bool make_torrent(std::filesystem::path full_path, int piece_size, const std::string &tracker, const std::string &outfile)
bool download_file(TransferMetadata &f_meta, std::filesystem::path dest) override
bool pause_file(TransferMetadata &f_meta) override
static bool file_filter(std::string const &f)
bool add_magnet(lt::string_view uri, const std::filesystem::path &dest)
bool cancel_file(TransferMetadata &f_meta) override
std::map< std::string, TransferMetadata * > m_filename_to_metadata
std::filesystem::path get_work_dir()
session_state_t session_state
lt::session_params set_settings(const IPFormat &listen_interface, const std::string &listen_port)
void generate_torrents_files(const std::filesystem::path &dest, const std::string &tracker)
char const * state(lt::torrent_status::state_t s)
std::string add_torrent(const std::string &torrent, const std::filesystem::path &dest)
bool upload_file(TransferMetadata &f_meta) override
WorkerThread contains a thread which runs the do_work() function.
std::chrono::steady_clock clk
Unsupported std::string uri Execution of command std::string error Failed to create CommandFacility uri
std::vector< lt::block_info > download_queue_block_info
std::vector< lt::peer_info > peers
std::vector< lt::announce_entry > trackers
std::deque< std::string > events
std::vector< int > piece_availability
std::vector< std::int64_t > file_progress
std::vector< lt::partial_piece_info > download_queue