enabled dht, and tweaked some parameters.

disabled notification checks if ext ports.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@347 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2008-02-11 23:27:17 +00:00
parent a56f9266f8
commit 3f582afe5a
4 changed files with 54 additions and 21 deletions

View File

@ -106,8 +106,8 @@ bool OpenDHTMgr::init()
std::string configpath = "."; std::string configpath = ".";
/* load up DHT gateways */ /* load up DHT gateways */
//mClient = new OpenDHTClient(); mClient = new OpenDHTClient();
mClient = new DHTClientDummy(); //mClient = new DHTClientDummy();
std::string filename = configpath; std::string filename = configpath;
if (configpath.size() > 0) if (configpath.size() > 0)

View File

@ -310,7 +310,7 @@ void p3ConnectMgr::netUpnpInit()
mNetStatus = RS_NET_UPNP_SETUP; mNetStatus = RS_NET_UPNP_SETUP;
iport = ntohs(ownState.localaddr.sin_port); iport = ntohs(ownState.localaddr.sin_port);
eport = ntohs(ownState.serveraddr.sin_port); eport = ntohs(ownState.serveraddr.sin_port);
if ((eport < 1000) || (eport > 10000)) if ((eport < 1000) || (eport > 30000))
{ {
eport = iport; eport = iport;
} }

View File

@ -24,6 +24,7 @@
*/ */
#include "pqi/p3dhtmgr.h" #include "pqi/p3dhtmgr.h"
#include "pqi/p3connmgr.h"
#include <openssl/sha.h> #include <openssl/sha.h>
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>
@ -54,7 +55,7 @@
#define DHT_SEARCH_PERIOD 1800 /* PeerKeys: if we haven't found them: 30 min */ #define DHT_SEARCH_PERIOD 1800 /* PeerKeys: if we haven't found them: 30 min */
#define DHT_CHECK_PERIOD 3600 /* PeerKeys: re-lookup peer: 60 min */ #define DHT_CHECK_PERIOD 3600 /* PeerKeys: re-lookup peer: 60 min */
#define DHT_PUBLISH_PERIOD 1800 /* OwnKey 30 min */ #define DHT_PUBLISH_PERIOD 1800 /* OwnKey 30 min */
#define DHT_NOTIFY_PERIOD 600 /* 10 min - Notify Check period */ #define DHT_NOTIFY_PERIOD 300 /* 5 min - Notify Check period */
#define DHT_RESTART_PERIOD 300 /* 5 min */ #define DHT_RESTART_PERIOD 300 /* 5 min */
#define DHT_DEFAULT_PERIOD 600 /* Default period if no work to do */ #define DHT_DEFAULT_PERIOD 600 /* Default period if no work to do */
@ -531,33 +532,64 @@ int p3DhtMgr::checkOwnDHTKeys()
/* check for connect requests */ /* check for connect requests */
if ((peer.state == DHT_PEER_PUBLISHED) && if ((peer.state == DHT_PEER_PUBLISHED) &&
(now - peer.notifyTS >= DHT_NOTIFY_PERIOD)) (!(peer.type & RS_NET_CONN_TCP_EXTERNAL)))
{ {
#ifdef DHT_DEBUG if (now - peer.notifyTS >= DHT_NOTIFY_PERIOD)
std::cerr << "p3DhtMgr::checkOwnDHTKeys() check for Notify (rep=0)";
std::cerr << std::endl;
#endif
if (dhtSearch(peer.hash1, DHT_MODE_NOTIFY))
{ {
dhtMtx.lock(); /* LOCK MUTEX */ #ifdef DHT_DEBUG
std::cerr << "p3DhtMgr::checkOwnDHTKeys() check for Notify (rep=0)";
std::cerr << std::endl;
#endif
if (dhtSearch(peer.hash1, DHT_MODE_NOTIFY))
{
dhtMtx.lock(); /* LOCK MUTEX */
ownEntry.notifyTS = now; ownEntry.notifyTS = now;
dhtMtx.unlock(); /* UNLOCK MUTEX */ dhtMtx.unlock(); /* UNLOCK MUTEX */
}
/* restart immediately */
repubPeriod = DHT_MIN_PERIOD;
return repubPeriod;
}
else
{
repubPeriod = DHT_NOTIFY_PERIOD -
(now - peer.notifyTS);
if (repubPeriod < DHT_MIN_PERIOD)
{
repubPeriod = DHT_MIN_PERIOD;
}
#ifdef DHT_DEBUG
std::cerr << "p3DhtMgr::checkOwnDHTKeys() check Notify in: ";
std::cerr << repubPeriod << std::endl;
#endif
} }
/* restart immediately */
repubPeriod = DHT_MIN_PERIOD;
return repubPeriod;
} }
else else
{ {
repubPeriod = DHT_NOTIFY_PERIOD - if (peer.state != DHT_PEER_PUBLISHED)
(now - peer.notifyTS); {
#ifdef DHT_DEBUG #ifdef DHT_DEBUG
std::cerr << "p3DhtMgr::checkOwnDHTKeys() check Notify in: "; std::cerr << "p3DhtMgr::checkOwnDHTKeys() No Notify until Published";
std::cerr << repubPeriod << std::endl; std::cerr << std::endl;
#endif #endif
}
else if (peer.type & RS_NET_CONN_TCP_EXTERNAL)
{
#ifdef DHT_DEBUG
std::cerr << "p3DhtMgr::checkOwnDHTKeys() No Notify because have Ext Addr";
std::cerr << std::endl;
#endif
}
else
{
#ifdef DHT_DEBUG
std::cerr << "p3DhtMgr::checkOwnDHTKeys() No Notify: Unknown Reason";
std::cerr << std::endl;
#endif
}
} }
} }

View File

@ -637,6 +637,7 @@ int RsServer::StartupRetroShare(RsInit *config)
server->StartupMonitor(); server->StartupMonitor();
mUpnpMgr->start(); mUpnpMgr->start();
mDhtMgr->start();
#ifdef PQI_USE_CHANNELS #ifdef PQI_USE_CHANNELS