mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 00:19:25 -05:00
fixed up network simulator to work with new service control system and turtle client system
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7226 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
47c9971b5c
commit
900edb48cf
@ -1,19 +1,13 @@
|
||||
#include "MonitoredTurtle.h"
|
||||
|
||||
bool MonitoredTurtleRouter::performLocalHashSearch(const TurtleFileHash& hash,const RsPeerId& peer_id,FileInfo& info)
|
||||
bool MonitoredTurtleClient::handleTunnelRequest(const TurtleFileHash& hash,const RsPeerId& peer_id)
|
||||
{
|
||||
std::map<RsFileHash,FileInfo>::const_iterator it( _local_files.find(hash) ) ;
|
||||
|
||||
if(it != _local_files.end() )
|
||||
{
|
||||
info = it->second ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
return (it != _local_files.end() ) ;
|
||||
}
|
||||
|
||||
void MonitoredTurtleRouter::provideFileHash(const RsFileHash& hash)
|
||||
void MonitoredTurtleClient::provideFileHash(const RsFileHash& hash)
|
||||
{
|
||||
FileInfo& info( _local_files[hash] ) ;
|
||||
|
||||
|
@ -1,23 +1,16 @@
|
||||
#include <turtle/p3turtle.h>
|
||||
|
||||
class MonitoredTurtleRouter: public p3turtle
|
||||
class MonitoredTurtleClient: public RsTurtleClientService
|
||||
{
|
||||
public:
|
||||
MonitoredTurtleRouter(p3ServiceControl *sc,p3LinkMgr *lmgr,ftServer *fts)
|
||||
: p3turtle(sc,lmgr)
|
||||
{
|
||||
}
|
||||
public:
|
||||
virtual void addVirtualPeer(const TurtleFileHash& hash,const TurtleVirtualPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction dir) {}
|
||||
virtual void removeVirtualPeer(const TurtleFileHash& hash,const TurtleVirtualPeerId& virtual_peer_id) {}
|
||||
virtual void connectToTurtleRouter(p3turtle*p) { p->registerTunnelService(this) ; }
|
||||
|
||||
// Overload functions that I don't want to be called for real!
|
||||
bool handleTunnelRequest(const TurtleFileHash& hash,const RsPeerId& peer_id);
|
||||
void provideFileHash(const RsFileHash& hash);
|
||||
|
||||
virtual bool loadConfiguration(RsFileHash& loadHash) { return true ;}
|
||||
virtual bool saveConfiguration() { return true ;}
|
||||
virtual bool performLocalHashSearch(const TurtleFileHash& hash,const RsPeerId& peer_id,FileInfo& info) ;
|
||||
|
||||
// new functions to replace somme internal functionalities
|
||||
|
||||
void provideFileHash(const RsFileHash& hash) ;
|
||||
|
||||
private:
|
||||
std::map<RsFileHash,FileInfo> _local_files ;
|
||||
private:
|
||||
std::map<RsFileHash,FileInfo> _local_files ;
|
||||
};
|
||||
|
||||
|
@ -153,14 +153,41 @@ class FakePeerMgr: public p3PeerMgrIMPL
|
||||
|
||||
virtual bool idFriend(const RsPeerId& ssl_id) { return _ids.find(ssl_id) != _ids.end() ; }
|
||||
|
||||
std::set<RsPeerId> _ids ;
|
||||
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id)
|
||||
{
|
||||
return ~ServicePermissionFlags(0) ;
|
||||
}
|
||||
std::set<RsPeerId> _ids ;
|
||||
};
|
||||
|
||||
const RsTurtle *PeerNode::turtle_service() const
|
||||
{
|
||||
return _turtle ;
|
||||
}
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
PeerNode::PeerNode(const RsPeerId& id,const std::list<RsPeerId>& friends)
|
||||
: _id(id)
|
||||
{
|
||||
@ -170,14 +197,22 @@ PeerNode::PeerNode(const RsPeerId& id,const std::list<RsPeerId>& friends)
|
||||
p3PeerMgr *peer_mgr = new FakePeerMgr(id, friends) ;
|
||||
|
||||
_publisher = new FakePublisher ;
|
||||
p3ServiceControl *ctrl = new p3ServiceControl(link_mgr) ;
|
||||
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 MonitoredTurtleRouter(ctrl,link_mgr,ft_server),true) ;
|
||||
_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.
|
||||
//
|
||||
}
|
||||
@ -205,7 +240,7 @@ RsRawItem *PeerNode::outgoing()
|
||||
void PeerNode::provideFileHash(const RsFileHash& hash)
|
||||
{
|
||||
_provided_hashes.insert(hash) ;
|
||||
_turtle->provideFileHash(hash) ;
|
||||
_ftserver->provideFileHash(hash) ;
|
||||
}
|
||||
|
||||
void PeerNode::manageFileHash(const RsFileHash& hash)
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <turtle/p3turtle.h>
|
||||
|
||||
class MonitoredTurtleRouter ;
|
||||
class MonitoredTurtleClient ;
|
||||
class RsTurtle ;
|
||||
class RsRawItem ;
|
||||
class p3ServiceServer ;
|
||||
@ -46,8 +47,8 @@ class PeerNode
|
||||
|
||||
private:
|
||||
p3ServiceServer *_service_server ;
|
||||
MonitoredTurtleRouter *_turtle ;
|
||||
ftServer *_ftserver ;
|
||||
p3turtle *_turtle ;
|
||||
MonitoredTurtleClient *_ftserver ;
|
||||
pqiPublisher *_publisher ;
|
||||
RsPeerId _id ;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user