24 #include <ktorrent_export.h>
25 #include <net/address.h>
26 #include <util/constants.h>
27 #include <peer/peermanager.h>
28 #include "peerprotocolextension.h"
40 class KTORRENT_EXPORT UTPex :
public PeerProtocolExtension,
public PeerManager::PeerVisitor
43 UTPex(Peer* peer,Uint32
id);
51 void handlePacket(
const Uint8* packet,Uint32 size)
override;
54 bool needsUpdate()
const override;
57 void update()
override;
60 void changeID(Uint32 nid) {
id = nid;}
63 static void setEnabled(
bool on) {pex_enabled = on;}
66 static bool isEnabled() {
return pex_enabled;}
68 void encode(BEncoder & enc,
const std::map<Uint32,net::Address> & ps);
69 void encodeFlags(
BEncoder & enc,
const std::map<Uint32,Uint8> & flags);
70 void visit(
const bt::Peer::Ptr p)
override;
73 std::map<Uint32,net::Address> peers;
74 TimeStamp last_updated;
75 static bool pex_enabled;
77 std::map<Uint32,net::Address> added;
78 std::map<Uint32,Uint8> flags;
79 std::map<Uint32,net::Address> npeers;