libktorrent
2.2.0
|
Manages all the Peers. More...
#include <peermanager.h>
Classes | |
class | PeerVisitor |
Public Slots | |
void | peerSourceReady (PeerSource *ps) |
Signals | |
void | newPeer (Peer *p) |
void | peerKilled (Peer *p) |
Public Member Functions | |
PeerManager (Torrent &tor) | |
void | addPotentialPeer (const net::Address &addr, bool local) |
void | bitSetReceived (Peer *p, const BitSet &bs) |
Bitset received by a peer. | |
bool | chokerNeedsToRun () const |
Does the choker need to run again. | |
void | closeAllConnections () |
bool | connectedTo (const PeerID &peer_id) |
Are we connected to a Peer given it's PeerID ? | |
Peer::Ptr | findPeer (PieceDownloader *pd) |
Peer::Ptr | findPeer (Uint32 peer_id) |
const BitSet & | getAvailableChunksBitSet () const |
Get a BitSet of all available chunks. | |
ChunkCounter & | getChunkCounter () |
Get the chunk counter. | |
Uint32 | getNumConnectedLeechers () const |
Get the number of connected leechers. | |
Uint32 | getNumConnectedPeers () const |
Get the number of connected peers. | |
Uint32 | getNumConnectedSeeders () const |
Get the number of connected seeders. | |
Uint32 | getNumPending () const |
Get the number of pending peers we are attempting to connect to. | |
QList< Peer::Ptr > | getPeers () const |
const Torrent & | getTorrent () const |
Get the Torrent. | |
void | have (Peer *p, Uint32 index) |
Have message received by a peer. | |
bool | isPartialSeed () const |
Are we a partial seed. | |
bool | isPexEnabled () const |
Is PEX eanbled. | |
bool | isStarted () const |
Is the peer manager started. | |
void | killSeeders () |
void | killStalePeers () |
void | killUninterested () |
void | loadPeerList (const QString &file) |
void | newConnection (mse::EncryptedPacketSocket::Ptr sock, const PeerID &peer_id, Uint32 support) |
void | pause () |
void | peerAuthenticated (Authenticate *auth, PeerConnector::WPtr pcon, bool ok, ConnectionLimit::Token::Ptr token) |
void | pex (const QByteArray &arr) |
A PEX message was received. | |
void | pieceReceived (const Piece &p) |
A Piece was received. | |
void | portPacketReceived (const QString &ip, Uint16 port) |
A port packet was received. | |
void | rerunChoker () |
Rerun the choker. | |
void | savePeerList (const QString &file) |
void | sendHave (Uint32 index) |
Send a have message to all peers. | |
void | setGroupIDs (Uint32 up, Uint32 down) |
Set the group IDs of each peer. | |
void | setPartialSeed (bool partial_seed) |
Set if we are a partial seed or not. | |
void | setPexEnabled (bool on) |
Enable or disable PEX. | |
void | setPieceHandler (PieceHandler *ph) |
Set the piece handler. | |
void | setSuperSeeding (bool on, const BitSet &chunks) |
Enable or disable super seeding. | |
void | setWantedChunks (const BitSet &bs) |
void | start (bool superseed) |
void | stop () |
void | unpause () |
void | update () |
Uint32 | uploadRate () const |
Get the combined upload rate of all peers in bytes per sec. | |
void | visit (PeerVisitor &visitor) |
Visit all peers. | |
Static Public Member Functions | |
static ConnectionLimit & | connectionLimits () |
Get the connection limits. | |
This class manages all Peer objects. It can also open connections to other peers.
Definition at line 66 of file peermanager.h.
void bt::PeerManager::addPotentialPeer | ( | const net::Address & | addr, |
bool | local | ||
) |
Add a potential peer
addr | The peers' address |
local | Is it a peer on the local network |
void bt::PeerManager::closeAllConnections | ( | ) |
Close all Peer connections.
Peer::Ptr bt::PeerManager::findPeer | ( | PieceDownloader * | pd | ) |
Find a Peer based on it's PieceDownloader
pd | The PieceDownloader |
Peer::Ptr bt::PeerManager::findPeer | ( | Uint32 | peer_id | ) |
QList<Peer::Ptr> bt::PeerManager::getPeers | ( | ) | const |
Get a list of all peers.
void bt::PeerManager::killSeeders | ( | ) |
Kills all connections to seeders. This is used when torrent download gets finished and we should drop all connections to seeders
void bt::PeerManager::killStalePeers | ( | ) |
Kill all peers who appear to be stale
void bt::PeerManager::killUninterested | ( | ) |
Kills all peers that are not interested for a long time. This should be used when torrent is seeding ONLY.
void bt::PeerManager::loadPeerList | ( | const QString & | file | ) |
Load the peer list again and add them to the potential peers
void bt::PeerManager::newConnection | ( | mse::EncryptedPacketSocket::Ptr | sock, |
const PeerID & | peer_id, | ||
Uint32 | support | ||
) |
A new connection is ready for this PeerManager.
sock | The socket |
peer_id | The Peer's ID |
support | What extensions the peer supports |
void bt::PeerManager::pause | ( | ) |
Pause the peer connections
void bt::PeerManager::peerAuthenticated | ( | Authenticate * | auth, |
PeerConnector::WPtr | pcon, | ||
bool | ok, | ||
ConnectionLimit::Token::Ptr | token | ||
) |
A peer has authenticated.
auth | The Authenticate object |
pcon | The PeerConnector |
ok | Whether or not the attempt was succesfull |
token | The ConnectionLimit::Token |
|
slot |
A PeerSource, has new potential peers.
ps | The PeerSource |
void bt::PeerManager::savePeerList | ( | const QString & | file | ) |
Save the IP's and port numbers of all peers.
void bt::PeerManager::start | ( | bool | superseed | ) |
Start listening to incoming requests.
superseed | Set to true to get superseeding |
void bt::PeerManager::stop | ( | ) |
Stop listening to incoming requests.
void bt::PeerManager::unpause | ( | ) |
Unpause the peer connections
void bt::PeerManager::update | ( | ) |
Check for new connections, update down and upload speed of each Peer. Initiate new connections.