Changes to support Relays.

* added p3BitDht::addKnownNode() so that DhtIds can be used instead of SslIds.
 * switched from bdStdDht() functions to use bdModDht().
 * made DhtFunctions a class variable.
 * added function to modify NodePerBucket() parameter.
 * Bugfix for LinkType. peerConnectAddress.flags was not initialised.
 * Extra debugging of LinkType data (use LINKMGR_DEBUG_LINKTYPE).
 * cleaned up udprelay output.
 * Added Compile Rules to libretroshare.pro for building LocalNet Testing Version. (testnetwork)




git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-dhtmods@4795 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2012-01-14 01:54:17 +00:00
parent fe955c9a4f
commit 96c9071920
7 changed files with 131 additions and 20 deletions

View file

@ -120,7 +120,8 @@ p3BitDht::p3BitDht(std::string id, pqiConnectCb *cb, p3NetMgr *nm,
#endif
/* standard dht behaviour */
bdDhtFunctions *stdfns = new bdStdDht();
//bdDhtFunctions *stdfns = new bdStdDht();
mDhtFns = new bdModDht();
#ifdef DEBUG_BITDHT
std::cerr << "p3BitDht() startup ... creating UdpBitDht";
@ -128,7 +129,7 @@ p3BitDht::p3BitDht(std::string id, pqiConnectCb *cb, p3NetMgr *nm,
#endif
/* create dht */
mUdpBitDht = new UdpBitDht(udpstack, &mOwnDhtId, dhtVersion, bootstrapfile, stdfns);
mUdpBitDht = new UdpBitDht(udpstack, &mOwnDhtId, dhtVersion, bootstrapfile, mDhtFns);
udpstack->addReceiver(mUdpBitDht);
/* setup callback to here */
@ -170,6 +171,12 @@ void p3BitDht::setupPeerSharer(pqiNetAssistPeerShare *sharer)
mPeerSharer = sharer;
}
/* Tweak the DHT Parameters */
void p3BitDht::modifyNodesPerBucket(uint16_t count)
{
bdModDht *modFns = (bdModDht *) mDhtFns;
modFns->setNodesPerBucket(count);
}
/* Support for Outsourced Relay Handling */

View file

@ -173,7 +173,7 @@ virtual std::string getUdpAddressString();
void setupConnectBits(UdpStunner *dhtStunner, UdpStunner *proxyStunner, UdpRelayReceiver *relay);
void setupPeerSharer(pqiNetAssistPeerShare *sharer);
void modifyNodesPerBucket(uint16_t count);
void start(); /* starts up the bitdht thread */
@ -322,6 +322,7 @@ int removePeer(const std::string pid);
// Can be used externally too.
int calculateNodeId(const std::string pid, bdNodeId *id);
int addKnownNode(const bdId *id, uint32_t flags);
private:
@ -345,6 +346,8 @@ int removeTranslation_locked(const std::string pid);
pqiNetAssistPeerShare *mPeerSharer;
bdDhtFunctions *mDhtFns;
RsMutex dhtMtx;

View file

@ -275,6 +275,49 @@ int p3BitDht::addKnownPeer(const std::string &pid, const struct sockaddr_in &add
return 1;
}
/* Total duplicate of above function - can't be helped, should merge somehow */
int p3BitDht::addKnownNode(const bdId *id, uint32_t flags)
{
int bdflags = 0;
switch(flags & NETASSIST_KNOWN_PEER_TYPE_MASK)
{
default:
return 0;
break;
case NETASSIST_KNOWN_PEER_WHITELIST:
bdflags = BITDHT_PEER_STATUS_DHT_WHITELIST;
break;
case NETASSIST_KNOWN_PEER_FOF:
bdflags = BITDHT_PEER_STATUS_DHT_FOF;
break;
case NETASSIST_KNOWN_PEER_FRIEND:
bdflags = BITDHT_PEER_STATUS_DHT_FRIEND;
break;
case NETASSIST_KNOWN_PEER_RELAY:
bdflags = BITDHT_PEER_STATUS_DHT_RELAY_SERVER;
break;
case NETASSIST_KNOWN_PEER_SELF:
bdflags = BITDHT_PEER_STATUS_DHT_SELF;
break;
}
if (flags & NETASSIST_KNOWN_PEER_ONLINE)
{
bdflags |= BD_FRIEND_ENTRY_ONLINE;
}
mUdpBitDht->updateKnownPeer(id, 0, bdflags);
return 1;
}
#if 0

View file

@ -124,6 +124,9 @@ uint32_t p3BitDht::getRelayMode()
int p3BitDht::setRelayMode(uint32_t mode)
{
std::cerr << "p3BitDht::setRelayMode(" << mode << ")";
std::cerr << std::endl;
if (mode & RSDHT_RELAY_ENABLED)
{
mUdpBitDht->ConnectionOptions(