4#include <Kanoop/torrent/kanooptorrent.h>
5#include <Kanoop/torrent/torrent.h>
6#include <Kanoop/torrent/sessionstats.h>
7#include <Kanoop/utility/loggingbaseclass.h>
9#include <QNetworkProxy>
33 public LoggingBaseClass
45 Q_ENUM(EncryptionMode)
62 Torrent* addTorrent(const
MagnetLink& magnetLink, const QString& downloadDirectory = QString());
70 Torrent* addTorrent(const QString& torrentFilePath, const QString& downloadDirectory = QString());
78 Torrent* addTorrent(const QByteArray& torrentData, const QString& downloadDirectory = QString());
85 void removeTorrent(
Torrent* torrent,
bool deleteFiles = false);
90 QList<
Torrent*> torrents()
const {
return _torrents; }
214 void addIpFilter(
const QHostAddress& first,
const QHostAddress& last);
295 void listenFailed(
const QString& address,
int port,
const QString& error);
309 void configureProxy();
310 void applySetting(
int name,
int value);
311 void applySetting(
int name,
bool value);
312 void applySetting(
int name,
const std::string& value);
313 int getSettingInt(
int name)
const;
314 bool getSettingBool(
int name)
const;
315 std::string getSettingString(
int name)
const;
316 Torrent* findTorrentByHandle(
void* alertHandle);
318 void* _session =
nullptr;
319 QList<Torrent*> _torrents;
320 QNetworkProxy _networkProxy;
321 QString _defaultDownloadDirectory;
322 QString _resumeDataDirectory;
323 QTimer* _alertTimer =
nullptr;
Parses and constructs BitTorrent magnet URIs.
Aggregate statistics snapshot for a TorrentClient session.
Qt wrapper around a libtorrent session.
void setEncryptionMode(EncryptionMode mode)
Set the peer connection encryption policy.
int loadBlocklist(const QString &filePath)
Load a P2P-format blocklist from a file.
void loadResumeData()
Scan the resume-data directory and re-add all found torrents.
EncryptionMode
Peer connection encryption policy.
@ EncryptionForced
Require encryption; reject plaintext peers.
@ EncryptionDisabled
Disable encryption entirely.
@ EncryptionEnabled
Prefer encrypted connections, allow plaintext fallback.
QString userAgent() const
The user-agent string sent to trackers and peers.
void listenSucceeded(const QString &address, int port)
Emitted when the session begins listening on an interface.
void torrentRemoved(const QByteArray &infoHash)
Emitted after a torrent is removed.
void setUploadRateLimit(int bytesPerSecond)
Set the global upload rate limit in bytes/sec.
void dhtBootstrapComplete()
Emitted when the DHT routing table is initially populated.
void setResumeDataDirectory(const QString &path)
Set the resume-data directory and create it if it doesn't exist.
bool isLsdEnabled() const
Whether Local Service Discovery (LSD) is enabled.
void removeIpFilter(const QHostAddress &first, const QHostAddress &last)
Remove a previously added IP filter range.
SessionStats sessionStats() const
Compute an aggregate snapshot of session statistics.
QString resumeDataDirectory() const
Directory where .fastresume files are stored.
bool isDhtEnabled() const
Whether the Distributed Hash Table (DHT) is enabled.
void requestSessionStats()
Post an asynchronous session-stats request to libtorrent.
QString listenInterfaces() const
Current listen interface string.
void clearIpFilter()
Remove all IP filter rules, allowing all addresses.
void processAlerts()
Process pending libtorrent alerts.
void setDownloadRateLimit(int bytesPerSecond)
Set the global download rate limit in bytes/sec.
void saveAllResumeData()
Request resume-data saves for every managed torrent.
void externalAddressDetected(const QString &address)
Emitted when the session's external (public) IP is detected.
void torrentComplete(Torrent *torrent)
Emitted when a torrent finishes downloading and enters seeding.
void sessionStatsReceived(const SessionStats &stats)
Emitted in response to requestSessionStats().
void stopAll()
Pause all active torrents.
void setMaxUploads(int value)
Set the maximum number of unchoke slots.
void setNetworkProxy(const QNetworkProxy &value)
Route all libtorrent traffic through a SOCKS5 proxy.
void resumeDataFailed(const QByteArray &infoHash, const QString &error)
Emitted when saving resume data for a torrent fails.
void setDhtEnabled(bool enabled)
Enable or disable DHT.
void setDefaultDownloadDirectory(const QString &value)
Set the default save path for new torrents.
int maxConnections() const
Maximum number of simultaneous connections across all torrents.
void listenFailed(const QString &address, int port, const QString &error)
Emitted when binding to a listen interface fails.
void setLsdEnabled(bool enabled)
Enable or disable LSD.
void torrentAdded(Torrent *torrent)
Emitted after a torrent is successfully added to the session.
void setMaxConnections(int value)
Set the global connection limit.
void addIpFilter(const QHostAddress &first, const QHostAddress &last)
Block a range of IP addresses.
void setUserAgent(const QString &value)
Set the user-agent string.
EncryptionMode encryptionMode() const
Current peer connection encryption policy.
void startAll()
Resume all paused/stopped torrents.
QNetworkProxy networkProxy() const
Current SOCKS5 proxy configuration.
void setListenInterfaces(const QString &value)
Set the listen interfaces for incoming connections.
void resumeDataSaved(const QByteArray &infoHash)
Emitted when a torrent's resume data is successfully written to disk.
int maxUploads() const
Maximum number of unchoke slots (upload slots).
Torrent * findTorrent(const QByteArray &infoHash) const
Find a torrent by its 20-byte SHA-1 info hash.
QString defaultDownloadDirectory() const
Default save path for new torrents when no override is given.
void torrentStateChanged(Torrent *torrent, Torrent::State state)
Emitted when any torrent transitions to a new state.
int downloadRateLimit() const
Global download rate limit in bytes/sec.
int uploadRateLimit() const
Global upload rate limit in bytes/sec.
Represents a single torrent within a TorrentClient session.
State
Lifecycle state of a torrent.