2010-03-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Don't use hash for Peer::id. Simple concatenation of ip address
	and port is enough.
	* src/Peer.cc
	* test/PeerTest.cc
pull/1/head
Tatsuhiro Tsujikawa 2010-03-05 12:54:20 +00:00
parent b55f2de8e6
commit db4ed87f7a
3 changed files with 10 additions and 12 deletions

View File

@ -1,3 +1,10 @@
2010-03-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Don't use hash for Peer::id. Simple concatenation of ip address
and port is enough.
* src/Peer.cc
* test/PeerTest.cc
2010-03-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Enclosed log of DHTMessage::toString() with Logger::info().

View File

@ -40,9 +40,6 @@
#include "util.h"
#include "a2functional.h"
#include "PeerSessionResource.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "MessageDigestHelper.h"
#endif // ENABLE_MESSAGE_DIGEST
#include "BtMessageDispatcher.h"
namespace aria2 {
@ -60,13 +57,8 @@ Peer::Peer(std::string ipaddr, uint16_t port, bool incoming):
{
memset(_peerId, 0, PEER_ID_LENGTH);
resetStatus();
std::string idSeed = ipaddr;
strappend(idSeed, ":", util::uitos(port));
#ifdef ENABLE_MESSAGE_DIGEST
id = MessageDigestHelper::digestString(MessageDigestContext::SHA1, idSeed);
#else
id = idSeed;
#endif // ENABLE_MESSAGE_DIGEST
id = ipaddr;
strappend(id, A2STR::COLON_C, util::uitos(port));
}
Peer::~Peer()

View File

@ -43,8 +43,7 @@ void PeerTest::testAmAllowedIndexSet() {
}
void PeerTest::testGetId() {
CPPUNIT_ASSERT_EQUAL(std::string("f05897fc14a41cb3400e283e189158656d7184da"),
peer->getID());
CPPUNIT_ASSERT_EQUAL(std::string("localhost:6969"), peer->getID());
}
void PeerTest::testOperatorEqual()