- Integrated the turtle search and download to the gui. Now the search handles both friend and turtle searching.

- added a console in config->server->F2F routing to be able to visualize turtle routing statistics

WARNING: this is not complete yet. The fllowing still needs to be done:
- detect duplicates in search results between turtle and friends search
- RegExpr search does ot work with turtle (still to code).
- search does not search own files. Is this really needed after all ?



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1540 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2009-08-16 20:10:53 +00:00
parent 44efa071f4
commit a293a39d1b
17 changed files with 384 additions and 160 deletions

View file

@ -57,7 +57,6 @@ const uint32_t MAX_UPNP_INIT = 10; /* seconds UPnP timeout */
/****
* #define CONN_DEBUG 1
***/
#define CONN_DEBUG 1
/****
* #define P3CONNMGR_NO_TCP_CONNECTIONS 1
***/
@ -667,14 +666,7 @@ void p3ConnectMgr::netUdpCheck()
/* get the addr from the configuration */
struct sockaddr_in iaddr = ownState.localaddr;
if(use_extr_addr_finder && mExtAddrFinder->hasValidIP(&tmpip))
{
extValid = true;
extAddr = tmpip ;
extAddr.sin_port = iaddr.sin_port ;
extAddrStable = true;
}
else if (mUpnpAddrValid)
if (mUpnpAddrValid)
{
extValid = true;
extAddr = mUpnpExtAddr;
@ -686,6 +678,13 @@ void p3ConnectMgr::netUdpCheck()
extAddr = mStunExtAddr;
extAddrStable = mStunAddrStable;
}
else if(use_extr_addr_finder && mExtAddrFinder->hasValidIP(&tmpip))
{
extValid = true;
extAddr = tmpip ;
extAddr.sin_port = iaddr.sin_port ;
extAddrStable = true;
}
if (extValid)
{
@ -1020,6 +1019,7 @@ bool p3ConnectMgr::stunCheck()
netReset();
}
#ifdef CONN_DEBUG
int i = 0;
for(i = 0; tou_getstunpeer(i, (struct sockaddr *) &raddr, &rlen,
(struct sockaddr *) &eaddr, &elen,
@ -1038,6 +1038,7 @@ bool p3ConnectMgr::stunCheck()
}
std::cerr << std::endl;
}
#endif
/* pass on udp status to dht */
if (tou_needstunpeers())

View file

@ -29,6 +29,7 @@
#include <inttypes.h>
#include <string>
#include <list>
#include <vector>
class RsTurtle;
extern RsTurtle *rsTurtle ;
@ -56,11 +57,11 @@ struct TurtleFileInfo
class RsTurtle
{
public:
enum FileSharingStrategy { SHARE_ENTIRE_NETWORK, SHARE_FRIENDS_ONLY } ;
RsTurtle() { _sharing_strategy = SHARE_ENTIRE_NETWORK ;}
virtual ~RsTurtle() {}
enum FileSharingStrategy { SHARE_ENTIRE_NETWORK, SHARE_FRIENDS_ONLY } ;
// Lauches a search request through the pipes, and immediately returns
// the request id, which will be further used by the gui to store results
// as they come back.
@ -85,6 +86,10 @@ class RsTurtle
void setFileSharingStrategy(FileSharingStrategy f) { _sharing_strategy = f ; }
// Get info from the turtle router. I use std strings to hide the internal structs.
virtual void getInfo(std::vector<std::vector<std::string> >&,std::vector<std::vector<std::string> >&,
std::vector<std::vector<std::string> >&,std::vector<std::vector<std::string> >&) const = 0;
protected:
FileSharingStrategy _sharing_strategy ;
};

View file

