moved code into separate directories

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7244 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-04-06 08:10:14 +00:00
parent 44a1f6f6f3
commit 1e0ea41b4a
24 changed files with 263 additions and 19 deletions

View File

@ -0,0 +1,19 @@
TEMPLATE = app
CONFIG *= qt qglviewer
QT *= xml opengl
INCLUDEPATH *= ../.. ..
TARGET = NetworkSim
DESTDIR = bin
SOURCES = main.cpp NetworkViewer.cpp NetworkSimulatorGUI.cpp \
TurtleRouterStatistics.cpp RsAutoUpdatePage.cpp
HEADERS = NetworkViewer.h NetworkSimulatorGUI.h \
TurtleRouterStatistics.h RsAutoUpdatePage.h
FORMS = NetworkSimulatorGUI.ui TurtleRouterStatistics.ui
LIBS *= ../../../lib/libretroshare.a ../../../../../libbitdht/src/lib/libbitdht.a ../../../../../../lib/sqlcipher/.libs/libsqlcipher.a ../../../../../openpgpsdk/src/lib/libops.a -lgnome-keyring -lupnp -lssl -lcrypto -lbz2 -lixml

View File

@ -1,19 +0,0 @@
TEMPLATE = app
CONFIG *= qt qglviewer
QT *= xml opengl
INCLUDEPATH *= ../.. ..
TARGET = NetworkSim
SOURCES = Network.cpp PeerNode.cpp main.cpp NetworkViewer.cpp NetworkSimulatorGUI.cpp \
TurtleRouterStatistics.cpp RsAutoUpdatePage.cpp MonitoredRsPeers.cpp \
MonitoredTurtle.cpp
HEADERS = Network.h PeerNode.h MonitoredTurtle.h NetworkViewer.h NetworkSimulatorGUI.h \
TurtleRouterStatistics.h RsAutoUpdatePage.h MonitoredRsPeers.h
FORMS = NetworkSimulatorGUI.ui TurtleRouterStatistics.ui
LIBS *= ../../lib/libretroshare.a ../../../../libbitdht/src/lib/libbitdht.a ../../../../../lib/sqlcipher/.libs/libsqlcipher.a ../../../../openpgpsdk/src/lib/libops.a -lgnome-keyring -lupnp -lssl -lcrypto -lbz2 -lixml

View File

@ -0,0 +1,90 @@
#pragma once
#include <pqi/p3linkmgr.h>
#include <pqi/p3peermgr.h>
#include <ft/ftserver.h>
class FakeLinkMgr: public p3LinkMgrIMPL
{
public:
FakeLinkMgr(const RsPeerId& own_id,const std::list<RsPeerId>& friends)
: p3LinkMgrIMPL(NULL,NULL),_own_id(own_id),_friends(friends)
{
}
virtual const RsPeerId& getOwnId() { return _own_id ; }
virtual void getOnlineList(std::list<RsPeerId>& lst) { lst = _friends ; }
virtual uint32_t getLinkType(const RsPeerId&) { return RS_NET_CONN_TCP_ALL | RS_NET_CONN_SPEED_NORMAL; }
virtual bool getPeerName(const RsPeerId &ssl_id, std::string &name) { name = ssl_id.toStdString() ; return true ;}
private:
RsPeerId _own_id ;
std::list<RsPeerId> _friends ;
};
class FakePublisher: public pqiPublisher
{
public:
virtual bool sendItem(RsRawItem *item)
{
_item_queue.push_back(item) ;
}
RsRawItem *outgoing()
{
if(_item_queue.empty())
return NULL ;
RsRawItem *item = _item_queue.front() ;
_item_queue.pop_front() ;
return item ;
}
private:
std::list<RsRawItem*> _item_queue ;
};
class FakePeerMgr: public p3PeerMgrIMPL
{
public:
FakePeerMgr(const RsPeerId& own,const std::list<RsPeerId>& ids)
: p3PeerMgrIMPL(own,RsPgpId(),"no name","location name")
{
for(std::list<RsPeerId>::const_iterator it(ids.begin());it!=ids.end();++it)
_ids.insert(*it) ;
}
virtual bool idFriend(const RsPeerId& ssl_id) { return _ids.find(ssl_id) != _ids.end() ; }
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id)
{
return ~ServicePermissionFlags(0) ;
}
std::set<RsPeerId> _ids ;
};
class FakeServiceControl: public p3ServiceControl
{
public:
FakeServiceControl(p3LinkMgr *lm)
: p3ServiceControl(lm),mLink(lm)
{
}
virtual void getPeersConnected(const uint32_t serviceId, std::set<RsPeerId> &peerSet)
{
std::list<RsPeerId> ids ;
mLink->getOnlineList(ids) ;
for(std::list<RsPeerId>::const_iterator it(ids.begin());it!=ids.end();++it)
peerSet.insert(*it) ;
}
virtual bool checkFilter(uint32_t,const RsPeerId& id)
{
return true ;
}
p3LinkMgr *mLink;
};

