mirror of
https://github.com/aria2/aria2.git
synced 2025-04-04 21:17:41 +03:00
2010-06-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Renamed member variables * src/ActivePeerConnectionCommand.cc * src/BtLeecherStateChoke.cc * src/BtPieceMessage.cc * src/BtPortMessage.cc * src/BtSeederStateChoke.cc * src/DHTGetPeersReplyMessage.cc * src/DefaultBtInteractive.cc * src/DefaultPeerStorage.cc * src/HandshakeExtensionMessage.cc * src/LpdReceiveMessageCommand.cc * src/Peer.cc * src/Peer.h * src/PeerAbstractCommand.cc * src/PeerInitiateConnectionCommand.cc * src/PeerListenCommand.cc * src/SimpleBtMessage.cc * src/UTPexExtensionMessage.cc * src/XmlRpcMethodImpl.cc * test/DHTAnnouncePeerMessageTest.cc * test/DHTGetPeersMessageTest.cc * test/DHTGetPeersReplyMessageTest.cc * test/DHTMessageFactoryImplTest.cc * test/DHTPeerAnnounceEntryTest.cc * test/DHTPeerAnnounceStorageTest.cc * test/DefaultPeerStorageTest.cc * test/HandshakeExtensionMessageTest.cc * test/LpdMessageReceiverTest.cc * test/PeerListProcessorTest.cc * test/PeerTest.cc * test/UTPexExtensionMessageTest.cc
This commit is contained in:
parent
32031a4f01
commit
55258bc019
31 changed files with 150 additions and 90 deletions
34
ChangeLog
34
ChangeLog
|
@ -1,3 +1,37 @@
|
||||||
|
2010-06-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Renamed member variables
|
||||||
|
* src/ActivePeerConnectionCommand.cc
|
||||||
|
* src/BtLeecherStateChoke.cc
|
||||||
|
* src/BtPieceMessage.cc
|
||||||
|
* src/BtPortMessage.cc
|
||||||
|
* src/BtSeederStateChoke.cc
|
||||||
|
* src/DHTGetPeersReplyMessage.cc
|
||||||
|
* src/DefaultBtInteractive.cc
|
||||||
|
* src/DefaultPeerStorage.cc
|
||||||
|
* src/HandshakeExtensionMessage.cc
|
||||||
|
* src/LpdReceiveMessageCommand.cc
|
||||||
|
* src/Peer.cc
|
||||||
|
* src/Peer.h
|
||||||
|
* src/PeerAbstractCommand.cc
|
||||||
|
* src/PeerInitiateConnectionCommand.cc
|
||||||
|
* src/PeerListenCommand.cc
|
||||||
|
* src/SimpleBtMessage.cc
|
||||||
|
* src/UTPexExtensionMessage.cc
|
||||||
|
* src/XmlRpcMethodImpl.cc
|
||||||
|
* test/DHTAnnouncePeerMessageTest.cc
|
||||||
|
* test/DHTGetPeersMessageTest.cc
|
||||||
|
* test/DHTGetPeersReplyMessageTest.cc
|
||||||
|
* test/DHTMessageFactoryImplTest.cc
|
||||||
|
* test/DHTPeerAnnounceEntryTest.cc
|
||||||
|
* test/DHTPeerAnnounceStorageTest.cc
|
||||||
|
* test/DefaultPeerStorageTest.cc
|
||||||
|
* test/HandshakeExtensionMessageTest.cc
|
||||||
|
* test/LpdMessageReceiverTest.cc
|
||||||
|
* test/PeerListProcessorTest.cc
|
||||||
|
* test/PeerTest.cc
|
||||||
|
* test/UTPexExtensionMessageTest.cc
|
||||||
|
|
||||||
2010-06-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-06-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Made DHTNode::getIPAddress() return const reference.
|
Made DHTNode::getIPAddress() return const reference.
|
||||||
|
|
|
@ -147,7 +147,8 @@ void ActivePeerConnectionCommand::connectToPeer(const SharedHandle<Peer>& peer)
|
||||||
_e->addCommand(command);
|
_e->addCommand(command);
|
||||||
if(getLogger()->info()) {
|
if(getLogger()->info()) {
|
||||||
getLogger()->info(MSG_CONNECTING_TO_PEER,
|
getLogger()->info(MSG_CONNECTING_TO_PEER,
|
||||||
util::itos(getCuid()).c_str(), peer->ipaddr.c_str());
|
util::itos(getCuid()).c_str(),
|
||||||
|
peer->getIPAddress().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,8 @@ void BtLeecherStateChoke::plannedOptimisticUnchoke
|
||||||
std::random_shuffle(peerEntries.begin(), i,
|
std::random_shuffle(peerEntries.begin(), i,
|
||||||
*(SimpleRandomizer::getInstance().get()));
|
*(SimpleRandomizer::getInstance().get()));
|
||||||
(*peerEntries.begin()).enableOptUnchoking();
|
(*peerEntries.begin()).enableOptUnchoking();
|
||||||
_logger->info("POU: %s", (*peerEntries.begin()).getPeer()->ipaddr.c_str());
|
_logger->info
|
||||||
|
("POU: %s", (*peerEntries.begin()).getPeer()->getIPAddress().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +153,7 @@ void BtLeecherStateChoke::regularUnchoke(std::vector<PeerEntry>& peerEntries)
|
||||||
for(;peerIter != rest && count; ++peerIter, --count) {
|
for(;peerIter != rest && count; ++peerIter, --count) {
|
||||||
(*peerIter).disableChokingRequired();
|
(*peerIter).disableChokingRequired();
|
||||||
_logger->info("RU: %s, dlspd=%u",
|
_logger->info("RU: %s, dlspd=%u",
|
||||||
(*peerIter).getPeer()->ipaddr.c_str(),
|
(*peerIter).getPeer()->getIPAddress().c_str(),
|
||||||
(*peerIter).getDownloadSpeed());
|
(*peerIter).getDownloadSpeed());
|
||||||
if((*peerIter).getPeer()->optUnchoking()) {
|
if((*peerIter).getPeer()->optUnchoking()) {
|
||||||
fastOptUnchoker = true;
|
fastOptUnchoker = true;
|
||||||
|
@ -166,11 +167,11 @@ void BtLeecherStateChoke::regularUnchoke(std::vector<PeerEntry>& peerEntries)
|
||||||
eoi = peerEntries.end(); i != eoi; ++i) {
|
eoi = peerEntries.end(); i != eoi; ++i) {
|
||||||
if((*i).getPeer()->peerInterested()) {
|
if((*i).getPeer()->peerInterested()) {
|
||||||
(*i).enableOptUnchoking();
|
(*i).enableOptUnchoking();
|
||||||
_logger->info("OU: %s", (*i).getPeer()->ipaddr.c_str());
|
_logger->info("OU: %s", (*i).getPeer()->getIPAddress().c_str());
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
(*i).disableChokingRequired();
|
(*i).disableChokingRequired();
|
||||||
_logger->info("OU: %s", (*i).getPeer()->ipaddr.c_str());
|
_logger->info("OU: %s", (*i).getPeer()->getIPAddress().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,8 @@ void BtPieceMessage::send()
|
||||||
if(getLogger()->info()) {
|
if(getLogger()->info()) {
|
||||||
getLogger()->info(MSG_SEND_PEER_MESSAGE,
|
getLogger()->info(MSG_SEND_PEER_MESSAGE,
|
||||||
util::itos(getCuid()).c_str(),
|
util::itos(getCuid()).c_str(),
|
||||||
getPeer()->ipaddr.c_str(), getPeer()->port,
|
getPeer()->getIPAddress().c_str(),
|
||||||
|
getPeer()->getPort(),
|
||||||
toString().c_str());
|
toString().c_str());
|
||||||
}
|
}
|
||||||
unsigned char* msgHdr = createMessageHeader();
|
unsigned char* msgHdr = createMessageHeader();
|
||||||
|
|
|
@ -76,7 +76,7 @@ void BtPortMessage::doReceivedAction()
|
||||||
// node id is random at this point. When ping reply received, new DHTNode
|
// node id is random at this point. When ping reply received, new DHTNode
|
||||||
// instance created with proper node ID and is added to a routing table.
|
// instance created with proper node ID and is added to a routing table.
|
||||||
SharedHandle<DHTNode> node(new DHTNode());
|
SharedHandle<DHTNode> node(new DHTNode());
|
||||||
node->setIPAddress(getPeer()->ipaddr);
|
node->setIPAddress(getPeer()->getIPAddress());
|
||||||
node->setPort(_port);
|
node->setPort(_port);
|
||||||
{
|
{
|
||||||
SharedHandle<DHTTask> task = _taskFactory->createPingTask(node);
|
SharedHandle<DHTTask> task = _taskFactory->createPingTask(node);
|
||||||
|
|
|
@ -94,7 +94,7 @@ void BtSeederStateChoke::unchoke
|
||||||
for(std::vector<PeerEntry>::iterator eoi = peers.end();
|
for(std::vector<PeerEntry>::iterator eoi = peers.end();
|
||||||
r != eoi && count; ++r, --count) {
|
r != eoi && count; ++r, --count) {
|
||||||
(*r).getPeer()->chokingRequired(false);
|
(*r).getPeer()->chokingRequired(false);
|
||||||
_logger->info("RU: %s, ulspd=%u", (*r).getPeer()->ipaddr.c_str(),
|
_logger->info("RU: %s, ulspd=%u", (*r).getPeer()->getIPAddress().c_str(),
|
||||||
(*r).getUploadSpeed());
|
(*r).getUploadSpeed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ void BtSeederStateChoke::unchoke
|
||||||
std::random_shuffle(r, peers.end(),
|
std::random_shuffle(r, peers.end(),
|
||||||
*(SimpleRandomizer::getInstance().get()));
|
*(SimpleRandomizer::getInstance().get()));
|
||||||
(*r).getPeer()->optUnchoking(true);
|
(*r).getPeer()->optUnchoking(true);
|
||||||
_logger->info("POU: %s", (*r).getPeer()->ipaddr.c_str());
|
_logger->info("POU: %s", (*r).getPeer()->getIPAddress().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,8 @@ BDE DHTGetPeersReplyMessage::getResponse()
|
||||||
++i) {
|
++i) {
|
||||||
const SharedHandle<Peer>& peer = *i;
|
const SharedHandle<Peer>& peer = *i;
|
||||||
unsigned char buffer[6];
|
unsigned char buffer[6];
|
||||||
if(bittorrent::createcompact(buffer, peer->ipaddr, peer->port)) {
|
if(bittorrent::createcompact
|
||||||
|
(buffer, peer->getIPAddress(), peer->getPort())) {
|
||||||
valuesList << BDE(buffer, sizeof(buffer));
|
valuesList << BDE(buffer, sizeof(buffer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,7 @@ BtMessageHandle DefaultBtInteractive::receiveHandshake(bool quickReply) {
|
||||||
}
|
}
|
||||||
if(_logger->info()) {
|
if(_logger->info()) {
|
||||||
_logger->info(MSG_RECEIVE_PEER_MESSAGE, util::itos(_cuid).c_str(),
|
_logger->info(MSG_RECEIVE_PEER_MESSAGE, util::itos(_cuid).c_str(),
|
||||||
_peer->ipaddr.c_str(), _peer->port,
|
_peer->getIPAddress().c_str(), _peer->getPort(),
|
||||||
message->toString().c_str());
|
message->toString().c_str());
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
|
@ -228,7 +228,7 @@ void DefaultBtInteractive::addBitfieldMessageToQueue() {
|
||||||
void DefaultBtInteractive::addAllowedFastMessageToQueue() {
|
void DefaultBtInteractive::addAllowedFastMessageToQueue() {
|
||||||
if(_peer->isFastExtensionEnabled()) {
|
if(_peer->isFastExtensionEnabled()) {
|
||||||
std::vector<size_t> fastSet;
|
std::vector<size_t> fastSet;
|
||||||
bittorrent::computeFastSet(fastSet, _peer->ipaddr,
|
bittorrent::computeFastSet(fastSet, _peer->getIPAddress(),
|
||||||
_downloadContext->getNumPieces(),
|
_downloadContext->getNumPieces(),
|
||||||
bittorrent::getInfoHash(_downloadContext),
|
bittorrent::getInfoHash(_downloadContext),
|
||||||
_allowedFastSetSize);
|
_allowedFastSetSize);
|
||||||
|
@ -294,7 +294,7 @@ size_t DefaultBtInteractive::receiveMessages() {
|
||||||
++msgcount;
|
++msgcount;
|
||||||
if(_logger->info()) {
|
if(_logger->info()) {
|
||||||
_logger->info(MSG_RECEIVE_PEER_MESSAGE, util::itos(_cuid).c_str(),
|
_logger->info(MSG_RECEIVE_PEER_MESSAGE, util::itos(_cuid).c_str(),
|
||||||
_peer->ipaddr.c_str(), _peer->port,
|
_peer->getIPAddress().c_str(), _peer->getPort(),
|
||||||
message->toString().c_str());
|
message->toString().c_str());
|
||||||
}
|
}
|
||||||
message->doReceivedAction();
|
message->doReceivedAction();
|
||||||
|
@ -478,7 +478,7 @@ void DefaultBtInteractive::addPeerExchangeMessage()
|
||||||
for(std::deque<SharedHandle<Peer> >::const_iterator i =
|
for(std::deque<SharedHandle<Peer> >::const_iterator i =
|
||||||
peers.begin(), eoi = peers.end();
|
peers.begin(), eoi = peers.end();
|
||||||
i != eoi && !m->freshPeersAreFull(); ++i) {
|
i != eoi && !m->freshPeersAreFull(); ++i) {
|
||||||
if(_peer->ipaddr != (*i)->ipaddr) {
|
if(_peer->getIPAddress() != (*i)->getIPAddress()) {
|
||||||
m->addFreshPeer(*i);
|
m->addFreshPeer(*i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -488,7 +488,7 @@ void DefaultBtInteractive::addPeerExchangeMessage()
|
||||||
peers.rbegin(), eoi = peers.rend();
|
peers.rbegin(), eoi = peers.rend();
|
||||||
i != eoi && !m->droppedPeersAreFull();
|
i != eoi && !m->droppedPeersAreFull();
|
||||||
++i) {
|
++i) {
|
||||||
if(_peer->ipaddr != (*i)->ipaddr) {
|
if(_peer->getIPAddress() != (*i)->getIPAddress()) {
|
||||||
m->addDroppedPeer(*i);
|
m->addDroppedPeer(*i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,8 @@ public:
|
||||||
|
|
||||||
bool operator()(const SharedHandle<Peer>& peer) const {
|
bool operator()(const SharedHandle<Peer>& peer) const {
|
||||||
return (_peer == peer) ||
|
return (_peer == peer) ||
|
||||||
((_peer->ipaddr == peer->ipaddr) && (_peer->port == peer->port));
|
((_peer->getIPAddress() == peer->getIPAddress()) &&
|
||||||
|
(_peer->getPort() == peer->getPort()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -97,7 +98,7 @@ bool DefaultPeerStorage::addPeer(const SharedHandle<Peer>& peer) {
|
||||||
if(isPeerAlreadyAdded(peer)) {
|
if(isPeerAlreadyAdded(peer)) {
|
||||||
if(_logger->debug()) {
|
if(_logger->debug()) {
|
||||||
_logger->debug("Adding %s:%u is rejected because it has been already"
|
_logger->debug("Adding %s:%u is rejected because it has been already"
|
||||||
" added.", peer->ipaddr.c_str(), peer->port);
|
" added.", peer->getIPAddress().c_str(), peer->getPort());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -116,7 +117,8 @@ void DefaultPeerStorage::addPeer(const std::vector<SharedHandle<Peer> >& peers)
|
||||||
const SharedHandle<Peer>& peer = *itr;
|
const SharedHandle<Peer>& peer = *itr;
|
||||||
if(addPeer(peer)) {
|
if(addPeer(peer)) {
|
||||||
if(_logger->debug()) {
|
if(_logger->debug()) {
|
||||||
_logger->debug(MSG_ADDING_PEER, peer->ipaddr.c_str(), peer->port);
|
_logger->debug(MSG_ADDING_PEER,
|
||||||
|
peer->getIPAddress().c_str(), peer->getPort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,7 +155,7 @@ public:
|
||||||
ipaddr(ipaddr), port(port) {}
|
ipaddr(ipaddr), port(port) {}
|
||||||
|
|
||||||
bool operator()(const SharedHandle<Peer>& peer) const {
|
bool operator()(const SharedHandle<Peer>& peer) const {
|
||||||
return ipaddr == peer->ipaddr && port == peer->port;
|
return ipaddr == peer->getIPAddress() && port == peer->getPort();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -300,7 +302,7 @@ void DefaultPeerStorage::returnPeer(const SharedHandle<Peer>& peer)
|
||||||
if(itr == _peers.end()) {
|
if(itr == _peers.end()) {
|
||||||
if(_logger->debug()) {
|
if(_logger->debug()) {
|
||||||
_logger->debug("Cannot find peer %s:%u in PeerStorage.",
|
_logger->debug("Cannot find peer %s:%u in PeerStorage.",
|
||||||
peer->ipaddr.c_str(), peer->port);
|
peer->getIPAddress().c_str(), peer->getPort());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_peers.erase(itr);
|
_peers.erase(itr);
|
||||||
|
|
|
@ -102,7 +102,7 @@ std::string HandshakeExtensionMessage::toString() const
|
||||||
void HandshakeExtensionMessage::doReceivedAction()
|
void HandshakeExtensionMessage::doReceivedAction()
|
||||||
{
|
{
|
||||||
if(_tcpPort > 0) {
|
if(_tcpPort > 0) {
|
||||||
_peer->port = _tcpPort;
|
_peer->setPort(_tcpPort);
|
||||||
_peer->setIncomingPeer(false);
|
_peer->setIncomingPeer(false);
|
||||||
}
|
}
|
||||||
for(std::map<std::string, uint8_t>::const_iterator itr = _extensions.begin(),
|
for(std::map<std::string, uint8_t>::const_iterator itr = _extensions.begin(),
|
||||||
|
|
|
@ -120,13 +120,13 @@ bool LpdReceiveMessageCommand::execute()
|
||||||
if(peerStorage->addPeer(peer)) {
|
if(peerStorage->addPeer(peer)) {
|
||||||
if(getLogger()->debug()) {
|
if(getLogger()->debug()) {
|
||||||
getLogger()->debug("LPD peer %s:%u local=%d added.",
|
getLogger()->debug("LPD peer %s:%u local=%d added.",
|
||||||
peer->ipaddr.c_str(), peer->port,
|
peer->getIPAddress().c_str(), peer->getPort(),
|
||||||
peer->isLocalPeer()?1:0);
|
peer->isLocalPeer()?1:0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(getLogger()->debug()) {
|
if(getLogger()->debug()) {
|
||||||
getLogger()->debug("LPD peer %s:%u local=%d not added.",
|
getLogger()->debug("LPD peer %s:%u local=%d not added.",
|
||||||
peer->ipaddr.c_str(), peer->port,
|
peer->getIPAddress().c_str(), peer->getPort(),
|
||||||
peer->isLocalPeer()?1:0);
|
peer->isLocalPeer()?1:0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,8 +48,8 @@ namespace aria2 {
|
||||||
#define BAD_CONDITION_INTERVAL 10
|
#define BAD_CONDITION_INTERVAL 10
|
||||||
|
|
||||||
Peer::Peer(std::string ipaddr, uint16_t port, bool incoming):
|
Peer::Peer(std::string ipaddr, uint16_t port, bool incoming):
|
||||||
ipaddr(ipaddr),
|
_ipaddr(ipaddr),
|
||||||
port(port),
|
_port(port),
|
||||||
_firstContactTime(global::wallclock),
|
_firstContactTime(global::wallclock),
|
||||||
_badConditionStartTime(0),
|
_badConditionStartTime(0),
|
||||||
_seeder(false),
|
_seeder(false),
|
||||||
|
@ -59,8 +59,8 @@ Peer::Peer(std::string ipaddr, uint16_t port, bool incoming):
|
||||||
{
|
{
|
||||||
memset(_peerId, 0, PEER_ID_LENGTH);
|
memset(_peerId, 0, PEER_ID_LENGTH);
|
||||||
resetStatus();
|
resetStatus();
|
||||||
id = ipaddr;
|
_id = _ipaddr;
|
||||||
strappend(id, A2STR::COLON_C, util::uitos(port));
|
strappend(_id, A2STR::COLON_C, util::uitos(_port));
|
||||||
}
|
}
|
||||||
|
|
||||||
Peer::~Peer()
|
Peer::~Peer()
|
||||||
|
|
29
src/Peer.h
29
src/Peer.h
|
@ -55,14 +55,14 @@ class PeerSessionResource;
|
||||||
class BtMessageDispatcher;
|
class BtMessageDispatcher;
|
||||||
|
|
||||||
class Peer {
|
class Peer {
|
||||||
public:
|
private:
|
||||||
std::string ipaddr;
|
std::string _ipaddr;
|
||||||
// TCP port of the other end of communication. If _incoming is
|
// TCP port of the other end of communication. If _incoming is
|
||||||
// true, then this port is not a port the peer is listening to and
|
// true, then this port is not a port the peer is listening to and
|
||||||
// we cannot connect to it.
|
// we cannot connect to it.
|
||||||
uint16_t port;
|
uint16_t _port;
|
||||||
private:
|
|
||||||
std::string id;
|
std::string _id;
|
||||||
|
|
||||||
cuid_t _cuid;
|
cuid_t _cuid;
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ public:
|
||||||
|
|
||||||
bool operator==(const Peer& p)
|
bool operator==(const Peer& p)
|
||||||
{
|
{
|
||||||
return id == p.id;
|
return _id == p._id;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const Peer& p)
|
bool operator!=(const Peer& p)
|
||||||
|
@ -103,6 +103,21 @@ public:
|
||||||
|
|
||||||
void resetStatus();
|
void resetStatus();
|
||||||
|
|
||||||
|
const std::string& getIPAddress() const
|
||||||
|
{
|
||||||
|
return _ipaddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t getPort() const
|
||||||
|
{
|
||||||
|
return _port;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPort(uint16_t port)
|
||||||
|
{
|
||||||
|
_port = port;
|
||||||
|
}
|
||||||
|
|
||||||
void usedBy(cuid_t cuid);
|
void usedBy(cuid_t cuid);
|
||||||
|
|
||||||
cuid_t usedBy() const
|
cuid_t usedBy() const
|
||||||
|
@ -135,7 +150,7 @@ public:
|
||||||
|
|
||||||
const std::string& getID() const
|
const std::string& getID() const
|
||||||
{
|
{
|
||||||
return id;
|
return _id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void startBadCondition();
|
void startBadCondition();
|
||||||
|
|
|
@ -118,8 +118,9 @@ bool PeerAbstractCommand::execute()
|
||||||
getLogger()->debug(MSG_TORRENT_DOWNLOAD_ABORTED, err,
|
getLogger()->debug(MSG_TORRENT_DOWNLOAD_ABORTED, err,
|
||||||
util::itos(getCuid()).c_str());
|
util::itos(getCuid()).c_str());
|
||||||
getLogger()->debug(MSG_PEER_BANNED,
|
getLogger()->debug(MSG_PEER_BANNED,
|
||||||
util::itos(getCuid()).c_str(), _peer->ipaddr.c_str(),
|
util::itos(getCuid()).c_str(),
|
||||||
_peer->port);
|
_peer->getIPAddress().c_str(),
|
||||||
|
_peer->getPort());
|
||||||
}
|
}
|
||||||
onAbort();
|
onAbort();
|
||||||
return prepareForNextPeer(0);
|
return prepareForNextPeer(0);
|
||||||
|
|
|
@ -82,11 +82,13 @@ PeerInitiateConnectionCommand::~PeerInitiateConnectionCommand()
|
||||||
bool PeerInitiateConnectionCommand::executeInternal() {
|
bool PeerInitiateConnectionCommand::executeInternal() {
|
||||||
if(getLogger()->info()) {
|
if(getLogger()->info()) {
|
||||||
getLogger()->info(MSG_CONNECTING_TO_SERVER,
|
getLogger()->info(MSG_CONNECTING_TO_SERVER,
|
||||||
util::itos(getCuid()).c_str(), getPeer()->ipaddr.c_str(),
|
util::itos(getCuid()).c_str(),
|
||||||
getPeer()->port);
|
getPeer()->getIPAddress().c_str(),
|
||||||
|
getPeer()->getPort());
|
||||||
}
|
}
|
||||||
createSocket();
|
createSocket();
|
||||||
getSocket()->establishConnection(getPeer()->ipaddr, getPeer()->port);
|
getSocket()->establishConnection(getPeer()->getIPAddress(),
|
||||||
|
getPeer()->getPort());
|
||||||
if(_mseHandshakeEnabled) {
|
if(_mseHandshakeEnabled) {
|
||||||
InitiatorMSEHandshakeCommand* c =
|
InitiatorMSEHandshakeCommand* c =
|
||||||
new InitiatorMSEHandshakeCommand(getCuid(), _requestGroup, getPeer(),
|
new InitiatorMSEHandshakeCommand(getCuid(), _requestGroup, getPeer(),
|
||||||
|
|
|
@ -131,8 +131,8 @@ bool PeerListenCommand::execute() {
|
||||||
_e->addCommand(command);
|
_e->addCommand(command);
|
||||||
if(getLogger()->debug()) {
|
if(getLogger()->debug()) {
|
||||||
getLogger()->debug("Accepted the connection from %s:%u.",
|
getLogger()->debug("Accepted the connection from %s:%u.",
|
||||||
peer->ipaddr.c_str(),
|
peer->getIPAddress().c_str(),
|
||||||
peer->port);
|
peer->getPort());
|
||||||
getLogger()->debug("Added CUID#%s to receive BitTorrent/MSE handshake.",
|
getLogger()->debug("Added CUID#%s to receive BitTorrent/MSE handshake.",
|
||||||
util::itos(cuid).c_str());
|
util::itos(cuid).c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,8 @@ void SimpleBtMessage::send() {
|
||||||
if(getLogger()->info()) {
|
if(getLogger()->info()) {
|
||||||
getLogger()->info(MSG_SEND_PEER_MESSAGE,
|
getLogger()->info(MSG_SEND_PEER_MESSAGE,
|
||||||
util::itos(getCuid()).c_str(),
|
util::itos(getCuid()).c_str(),
|
||||||
getPeer()->ipaddr.c_str(),
|
getPeer()->getIPAddress().c_str(),
|
||||||
getPeer()->port,
|
getPeer()->getPort(),
|
||||||
toString().c_str());
|
toString().c_str());
|
||||||
}
|
}
|
||||||
unsigned char* msg = createMessage();
|
unsigned char* msg = createMessage();
|
||||||
|
|
|
@ -80,7 +80,8 @@ UTPexExtensionMessage::createCompactPeerListAndFlag
|
||||||
for(std::vector<SharedHandle<Peer> >::const_iterator itr = peers.begin(),
|
for(std::vector<SharedHandle<Peer> >::const_iterator itr = peers.begin(),
|
||||||
eoi = peers.end(); itr != eoi; ++itr) {
|
eoi = peers.end(); itr != eoi; ++itr) {
|
||||||
unsigned char compact[6];
|
unsigned char compact[6];
|
||||||
if(bittorrent::createcompact(compact, (*itr)->ipaddr, (*itr)->port)) {
|
if(bittorrent::createcompact
|
||||||
|
(compact, (*itr)->getIPAddress(), (*itr)->getPort())) {
|
||||||
addrstring.append(&compact[0], &compact[6]);
|
addrstring.append(&compact[0], &compact[6]);
|
||||||
flagstring += (*itr)->isSeeder() ? "2" : "0";
|
flagstring += (*itr)->isSeeder() ? "2" : "0";
|
||||||
}
|
}
|
||||||
|
|
|
@ -626,11 +626,11 @@ static void gatherPeer(BDE& peers, const SharedHandle<PeerStorage>& ps)
|
||||||
BDE peerEntry = BDE::dict();
|
BDE peerEntry = BDE::dict();
|
||||||
peerEntry[KEY_PEER_ID] = util::torrentPercentEncode((*i)->getPeerId(),
|
peerEntry[KEY_PEER_ID] = util::torrentPercentEncode((*i)->getPeerId(),
|
||||||
PEER_ID_LENGTH);
|
PEER_ID_LENGTH);
|
||||||
peerEntry[KEY_IP] = (*i)->ipaddr;
|
peerEntry[KEY_IP] = (*i)->getIPAddress();
|
||||||
if((*i)->isIncomingPeer()) {
|
if((*i)->isIncomingPeer()) {
|
||||||
peerEntry[KEY_PORT] = std::string("0");
|
peerEntry[KEY_PORT] = std::string("0");
|
||||||
} else {
|
} else {
|
||||||
peerEntry[KEY_PORT] = util::uitos((*i)->port);
|
peerEntry[KEY_PORT] = util::uitos((*i)->getPort());
|
||||||
}
|
}
|
||||||
peerEntry[KEY_BITFIELD] = util::toHex((*i)->getBitfield(),
|
peerEntry[KEY_BITFIELD] = util::toHex((*i)->getBitfield(),
|
||||||
(*i)->getBitfieldLength());
|
(*i)->getBitfieldLength());
|
||||||
|
|
|
@ -117,8 +117,8 @@ void DHTAnnouncePeerMessageTest::testDoReceivedAction()
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)1, peers.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)1, peers.size());
|
||||||
{
|
{
|
||||||
SharedHandle<Peer> peer = peers[0];
|
SharedHandle<Peer> peer = peers[0];
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), peer->ipaddr);
|
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), peer->getIPAddress());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)6882, peer->port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)6882, peer->getPort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,13 +144,13 @@ void DHTGetPeersMessageTest::testDoReceivedAction()
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, m->_peers.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, m->_peers.size());
|
||||||
{
|
{
|
||||||
SharedHandle<Peer> peer = m->_peers[0];
|
SharedHandle<Peer> peer = m->_peers[0];
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.100"), peer->ipaddr);
|
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.100"), peer->getIPAddress());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)6888, peer->port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)6888, peer->getPort());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
SharedHandle<Peer> peer = m->_peers[1];
|
SharedHandle<Peer> peer = m->_peers[1];
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.101"), peer->ipaddr);
|
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.101"), peer->getIPAddress());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)6889, peer->port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)6889, peer->getPort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dispatcher._messageQueue.clear();
|
dispatcher._messageQueue.clear();
|
||||||
|
|
|
@ -82,7 +82,7 @@ void DHTGetPeersReplyMessageTest::testGetBencodedMessage()
|
||||||
SharedHandle<Peer> peer(new Peer("192.168.0."+util::uitos(i+1), 6881+i));
|
SharedHandle<Peer> peer(new Peer("192.168.0."+util::uitos(i+1), 6881+i));
|
||||||
unsigned char buffer[6];
|
unsigned char buffer[6];
|
||||||
CPPUNIT_ASSERT(bittorrent::createcompact
|
CPPUNIT_ASSERT(bittorrent::createcompact
|
||||||
(buffer, peer->ipaddr, peer->port));
|
(buffer, peer->getIPAddress(), peer->getPort()));
|
||||||
valuesList << BDE(buffer, sizeof(buffer));
|
valuesList << BDE(buffer, sizeof(buffer));
|
||||||
peers.push_back(peer);
|
peers.push_back(peer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,7 +292,7 @@ void DHTMessageFactoryImplTest::testCreateGetPeersReplyMessage_values()
|
||||||
SharedHandle<Peer> peer(new Peer("192.168.0."+util::uitos(i+1), 6881+i));
|
SharedHandle<Peer> peer(new Peer("192.168.0."+util::uitos(i+1), 6881+i));
|
||||||
unsigned char buffer[6];
|
unsigned char buffer[6];
|
||||||
CPPUNIT_ASSERT(bittorrent::createcompact
|
CPPUNIT_ASSERT(bittorrent::createcompact
|
||||||
(buffer, peer->ipaddr, peer->port));
|
(buffer, peer->getIPAddress(), peer->getPort()));
|
||||||
valuesList << BDE(buffer, sizeof(buffer));
|
valuesList << BDE(buffer, sizeof(buffer));
|
||||||
peers.push_back(peer);
|
peers.push_back(peer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,10 +102,10 @@ void DHTPeerAnnounceEntryTest::testGetPeers()
|
||||||
std::vector<SharedHandle<Peer> > peers;
|
std::vector<SharedHandle<Peer> > peers;
|
||||||
entry.getPeers(peers);
|
entry.getPeers(peers);
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, peers.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, peers.size());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), peers[0]->ipaddr);
|
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), peers[0]->getIPAddress());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)6881, peers[0]->port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)6881, peers[0]->getPort());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.2"), peers[1]->ipaddr);
|
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.2"), peers[1]->getIPAddress());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)6882, peers[1]->port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)6882, peers[1]->getPort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,8 @@ void DHTPeerAnnounceStorageTest::testAddAnnounce()
|
||||||
storage.getPeers(peers, infohash2);
|
storage.getPeers(peers, infohash2);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, peers.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, peers.size());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.3"), peers[0]->ipaddr);
|
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.3"), peers[0]->getIPAddress());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.4"), peers[1]->ipaddr);
|
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.4"), peers[1]->getIPAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -78,7 +78,7 @@ void DefaultPeerStorageTest::testDeleteUnusedPeer() {
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)1, ps.countPeer());
|
CPPUNIT_ASSERT_EQUAL((size_t)1, ps.countPeer());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.3"),
|
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.3"),
|
||||||
ps.getPeer("192.168.0.3", 6889)->ipaddr);
|
ps.getPeer("192.168.0.3", 6889)->getIPAddress());
|
||||||
|
|
||||||
ps.addPeer(peer1);
|
ps.addPeer(peer1);
|
||||||
ps.addPeer(peer2);
|
ps.addPeer(peer2);
|
||||||
|
@ -90,7 +90,7 @@ void DefaultPeerStorageTest::testDeleteUnusedPeer() {
|
||||||
// peer2 has been in use, so it did't deleted.
|
// peer2 has been in use, so it did't deleted.
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)1, ps.countPeer());
|
CPPUNIT_ASSERT_EQUAL((size_t)1, ps.countPeer());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.2"),
|
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.2"),
|
||||||
ps.getPeer("192.168.0.2", 6889)->ipaddr);
|
ps.getPeer("192.168.0.2", 6889)->getIPAddress());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,9 +125,10 @@ void DefaultPeerStorageTest::testAddPeer() {
|
||||||
|
|
||||||
SharedHandle<Peer> peer5(new Peer("192.168.0.4", 0));
|
SharedHandle<Peer> peer5(new Peer("192.168.0.4", 0));
|
||||||
|
|
||||||
peer5->port = 6889;
|
peer5->setPort(6889);
|
||||||
|
|
||||||
// this returns false because the peer which has same ip and port has already added
|
// this returns false because the peer which has same ip and port
|
||||||
|
// has already added
|
||||||
CPPUNIT_ASSERT_EQUAL(false, ps.addPeer(peer5));
|
CPPUNIT_ASSERT_EQUAL(false, ps.addPeer(peer5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +141,7 @@ void DefaultPeerStorageTest::testGetUnusedPeer() {
|
||||||
ps.addPeer(peer1);
|
ps.addPeer(peer1);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"),
|
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"),
|
||||||
ps.getUnusedPeer()->ipaddr);
|
ps.getUnusedPeer()->getIPAddress());
|
||||||
|
|
||||||
peer1->usedBy(1);
|
peer1->usedBy(1);
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ void HandshakeExtensionMessageTest::testDoReceivedAction()
|
||||||
|
|
||||||
msg.doReceivedAction();
|
msg.doReceivedAction();
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)6889, peer->port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)6889, peer->getPort());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint8_t)1, peer->getExtensionMessageID("ut_pex"));
|
CPPUNIT_ASSERT_EQUAL((uint8_t)1, peer->getExtensionMessageID("ut_pex"));
|
||||||
CPPUNIT_ASSERT_EQUAL((uint8_t)2, peer->getExtensionMessageID("a2_dht"));
|
CPPUNIT_ASSERT_EQUAL((uint8_t)2, peer->getExtensionMessageID("a2_dht"));
|
||||||
CPPUNIT_ASSERT_EQUAL((int64_t)1024, attrs[bittorrent::METADATA_SIZE].i());
|
CPPUNIT_ASSERT_EQUAL((int64_t)1024, attrs[bittorrent::METADATA_SIZE].i());
|
||||||
|
|
|
@ -52,7 +52,7 @@ void LpdMessageReceiverTest::testReceiveMessage()
|
||||||
CPPUNIT_ASSERT(!msg.isNull());
|
CPPUNIT_ASSERT(!msg.isNull());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("cd41c7fdddfd034a15a04d7ff881216e01c4ceaf"),
|
CPPUNIT_ASSERT_EQUAL(std::string("cd41c7fdddfd034a15a04d7ff881216e01c4ceaf"),
|
||||||
util::toHex(msg->getInfoHash()));
|
util::toHex(msg->getInfoHash()));
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)6000, msg->getPeer()->port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)6000, msg->getPeer()->getPort());
|
||||||
|
|
||||||
// Bad infohash
|
// Bad infohash
|
||||||
std::string badInfoHashString = "cd41c7fdddfd034a15a04d7ff881216e01c4ce";
|
std::string badInfoHashString = "cd41c7fdddfd034a15a04d7ff881216e01c4ce";
|
||||||
|
|
|
@ -42,8 +42,8 @@ void PeerListProcessorTest::testExtractPeerFromList() {
|
||||||
proc.extractPeerFromList(dict["peers"], std::back_inserter(peers));
|
proc.extractPeerFromList(dict["peers"], std::back_inserter(peers));
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)1, peers.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)1, peers.size());
|
||||||
SharedHandle<Peer> peer = *peers.begin();
|
SharedHandle<Peer> peer = *peers.begin();
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), peer->ipaddr);
|
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), peer->getIPAddress());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)2006, peer->port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)2006, peer->getPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerListProcessorTest::testExtract2PeersFromList() {
|
void PeerListProcessorTest::testExtract2PeersFromList() {
|
||||||
|
@ -59,12 +59,12 @@ void PeerListProcessorTest::testExtract2PeersFromList() {
|
||||||
proc.extractPeerFromList(dict["peers"], std::back_inserter(peers));
|
proc.extractPeerFromList(dict["peers"], std::back_inserter(peers));
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, peers.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, peers.size());
|
||||||
SharedHandle<Peer> peer = *peers.begin();
|
SharedHandle<Peer> peer = *peers.begin();
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), peer->ipaddr);
|
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), peer->getIPAddress());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)65535, peer->port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)65535, peer->getPort());
|
||||||
|
|
||||||
peer = *(peers.begin()+1);
|
peer = *(peers.begin()+1);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.2"), peer->ipaddr);
|
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.2"), peer->getIPAddress());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)2007, peer->port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)2007, peer->getPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -53,7 +53,7 @@ void PeerTest::testOperatorEqual()
|
||||||
{
|
{
|
||||||
Peer p1("localhost", 6881);
|
Peer p1("localhost", 6881);
|
||||||
Peer p2("localhsot", 0);
|
Peer p2("localhsot", 0);
|
||||||
p2.port = 6881;
|
p2.setPort(6881);
|
||||||
CPPUNIT_ASSERT(p1 != p2);
|
CPPUNIT_ASSERT(p1 != p2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,10 +85,10 @@ void UTPexExtensionMessageTest::testGetBencodedData()
|
||||||
unsigned char c2[6];
|
unsigned char c2[6];
|
||||||
unsigned char c3[6];
|
unsigned char c3[6];
|
||||||
unsigned char c4[6];
|
unsigned char c4[6];
|
||||||
bittorrent::createcompact(c1, p1->ipaddr, p1->port);
|
bittorrent::createcompact(c1, p1->getIPAddress(), p1->getPort());
|
||||||
bittorrent::createcompact(c2, p2->ipaddr, p2->port);
|
bittorrent::createcompact(c2, p2->getIPAddress(), p2->getPort());
|
||||||
bittorrent::createcompact(c3, p3->ipaddr, p3->port);
|
bittorrent::createcompact(c3, p3->getIPAddress(), p3->getPort());
|
||||||
bittorrent::createcompact(c4, p4->ipaddr, p4->port);
|
bittorrent::createcompact(c4, p4->getIPAddress(), p4->getPort());
|
||||||
|
|
||||||
std::string expected = "d5:added12:"+
|
std::string expected = "d5:added12:"+
|
||||||
std::string(&c1[0], &c1[6])+std::string(&c2[0], &c2[6])+
|
std::string(&c1[0], &c1[6])+std::string(&c2[0], &c2[6])+
|
||||||
|
@ -140,13 +140,13 @@ void UTPexExtensionMessageTest::testDoReceivedAction()
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, _peerStorage->getPeers().size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, _peerStorage->getPeers().size());
|
||||||
{
|
{
|
||||||
SharedHandle<Peer> p = _peerStorage->getPeers()[0];
|
SharedHandle<Peer> p = _peerStorage->getPeers()[0];
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), p->ipaddr);
|
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), p->getIPAddress());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)6881, p->port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)6881, p->getPort());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
SharedHandle<Peer> p = _peerStorage->getPeers()[1];
|
SharedHandle<Peer> p = _peerStorage->getPeers()[1];
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("10.1.1.2"), p->ipaddr);
|
CPPUNIT_ASSERT_EQUAL(std::string("10.1.1.2"), p->getIPAddress());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)9999, p->port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)9999, p->getPort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,19 +176,19 @@ void UTPexExtensionMessageTest::testCreate()
|
||||||
CPPUNIT_ASSERT_EQUAL((uint8_t)1, msg->getExtensionMessageID());
|
CPPUNIT_ASSERT_EQUAL((uint8_t)1, msg->getExtensionMessageID());
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, msg->getFreshPeers().size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, msg->getFreshPeers().size());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"),
|
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"),
|
||||||
msg->getFreshPeers()[0]->ipaddr);
|
msg->getFreshPeers()[0]->getIPAddress());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)6881, msg->getFreshPeers()[0]->port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)6881, msg->getFreshPeers()[0]->getPort());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("10.1.1.2"),
|
CPPUNIT_ASSERT_EQUAL(std::string("10.1.1.2"),
|
||||||
msg->getFreshPeers()[1]->ipaddr);
|
msg->getFreshPeers()[1]->getIPAddress());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)9999, msg->getFreshPeers()[1]->port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)9999, msg->getFreshPeers()[1]->getPort());
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, msg->getDroppedPeers().size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, msg->getDroppedPeers().size());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.2"),
|
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.2"),
|
||||||
msg->getDroppedPeers()[0]->ipaddr);
|
msg->getDroppedPeers()[0]->getIPAddress());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)6882, msg->getDroppedPeers()[0]->port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)6882, msg->getDroppedPeers()[0]->getPort());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("10.1.1.3"),
|
CPPUNIT_ASSERT_EQUAL(std::string("10.1.1.3"),
|
||||||
msg->getDroppedPeers()[1]->ipaddr);
|
msg->getDroppedPeers()[1]->getIPAddress());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)10000,
|
CPPUNIT_ASSERT_EQUAL((uint16_t)10000,
|
||||||
msg->getDroppedPeers()[1]->port);
|
msg->getDroppedPeers()[1]->getPort());
|
||||||
try {
|
try {
|
||||||
// 0 length data
|
// 0 length data
|
||||||
std::string in = "";
|
std::string in = "";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue