Improvement to BanPeers Sharing Code.

* Added p3BanList as a service.
 * Added interfaces to communicate addresses.
 * Added debug to p3BanList.
 * Fixed several bugs in the AddEntry/Condense
 * Fixed Mutex deadlocks.

Improvements to Dsdv code too.
 * Added p3Dsdv as a service.
 * Added Function to create a TEST service for routing.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-dhtmods@4687 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2011-11-25 00:58:01 +00:00
parent 8d4a7ed4f0
commit 85ea54395b
15 changed files with 304 additions and 18 deletions

View file

@ -70,6 +70,11 @@ virtual int dhtConnectCallback(const bdId *srcId, const bdId *proxyId, const bdI
return mParent->ConnectCallback(srcId, proxyId, destId, mode, point, param, cbtype, errcode);
}
virtual int dhtInfoCallback(const bdId *id, uint32_t type, uint32_t flags, std::string info)
{
return mParent->InfoCallback(id, type, flags, info);
}
private:
p3BitDht *mParent;
@ -84,6 +89,8 @@ p3BitDht::p3BitDht(std::string id, pqiConnectCb *cb, p3NetMgr *nm,
mProxyStunner = NULL;
mRelay = NULL;
mPeerSharer = NULL;
std::string dhtVersion = "RS51"; // should come from elsewhere!
mOwnRsId = id;
@ -150,6 +157,10 @@ void p3BitDht::setupConnectBits(UdpStunner *dhtStunner, UdpStunner *proxyStun
mRelay = relay;
}
void p3BitDht::setupPeerSharer(pqiNetAssistPeerShare *sharer)
{
mPeerSharer = sharer;
}
void p3BitDht::start()
{

View file

@ -155,8 +155,7 @@ virtual std::string getUdpAddressString();
void setupConnectBits(UdpStunner *dhtStunner, UdpStunner *proxyStunner, UdpRelayReceiver *relay);
void setupPeerSharer(pqiNetAssistPeerShare *sharer);
void start(); /* starts up the bitdht thread */
@ -177,6 +176,7 @@ virtual bool getNetworkStats(uint32_t &netsize, uint32_t &localnetsize);
virtual bool findPeer(std::string id);
virtual bool dropPeer(std::string id);
virtual int addBadPeer(const struct sockaddr_in &addr, uint32_t reason, uint32_t flags, uint32_t age);
virtual int addKnownPeer(const std::string &pid, const struct sockaddr_in &addr, uint32_t flags);
//virtual int addFriend(const std::string pid);
//virtual int addFriendOfFriend(const std::string pid);
@ -219,6 +219,8 @@ int PeerCallback(const bdId *id, uint32_t status);
int ValueCallback(const bdNodeId *id, std::string key, uint32_t status);
int ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId *destId,
uint32_t mode, uint32_t point, uint32_t param, uint32_t cbtype, uint32_t errcode);
int InfoCallback(const bdId *id, uint32_t type, uint32_t flags, std::string info);
int OnlinePeerCallback_locked(const bdId *id, uint32_t status, DhtPeerDetails *dpd);
int UnreachablePeerCallback_locked(const bdId *id, uint32_t status, DhtPeerDetails *dpd);
@ -283,6 +285,8 @@ int calculateNodeId(const std::string pid, bdNodeId *id);
p3NetMgr *mNetMgr;
pqiNetAssistPeerShare *mPeerSharer;
RsMutex dhtMtx;
std::string mOwnRsId;

View file

@ -37,6 +37,50 @@
************************************* Dht Callback ***************************************
******************************************************************************************/
/**** dht NodeCallback ****
*
*
* In the old version, we used this to callback mConnCb->peerStatus()
* We might want to drop this, and concentrate on the connection stuff.
*
* -> if an new dht peer, then pass to Stunners.
* -> do we care if we know them? not really!
*/
int p3BitDht::InfoCallback(const bdId *id, uint32_t type, uint32_t flags, std::string info)
{
/* translate info */
std::string rsid;
struct sockaddr_in addr = id->addr;
int outtype = PNASS_TYPE_BADPEER;
int outreason = PNASS_REASON_UNKNOWN;
int outage = 0;
#ifdef DEBUG_BITDHT_COMMON
std::cerr << "p3BitDht::InfoCallback() likely BAD_PEER: ";
bdStdPrintId(std::cerr, id);
std::cerr << std::endl;
#endif
{
RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/
DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(id->id), RSDHT_PEERTYPE_ANY);
if (dpd)
{
rsid = dpd->mRsId;
}
}
if (mPeerSharer)
{
mPeerSharer->updatePeer(rsid, addr, outtype, outreason, outage);
}
return 1;
}
/**** dht NodeCallback ****
*

View file

@ -183,6 +183,13 @@ bool p3BitDht::dropPeer(std::string pid)
********************************* Basic Peer Details *************************************
******************************************************************************************/
int p3BitDht::addBadPeer(const struct sockaddr_in &addr, uint32_t reason, uint32_t flags, uint32_t age)
{
//mUdpBitDht->updateKnownPeer(&id, 0, bdflags);
return 1;
}
int p3BitDht::addKnownPeer(const std::string &pid, const struct sockaddr_in &addr, uint32_t flags)
{