20 #ifndef BTPEERMANAGER_H
21 #define BTPEERMANAGER_H
24 #include <interfaces/peersource.h>
25 #include <ktorrent_export.h>
26 #include <peer/peer.h>
27 #include <peer/superseeder.h>
28 #include <peer/peerconnector.h>
29 #include <mse/encryptedpacketsocket.h>
33 class KResolverResults;
43 class PieceDownloader;
44 class ConnectionLimit;
46 using KNetwork::KResolverResults;
48 const Uint32 MAX_SIMULTANIOUS_AUTHS = 20;
56 virtual void pieceReceived(
const Piece & p) = 0;
116 void setWantedChunks(
const BitSet & bs);
223 virtual void visit(
const Peer::Ptr p) = 0;
251 void pex(
const QByteArray & arr);
282 void newPeer(
Peer* p);
283 void peerKilled(
Peer* p);
void setGroupIDs(Uint32 up, Uint32 down)
Set the group IDs of each peer.
Simple implementation of a BitSet.
const Torrent & getTorrent() const
Get the Torrent.
Uint32 getNumConnectedSeeders() const
Get the number of connected seeders.
void addPotentialPeer(const net::Address &addr, bool local)
void peerAuthenticated(Authenticate *auth, PeerConnector::WPtr pcon, bool ok, ConnectionLimit::Token::Ptr token)
Peer::Ptr findPeer(Uint32 peer_id)
void setSuperSeeding(bool on, const BitSet &chunks)
Enable or disable super seeding.
void rerunChoker()
Rerun the choker.
const BitSet & getAvailableChunksBitSet() const
Get a BitSet of all available chunks.
Uint32 getNumPending() const
Get the number of pending peers we are attempting to connect to.
bool chokerNeedsToRun() const
Does the choker need to run again.
void sendHave(Uint32 index)
Send a have message to all peers.
void newConnection(mse::EncryptedPacketSocket::Ptr sock, const PeerID &peer_id, Uint32 support)
Manages the connection with a peer.
PeerManager(Torrent &tor)
bool isStarted() const
Is the peer manager started.
void bitSetReceived(Peer *p, const BitSet &bs)
Bitset received by a peer.
void pex(const QByteArray &arr)
A PEX message was received.
bool connectedTo(const PeerID &peer_id)
Are we connected to a Peer given it's PeerID ?
virtual void visit(const Peer::Ptr p)=0
Called for each Peer.
void closeAllConnections()
bool isPartialSeed() const
Are we a partial seed.
Uint32 getNumConnectedLeechers() const
Get the number of connected leechers.
void savePeerList(const QString &file)
static ConnectionLimit & connectionLimits()
Get the connection limits.
void pieceReceived(const Piece &p)
A Piece was received.
void portPacketReceived(const QString &ip, Uint16 port)
A port packet was received.
void start(bool superseed)
void setPexEnabled(bool on)
Enable or disable PEX.
void visit(PeerVisitor &visitor)
Visit all peers.
bool isPexEnabled() const
Is PEX eanbled.
Base class for handling pieces.
Uint32 getNumConnectedPeers() const
Get the number of connected peers.
void peerSourceReady(PeerSource *ps)
void setPartialSeed(bool partial_seed)
Set if we are a partial seed or not.
Uint32 uploadRate() const
Get the combined upload rate of all peers in bytes per sec.
void setPieceHandler(PieceHandler *ph)
Set the piece handler.
void have(Peer *p, Uint32 index)
Have message received by a peer.
Peer::Ptr findPeer(PieceDownloader *pd)
ChunkCounter & getChunkCounter()
Get the chunk counter.
QList< Peer::Ptr > getPeers() const
void loadPeerList(const QString &file)