View File

@ -0,0 +1,81 @@
#include "PeerNode.h"
#include "FakeComponents.h"
#include "MonitoredTurtle.h"
PeerNode::PeerNode(const RsPeerId& id,const std::list<RsPeerId>& friends)
: _id(id)
{
// add a service server.
p3LinkMgr *link_mgr = new FakeLinkMgr(id, friends) ;
p3PeerMgr *peer_mgr = new FakePeerMgr(id, friends) ;
_publisher = new FakePublisher ;
p3ServiceControl *ctrl = new FakeServiceControl(link_mgr) ;
_service_server = new p3ServiceServer(_publisher,ctrl);
ftServer *ft_server = new ftServer(peer_mgr,ctrl) ;
_service_server->addService(_turtle = new p3turtle(ctrl,link_mgr),true) ;
_ftserver = new MonitoredTurtleClient ;
_ftserver->connectToTurtleRouter(_turtle) ;
RsServicePermissions perms;
perms.mDefaultAllowed = true ;
perms.mServiceId = RS_SERVICE_TYPE_TURTLE ;
ctrl->updateServicePermissions(RS_SERVICE_TYPE_TURTLE,perms) ;
// add a turtle router.
//
}
PeerNode::~PeerNode()
{
delete _service_server ;
}
void PeerNode::tick()
{
std::cerr << " ticking peer node " << _id << std::endl;
_service_server->tick() ;
}
void PeerNode::incoming(RsRawItem *item)
{
_service_server->recvItem(item) ;
}
RsRawItem *PeerNode::outgoing()
{
return dynamic_cast<FakePublisher*>(_publisher)->outgoing() ;
}
void PeerNode::provideFileHash(const RsFileHash& hash)
{
_provided_hashes.insert(hash) ;
_ftserver->provideFileHash(hash) ;
}
void PeerNode::manageFileHash(const RsFileHash& hash)
{
_managed_hashes.insert(hash) ;
_turtle->monitorTunnels(hash,_ftserver) ;
}
void PeerNode::getTrafficInfo(NodeTrafficInfo& info)
{
std::vector<std::vector<std::string> > hashes_info ;
std::vector<std::vector<std::string> > tunnels_info ;
std::vector<TurtleRequestDisplayInfo > search_reqs_info ;
std::vector<TurtleRequestDisplayInfo > tunnel_reqs_info ;
_turtle->getInfo(hashes_info,tunnels_info,search_reqs_info,tunnel_reqs_info) ;
for(uint32_t i=0;i<tunnels_info.size();++i)
{
info.local_src[tunnels_info[i][1]] = tunnels_info[i][0] ;
info.local_src[tunnels_info[i][2]] = tunnels_info[i][0] ;
}
}

View File

@ -0,0 +1,55 @@
#pragma once
#include <retroshare/rstypes.h>
#include <turtle/p3turtle.h>
class MonitoredTurtleRouter ;
class MonitoredTurtleClient ;
class RsTurtle ;
class p3turtle ;
class pqiPublisher ;
class RsRawItem ;
class p3ServiceServer ;
class PeerNode
{
public:
struct NodeTrafficInfo
{
std::map<std::string,std::string> local_src ; // peer id., tunnel id
std::map<std::string,std::string> local_dst ;
};
PeerNode(const RsPeerId& id,const std::list<RsPeerId>& friends) ;
~PeerNode() ;
RsRawItem *outgoing() ;
void incoming(RsRawItem *) ;
const RsPeerId& id() const { return _id ;}
void tick() ;
const RsTurtle *turtle_service() const { return _turtle ; }
// Turtle-related methods
//
void manageFileHash(const RsFileHash& hash) ;
void provideFileHash(const RsFileHash& hash) ;
const std::set<RsFileHash>& providedHashes() const { return _provided_hashes; }
const std::set<RsFileHash>& managedHashes() const { return _managed_hashes; }
void getTrafficInfo(NodeTrafficInfo& trinfo) ; //
private:
p3ServiceServer *_service_server ;
p3turtle *_turtle ;
MonitoredTurtleClient *_ftserver ;
pqiPublisher *_publisher ;
RsPeerId _id ;
std::set<RsFileHash> _provided_hashes ;
std::set<RsFileHash> _managed_hashes ;
};

View File

@ -0,0 +1,18 @@
TEMPLATE = lib
CONFIG *= staticlib
INCLUDEPATH *= ../../.. ..
TARGET = nscore
SOURCES = Network.cpp \
PeerNode.cpp \
MonitoredRsPeers.cpp \
MonitoredTurtle.cpp
HEADERS = Network.h \
PeerNode.h \
MonitoredTurtle.h \
MonitoredRsPeers.h
DESTDIR = ../lib