Changes to Integrate DHT... first tests appear successful.

* Added testing stuff to libretroshare.pro, enabled UDP again,
 * fixed NO_TCP #define in p3connmgr.cc
 * Added PeerStatus() call to p3bitdht.cc to start connect to DHT address.
 * HACK change to p3peers.cc to display DHT results.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3586 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2010-10-02 00:52:59 +00:00
parent 0ca009c4fa
commit 05e908df12
4 changed files with 74 additions and 10 deletions

View File

@ -308,9 +308,11 @@ int p3BitDht::lookupNodeId(const std::string pid, bdNodeId *id)
int p3BitDht::lookupRsId(const bdNodeId *id, std::string &pid) int p3BitDht::lookupRsId(const bdNodeId *id, std::string &pid)
{ {
#ifdef DEBUG_BITDHT
std::cerr << "p3BitDht::lookupRsId() for : "; std::cerr << "p3BitDht::lookupRsId() for : ";
bdStdPrintNodeId(std::cerr, id); bdStdPrintNodeId(std::cerr, id);
std::cerr << std::endl; std::cerr << std::endl;
#endif
RsStackMutex stack(dhtMtx); RsStackMutex stack(dhtMtx);
@ -417,13 +419,24 @@ int p3BitDht::NodeCallback(const bdId *id, uint32_t peerflags)
/* we found it ... do callback to p3connmgr */ /* we found it ... do callback to p3connmgr */
//uint32_t cbflags = ONLINE | UNREACHABLE; //uint32_t cbflags = ONLINE | UNREACHABLE;
for(int i = 0; i < 10; i++)
{
std::cerr << "p3BitDht::NodeCallback() FOUND NODE!!!: "; std::cerr << "p3BitDht::NodeCallback() FOUND NODE!!!: ";
bdStdPrintNodeId(std::cerr, &(id->id)); bdStdPrintNodeId(std::cerr, &(id->id));
std::cerr << "-> " << pid << " flags: " << peerflags; std::cerr << "-> " << pid << " flags: " << peerflags;
std::cerr << std::endl; std::cerr << std::endl;
}
/* add address to set */
pqiIpAddrSet addrs;
pqiIpAddress addr;
addr.mAddr = id->addr;
addr.mSeenTime = time(NULL);
addr.mSrc = 0;
addrs.updateExtAddrs(addr);
int type = 0;
/* callback to say they are online */
mConnCb->peerStatus(pid, addrs, type, 0, RS_CB_DHT);
return 1; return 1;
} }
@ -439,7 +452,8 @@ int p3BitDht::NodeCallback(const bdId *id, uint32_t peerflags)
int p3BitDht::PeerCallback(const bdNodeId *id, uint32_t status) int p3BitDht::PeerCallback(const bdNodeId *id, uint32_t status)
{ {
std::cerr << "p3BitDht::PeerCallback() NOOP for NOW"; std::cerr << "p3BitDht::PeerCallback() NodeId: ";
bdStdPrintNodeId(std::cerr, id);
std::cerr << std::endl; std::cerr << std::endl;
/* is it one that we are interested in? */ /* is it one that we are interested in? */
@ -447,11 +461,29 @@ int p3BitDht::PeerCallback(const bdNodeId *id, uint32_t status)
/* check for translation */ /* check for translation */
if (lookupRsId(id, pid)) if (lookupRsId(id, pid))
{ {
std::cerr << "p3BitDht::PeerCallback() => RsId: ";
std::cerr << pid << " status: " << status;
std::cerr << " NOOP for NOW";
std::cerr << std::endl;
/* we found it ... do callback to p3connmgr */ /* we found it ... do callback to p3connmgr */
//uint32_t cbflags = ONLINE | REACHABLE; //uint32_t cbflags = ONLINE | REACHABLE;
/* callback to say they are online */
//mConnCb->peerStatus(ent.id, addrs, ent.type, 0, RS_CB_DHT);
//mConnCb->peerConnectRequest(peer.id, peer.laddr, RS_CB_DHT);
return 1; return 1;
} }
else
{
std::cerr << "p3BitDht::PeerCallback()";
std::cerr << " FAILED TO TRANSLATE ID ";
std::cerr << " status: " << status;
std::cerr << " NOOP for NOW";
std::cerr << std::endl;
}
return 0; return 0;
} }

View File

@ -25,8 +25,10 @@ release {
DEFINES *= PQI_DISABLE_TUNNEL DEFINES *= PQI_DISABLE_TUNNEL
} }
testnetwork { testnetwork {
DEFINES *= PQI_DISABLE_UDP # DEFINES *= PQI_DISABLE_UDP
DEFINES *= PQI_DISABLE_TUNNEL DEFINES *= PQI_DISABLE_TUNNEL
# DEFINES *= AUTHSSL_DEBUG GPG_DEBUG # DEFINES *= AUTHSSL_DEBUG GPG_DEBUG
@ -93,6 +95,20 @@ SOURCES += tcponudp/udppeer.cc \
} }
test_bitdht {
# DISABLE TCP CONNECTIONS...
DEFINES *= P3CONNMGR_NO_TCP_CONNECTIONS
# NO AUTO CONNECTIONS??? FOR TESTING DHT STATUS.
DEFINES *= P3CONNMGR_NO_AUTO_CONNECTION
# ENABLED UDP NOW.
}
use_blogs { use_blogs {
HEADERS += services/p3blogs.h HEADERS += services/p3blogs.h

View File

@ -2332,7 +2332,12 @@ bool p3ConnectMgr::retryConnect(std::string id)
std::cerr << "p3ConnectMgr::retryConnect() id: " << id << std::endl; std::cerr << "p3ConnectMgr::retryConnect() id: " << id << std::endl;
#endif #endif
#ifndef P3CONNMGR_NO_TCP_CONNECTIONS
retryConnectTCP(id); retryConnectTCP(id);
#endif // P3CONNMGR_NO_TCP_CONNECTIONS
return true; return true;
} }
@ -2514,7 +2519,7 @@ bool p3ConnectMgr::retryConnectTCP(std::string id)
if (it->second.inConnAttempt) { if (it->second.inConnAttempt) {
/* -> it'll automatically use the addresses we added */ /* -> it'll automatically use the addresses we added */
#ifdef CONN_DEBUG #ifdef CONN_DEBUG
std::cerr << "p3ConnectMgr::retryConnectTcp() Already in CONNECT ATTEMPT"; std::cerr << "p3ConnectMgr::retryConnectTCP() Already in CONNECT ATTEMPT";
std::cerr << std::endl; std::cerr << std::endl;
std::cerr << "p3ConnectMgr::retryConnectTCP() Remaining ConnAddr Count: " << it->second.connAddrs.size(); std::cerr << "p3ConnectMgr::retryConnectTCP() Remaining ConnAddr Count: " << it->second.connAddrs.size();
std::cerr << std::endl; std::cerr << std::endl;

View File

@ -395,6 +395,17 @@ bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d)
/* Finally determine AutoConnect Status */ /* Finally determine AutoConnect Status */
std::ostringstream autostr; std::ostringstream autostr;
/* HACK to display DHT Status info too */
if (pcs.dht.found)
{
autostr << "DHT:CONTACT!!! ";
}
else
{
autostr << "DHT:SEARCHING ";
}
if (pcs.inConnAttempt) if (pcs.inConnAttempt)
{ {
if (pcs.currentConnAddrAttempt.type & RS_NET_CONN_TUNNEL) { if (pcs.currentConnAddrAttempt.type & RS_NET_CONN_TUNNEL) {