mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Changes to get DHT On/Off working, and get DHT status working too:
* Plumbed stats through the the retroshare interface. * Also changed Channel store period back to 10 minutes.... (Reduce overall file count). This must be done some time before the any changes are made to Channels periods. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3721 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
89ca27ef66
commit
519075c70b
@ -118,35 +118,52 @@ void p3BitDht::start()
|
||||
|
||||
mUdpBitDht->start(); /* starts up the bitdht thread */
|
||||
|
||||
/* switch on the dht too */
|
||||
mUdpBitDht->startDht();
|
||||
/* dht switched on by config later. */
|
||||
}
|
||||
|
||||
/* pqiNetAssist - external interface functions */
|
||||
void p3BitDht::enable(bool on)
|
||||
{
|
||||
//mUdpBitDht->enable(on);
|
||||
std::cerr << "p3BitDht::enable(" << on << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
if (on)
|
||||
{
|
||||
mUdpBitDht->startDht();
|
||||
}
|
||||
else
|
||||
{
|
||||
mUdpBitDht->stopDht();
|
||||
}
|
||||
}
|
||||
|
||||
void p3BitDht::shutdown() /* blocking call */
|
||||
{
|
||||
//mUdpBitDht->shutdown();
|
||||
mUdpBitDht->stopDht();
|
||||
}
|
||||
|
||||
|
||||
void p3BitDht::restart()
|
||||
{
|
||||
//mUdpBitDht->restart();
|
||||
mUdpBitDht->stopDht();
|
||||
mUdpBitDht->startDht();
|
||||
}
|
||||
|
||||
bool p3BitDht::getEnabled()
|
||||
{
|
||||
return false;
|
||||
return (mUdpBitDht->stateDht() != 0);
|
||||
}
|
||||
|
||||
bool p3BitDht::getActive()
|
||||
{
|
||||
return false;
|
||||
return (mUdpBitDht->stateDht() >= BITDHT_MGR_STATE_ACTIVE);
|
||||
}
|
||||
|
||||
bool p3BitDht::getNetworkStats(uint32_t &netsize, uint32_t &localnetsize)
|
||||
{
|
||||
netsize = mUdpBitDht->statsNetworkSize();
|
||||
localnetsize = mUdpBitDht->statsBDVersionSize();
|
||||
return true;
|
||||
}
|
||||
|
||||
/* pqiNetAssistConnect - external interface functions */
|
||||
|
@ -56,6 +56,7 @@ virtual void restart();
|
||||
|
||||
virtual bool getEnabled();
|
||||
virtual bool getActive();
|
||||
virtual bool getNetworkStats(uint32_t &netsize, uint32_t &localnetsize);
|
||||
|
||||
/* pqiNetAssistConnect - external interface functions */
|
||||
|
||||
|
@ -146,6 +146,9 @@ pqiNetStatus::pqiNetStatus()
|
||||
:mLocalAddrOk(false), mExtAddrOk(false), mExtAddrStableOk(false),
|
||||
mUpnpOk(false), mDhtOk(false), mResetReq(false)
|
||||
{
|
||||
mDhtNetworkSize = 0;
|
||||
mDhtRsNetworkSize = 0;
|
||||
|
||||
sockaddr_clear(&mLocalAddr);
|
||||
sockaddr_clear(&mExtAddr);
|
||||
return;
|
||||
@ -164,6 +167,8 @@ void pqiNetStatus::print(std::ostream &out)
|
||||
out << " mDhtOk: " << mDhtOk;
|
||||
out << " mResetReq: " << mResetReq;
|
||||
out << std::endl;
|
||||
out << "mDhtNetworkSize: " << mDhtNetworkSize << " mDhtRsNetworkSize: " << mDhtRsNetworkSize;
|
||||
out << std::endl;
|
||||
out << "mLocalAddr: " << rs_inet_ntoa(mLocalAddr.sin_addr) << ":" << ntohs(mLocalAddr.sin_port) << " ";
|
||||
out << "mExtAddr: " << rs_inet_ntoa(mExtAddr.sin_addr) << ":" << ntohs(mExtAddr.sin_port) << " ";
|
||||
out << " NetOk: " << NetOk();
|
||||
@ -3117,15 +3122,20 @@ bool p3ConnectMgr::setLocation(std::string id, std::string location)
|
||||
|
||||
bool p3ConnectMgr::setVisState(std::string id, uint32_t visState)
|
||||
{
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
if (id == AuthSSL::getAuthSSL()->OwnId())
|
||||
{
|
||||
mOwnState.visState = visState;
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
return true;
|
||||
uint32_t netMode;
|
||||
{
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
netMode = mOwnState.netMode;
|
||||
}
|
||||
setOwnNetConfig(netMode, visState);
|
||||
return true;
|
||||
}
|
||||
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check if it is a friend */
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
bool isFriend = false;
|
||||
@ -3742,6 +3752,12 @@ void p3ConnectMgr::addNetAssistConnect(uint32_t id, pqiNetAssistConnect *dht)
|
||||
|
||||
bool p3ConnectMgr::enableNetAssistConnect(bool on)
|
||||
{
|
||||
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::enableNetAssistConnect(" << on << ")";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<uint32_t, pqiNetAssistConnect *>::iterator it;
|
||||
for(it = mDhts.begin(); it != mDhts.end(); it++)
|
||||
{
|
||||
@ -3757,9 +3773,20 @@ bool p3ConnectMgr::netAssistConnectEnabled()
|
||||
{
|
||||
if ((it->second)->getEnabled())
|
||||
{
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::netAssistConnectEnabled() YES";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::netAssistConnectEnabled() NO";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3771,14 +3798,56 @@ bool p3ConnectMgr::netAssistConnectActive()
|
||||
if ((it->second)->getActive())
|
||||
|
||||
{
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::netAssistConnectActive() ACTIVE";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::netAssistConnectActive() INACTIVE";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3ConnectMgr::netAssistConnectStats(uint32_t &netsize, uint32_t &localnetsize)
|
||||
{
|
||||
std::map<uint32_t, pqiNetAssistConnect *>::iterator it;
|
||||
for(it = mDhts.begin(); it != mDhts.end(); it++)
|
||||
{
|
||||
if (((it->second)->getActive()) && ((it->second)->getNetworkStats(netsize, localnetsize)))
|
||||
|
||||
{
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::netAssistConnectStats(";
|
||||
std::cerr << netsize << ", " << localnetsize << ")";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::netAssistConnectStats() INACTIVE";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3ConnectMgr::netAssistConnectShutdown()
|
||||
{
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::netAssistConnectShutdown()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<uint32_t, pqiNetAssistConnect *>::iterator it;
|
||||
for(it = mDhts.begin(); it != mDhts.end(); it++)
|
||||
{
|
||||
@ -3840,9 +3909,15 @@ bool p3ConnectMgr::getDHTEnabled()
|
||||
return netAssistConnectEnabled();
|
||||
}
|
||||
|
||||
|
||||
void p3ConnectMgr::getNetStatus(pqiNetStatus &status)
|
||||
{
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* quick update of the stuff that can change! */
|
||||
mNetFlags.mDhtOk = netAssistConnectActive();
|
||||
netAssistConnectStats(mNetFlags.mDhtNetworkSize, mNetFlags.mDhtRsNetworkSize);
|
||||
|
||||
status = mNetFlags;
|
||||
}
|
||||
|
||||
|
@ -187,6 +187,9 @@ class pqiNetStatus
|
||||
bool mUpnpOk; // upnp is ok.
|
||||
bool mDhtOk; // dht is ok.
|
||||
|
||||
uint32_t mDhtNetworkSize;
|
||||
uint32_t mDhtRsNetworkSize;
|
||||
|
||||
struct sockaddr_in mLocalAddr; // percieved ext addr.
|
||||
struct sockaddr_in mExtAddr; // percieved ext addr.
|
||||
|
||||
@ -231,6 +234,7 @@ bool retryConnect(std::string id);
|
||||
bool getUPnPState();
|
||||
bool getUPnPEnabled();
|
||||
bool getDHTEnabled();
|
||||
bool getDHTStats(uint32_t &netsize, uint32_t &localnetsize);
|
||||
|
||||
bool getIPServersEnabled();
|
||||
void setIPServersEnabled(bool b) ;
|
||||
@ -320,6 +324,8 @@ virtual bool enableNetAssistConnect(bool on);
|
||||
virtual bool netAssistConnectEnabled();
|
||||
virtual bool netAssistConnectActive();
|
||||
virtual bool netAssistConnectShutdown();
|
||||
virtual bool netAssistConnectStats(uint32_t &netsize, uint32_t &localnetsize);
|
||||
|
||||
|
||||
/* Assist Firewall */
|
||||
bool netAssistExtAddress(struct sockaddr_in &extAddr);
|
||||
|
@ -94,15 +94,6 @@ class pqiNetAssistConnect: public pqiNetAssist
|
||||
* for the DHT, and must be non-blocking and return quickly
|
||||
*/
|
||||
|
||||
#if 0
|
||||
virtual void setBootstrapAllowed(bool on) = 0;
|
||||
virtual bool getBootstrapAllowed() = 0;
|
||||
|
||||
/* set key data */
|
||||
virtual bool setExternalInterface(struct sockaddr_in laddr,
|
||||
struct sockaddr_in raddr, uint32_t type) = 0;
|
||||
#endif
|
||||
|
||||
/* add / remove peers */
|
||||
virtual bool findPeer(std::string id) = 0;
|
||||
virtual bool dropPeer(std::string id) = 0;
|
||||
@ -112,15 +103,11 @@ virtual bool getPeerStatus(std::string id,
|
||||
struct sockaddr_in &laddr, struct sockaddr_in &raddr,
|
||||
uint32_t &type, uint32_t &mode) = 0;
|
||||
|
||||
#if 0
|
||||
//virtual bool getExternalInterface(struct sockaddr_in &raddr,
|
||||
// uint32_t &mode) = 0;
|
||||
|
||||
/* post DHT key saying we should connect (callback when done) */
|
||||
virtual bool notifyPeer(std::string id) = 0;
|
||||
|
||||
/* stun */
|
||||
virtual bool enableStun(bool on) = 0;
|
||||
virtual bool addStun(std::string id) = 0;
|
||||
#endif
|
||||
/***** Stats for Network / DHT *****/
|
||||
virtual bool getNetworkStats(uint32_t &netsize, uint32_t &localnetsize) = 0;
|
||||
|
||||
protected:
|
||||
std::string mPeerId;
|
||||
@ -128,38 +115,5 @@ virtual bool addStun(std::string id) = 0;
|
||||
};
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
class pqiNetAssistConnectBitDht: public pqiNetAssist
|
||||
{
|
||||
/*
|
||||
*/
|
||||
public:
|
||||
pqiNetAssistConnectBitDht(std::string id, pqiConnectCb *cb)
|
||||
:mPeerId(id), mConnCb(cb) { return; }
|
||||
|
||||
/********** External DHT Interface ************************
|
||||
* These Functions are the external interface
|
||||
* for the DHT, and must be non-blocking and return quickly
|
||||
*/
|
||||
|
||||
/* add / remove peers */
|
||||
virtual bool findPeer(std::string id) = 0;
|
||||
virtual bool dropPeer(std::string id) = 0;
|
||||
|
||||
/* extract current peer status */
|
||||
virtual bool getPeerStatus(std::string id, struct sockaddr_in &raddr,
|
||||
uint32_t &mode) = 0;
|
||||
|
||||
virtual bool getExternalInterface(struct sockaddr_in &raddr,
|
||||
uint32_t &mode) = 0;
|
||||
|
||||
protected:
|
||||
std::string mPeerId;
|
||||
pqiConnectCb *mConnCb;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* MRK_PQI_ASSIST_H */
|
||||
|
||||
|
@ -44,7 +44,7 @@ static std::list<std::string> waitingIds;
|
||||
/****
|
||||
*#define PGRP_DEBUG 1
|
||||
****/
|
||||
#define PGRP_DEBUG 1
|
||||
//#define PGRP_DEBUG 1
|
||||
|
||||
/* MUTEX NOTES:
|
||||
* Functions like GetRsRawItem() lock itself (pqihandler) and
|
||||
|
@ -180,6 +180,10 @@ class RsConfig
|
||||
bool netDhtOk; /* response from dht */
|
||||
bool netStunOk; /* recvd stun / udp packets */
|
||||
bool netExtraAddressOk; /* recvd ip address with external finder*/
|
||||
|
||||
uint32_t netDhtNetSize; /* response from dht */
|
||||
uint32_t netDhtRsNetSize; /* response from dht */
|
||||
|
||||
};
|
||||
|
||||
/********************** For Search Interface *****************/
|
||||
|
@ -129,12 +129,16 @@ int RsServer::UpdateAllConfig()
|
||||
|
||||
pqiNetStatus status;
|
||||
mConnMgr->getNetStatus(status);
|
||||
|
||||
config.netLocalOk = status.mLocalAddrOk;
|
||||
config.netUpnpOk = status.mUpnpOk;
|
||||
config.netDhtOk = status.mDhtOk;
|
||||
config.netStunOk = false;
|
||||
config.netExtraAddressOk = status.mExtAddrOk;
|
||||
|
||||
config.netDhtOk = status.mDhtOk;
|
||||
config.netDhtNetSize = status.mDhtNetworkSize;
|
||||
config.netDhtRsNetSize = status.mDhtRsNetworkSize;
|
||||
|
||||
/* update DHT/UPnP config */
|
||||
|
||||
config.uPnPState = mConnMgr->getUPnPState();
|
||||
|
@ -805,6 +805,7 @@ p3Peers::setVisState(std::string id, uint32_t extVisState)
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::setVisState() " << id << std::endl;
|
||||
#endif
|
||||
std::cerr << "p3Peers::setVisState() " << id << " " << extVisState << std::endl;
|
||||
|
||||
uint32_t visState = 0;
|
||||
if (!(extVisState & RS_VS_DHT_ON))
|
||||
|
@ -66,7 +66,7 @@ RsChannels *rsChannels = NULL;
|
||||
* PUBPERIOD * 2^16 = max STORE PERIOD */
|
||||
#define CHANNEL_STOREPERIOD (30*24*3600) /* 30 * 24 * 3600 - secs in a 30 day month */
|
||||
#define TEST_CHANNEL_STOREPERIOD (24*3600) /* one day */
|
||||
#define CHANNEL_PUBPERIOD 60 /* 1 minutes ... (max = 455 days) */
|
||||
#define CHANNEL_PUBPERIOD 600 /* 10 minutes ... (max = 455 days) */
|
||||
#define MAX_AUTO_DL 1E9 /* auto download of attachment limit; 1 GIG */
|
||||
|
||||
p3Channels::p3Channels(uint16_t type, CacheStrapper *cs,
|
||||
|
Loading…
Reference in New Issue
Block a user