@ -1406,6 +1406,87 @@ bool p3turtle::performLocalHashSearch(const TurtleFileHash& hash,FileInfo& info)
return rsFiles->FileDetails(hash, RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_SPEC_ONLY, info);
}
static std::string printNumber(uint num,bool hex=false)
{
if(hex)
{
char tmp[100] ;
sprintf(tmp,"0x%08x",num) ;
return std::string(tmp) ;
}
else
{
std::ostringstream out ;
out << num ;
return out.str() ;
}
}
void p3turtle::getInfo( std::vector<std::vector<std::string> >& hashes_info,
std::vector<std::vector<std::string> >& tunnels_info,
std::vector<std::vector<std::string> >& search_reqs_info,
std::vector<std::vector<std::string> >& tunnel_reqs_info) const
{
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
time_t now = time(NULL) ;
hashes_info.clear() ;
for(std::map<TurtleFileHash,TurtleFileHashInfo>::const_iterator it(_incoming_file_hashes.begin());it!=_incoming_file_hashes.end();++it)
{
hashes_info.push_back(std::vector<std::string>()) ;
std::vector<std::string>& hashes(hashes_info.back()) ;
hashes.push_back(it->first) ;
hashes.push_back(it->second.name) ;
hashes.push_back(printNumber(it->second.tunnels.size())) ;
hashes.push_back(printNumber(now - it->second.time_stamp)+" secs ago") ;
}
#ifdef A_VOIR
for(std::map<TurtleFileHash,FileInfo>::const_iterator it(_outgoing_file_hashes.begin());it!=_outgoing_file_hashes.end();++it)
std::cerr << " hash=0x" << it->first << ", name=" << it->second.fname << ", size=" << it->second.size << std::endl ;
#endif
tunnels_info.clear();
for(std::map<TurtleTunnelId,TurtleTunnel>::const_iterator it(_local_tunnels.begin());it!=_local_tunnels.end();++it)
{
tunnels_info.push_back(std::vector<std::string>()) ;
std::vector<std::string>& tunnel(tunnels_info.back()) ;
tunnel.push_back(printNumber(it->first,true)) ;
tunnel.push_back(rsPeers->getPeerName(it->second.local_src)) ;
tunnel.push_back(rsPeers->getPeerName(it->second.local_dst)) ;
tunnel.push_back(it->second.hash) ;
tunnel.push_back(printNumber(now-it->second.time_stamp)) ;
}
search_reqs_info.clear();
for(std::map<TurtleSearchRequestId,TurtleRequestInfo>::const_iterator it(_search_requests_origins.begin());it!=_search_requests_origins.end();++it)
{
search_reqs_info.push_back(std::vector<std::string>()) ;
std::vector<std::string>& search_req(search_reqs_info.back()) ;
search_req.push_back(printNumber(it->first,true)) ;
search_req.push_back(rsPeers->getPeerName(it->second.origin)) ;
search_req.push_back(printNumber(now - it->second.time_stamp)) ;
}
tunnel_reqs_info.clear();
for(std::map<TurtleSearchRequestId,TurtleRequestInfo>::const_iterator it(_tunnel_requests_origins.begin());it!=_tunnel_requests_origins.end();++it)
{
tunnel_reqs_info.push_back(std::vector<std::string>()) ;
std::vector<std::string>& tunnel_req(tunnel_reqs_info.back()) ;
tunnel_req.push_back(printNumber(it->first,true)) ;
tunnel_req.push_back(rsPeers->getPeerName(it->second.origin)) ;
tunnel_req.push_back(printNumber(now - it->second.time_stamp)) ;
}
}
#ifdef P3TURTLE_DEBUG
void p3turtle::dumpState()
{

View file

@ -227,6 +227,12 @@ class p3turtle: public p3Service, public pqiMonitor, public RsTurtle, public ftS
//
virtual void stopMonitoringFileTunnels(const std::string& file_hash) ;
// get info about tunnels
virtual void getInfo(std::vector<std::vector<std::string> >&,
std::vector<std::vector<std::string> >&,
std::vector<std::vector<std::string> >&,
std::vector<std::vector<std::string> >&) const ;
/************* from pqiMonitor *******************/
// Informs the turtle router that some peers are (dis)connected. This should initiate digging new tunnels,
// and closing other tunnels.