From 9ec411345d6102d1f183017802ad227be83c9c13 Mon Sep 17 00:00:00 2001 From: drbob Date: Wed, 13 Jul 2011 09:12:31 +0000 Subject: [PATCH] * added OwnId at p3bitdht level. * Filter out own id from stun peers. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-netupgrade@4438 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/dht/p3bitdht.cc | 8 ++++---- libretroshare/src/dht/p3bitdht.h | 3 +++ libretroshare/src/dht/p3bitdht_peernet.cc | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/dht/p3bitdht.cc b/libretroshare/src/dht/p3bitdht.cc index f4de8c095..0ce9f854a 100644 --- a/libretroshare/src/dht/p3bitdht.cc +++ b/libretroshare/src/dht/p3bitdht.cc @@ -85,7 +85,7 @@ p3BitDht::p3BitDht(std::string id, pqiConnectCb *cb, p3NetMgr *nm, mRelay = NULL; std::string dhtVersion = "RS51"; // should come from elsewhere! - bdNodeId ownId; + mOwnRsId = id; #ifdef DEBUG_BITDHT std::cerr << "p3BitDht::p3BitDht()" << std::endl; @@ -99,12 +99,12 @@ p3BitDht::p3BitDht(std::string id, pqiConnectCb *cb, p3NetMgr *nm, /* setup ownId */ storeTranslation_locked(id); - lookupNodeId_locked(id, &ownId); + lookupNodeId_locked(id, &mOwnDhtId); #ifdef DEBUG_BITDHT std::cerr << "Own NodeId: "; - bdStdPrintNodeId(std::cerr, &ownId); + bdStdPrintNodeId(std::cerr, &mOwnDhtId); std::cerr << std::endl; #endif @@ -117,7 +117,7 @@ p3BitDht::p3BitDht(std::string id, pqiConnectCb *cb, p3NetMgr *nm, #endif /* create dht */ - mUdpBitDht = new UdpBitDht(udpstack, &ownId, dhtVersion, bootstrapfile, stdfns); + mUdpBitDht = new UdpBitDht(udpstack, &mOwnDhtId, dhtVersion, bootstrapfile, stdfns); udpstack->addReceiver(mUdpBitDht); /* setup callback to here */ diff --git a/libretroshare/src/dht/p3bitdht.h b/libretroshare/src/dht/p3bitdht.h index bebb98298..8542ae157 100644 --- a/libretroshare/src/dht/p3bitdht.h +++ b/libretroshare/src/dht/p3bitdht.h @@ -249,6 +249,9 @@ int calculateNodeId(const std::string pid, bdNodeId *id); RsMutex dhtMtx; + std::string mOwnRsId; + bdNodeId mOwnDhtId; + time_t mMinuteTS; /* translation maps */ diff --git a/libretroshare/src/dht/p3bitdht_peernet.cc b/libretroshare/src/dht/p3bitdht_peernet.cc index 3d04a541d..cf1249f86 100644 --- a/libretroshare/src/dht/p3bitdht_peernet.cc +++ b/libretroshare/src/dht/p3bitdht_peernet.cc @@ -186,6 +186,20 @@ int p3BitDht::NodeCallback(const bdId *id, uint32_t peerflags) * ideally don't pass to both peers... (XXX do later) */ + { + RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/ + if (id->id == mOwnDhtId) + { +#ifdef DEBUG_BITDHT_COMMON + std::cerr << "p3BitDht::NodeCallback() Skipping own id"; + bdStdPrintId(std::cerr, id); + std::cerr << std::endl; +#endif + return 1; + } + } + + if ((mProxyStunner) && (mProxyStunner->needStunPeers())) { #ifdef DEBUG_BITDHT_COMMON