mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-16 13:02:27 -04:00
Removed p3ConnectMgr. Replaced it with p3LinkMgr, p3NetMgr and p3PeerMgr.
Updated references in other classes. * Most classes need p3LinkMgr, and only use two functions: OwnId() and getOnlineList() git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-netupgrade@4416 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
21487bfdf6
commit
f6f721a492
55 changed files with 1226 additions and 1044 deletions
|
@ -38,6 +38,9 @@ const int p3facemsgzone = 11453;
|
|||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "pqi/p3peermgr.h"
|
||||
#include "pqi/p3netmgr.h"
|
||||
|
||||
|
||||
/****************************************/
|
||||
/* RsIface Config */
|
||||
|
@ -106,18 +109,18 @@ int RsServer::UpdateAllConfig()
|
|||
|
||||
config.ownId = AuthSSL::getAuthSSL()->OwnId();
|
||||
config.ownName = AuthGPG::getAuthGPG()->getGPGOwnName();
|
||||
peerConnectState pstate;
|
||||
mConnMgr->getOwnNetStatus(pstate);
|
||||
peerState pstate;
|
||||
mPeerMgr->getOwnNetStatus(pstate);
|
||||
|
||||
/* ports */
|
||||
config.localAddr = rs_inet_ntoa(pstate.currentlocaladdr.sin_addr);
|
||||
config.localPort = ntohs(pstate.currentlocaladdr.sin_port);
|
||||
config.localAddr = rs_inet_ntoa(pstate.localaddr.sin_addr);
|
||||
config.localPort = ntohs(pstate.localaddr.sin_port);
|
||||
|
||||
config.firewalled = true;
|
||||
config.forwardPort = true;
|
||||
|
||||
config.extAddr = rs_inet_ntoa(pstate.currentserveraddr.sin_addr);
|
||||
config.extPort = ntohs(pstate.currentserveraddr.sin_port);
|
||||
config.extAddr = rs_inet_ntoa(pstate.serveraddr.sin_addr);
|
||||
config.extPort = ntohs(pstate.serveraddr.sin_port);
|
||||
|
||||
/* data rates */
|
||||
config.maxDownloadDataRate = (int) pqih -> getMaxRate(true); /* kb */
|
||||
|
@ -128,7 +131,7 @@ int RsServer::UpdateAllConfig()
|
|||
/* update network configuration */
|
||||
|
||||
pqiNetStatus status;
|
||||
mConnMgr->getNetStatus(status);
|
||||
mNetMgr->getNetStatus(status);
|
||||
|
||||
config.netLocalOk = status.mLocalAddrOk;
|
||||
config.netUpnpOk = status.mUpnpOk;
|
||||
|
@ -141,10 +144,10 @@ int RsServer::UpdateAllConfig()
|
|||
|
||||
/* update DHT/UPnP config */
|
||||
|
||||
config.uPnPState = mConnMgr->getUPnPState();
|
||||
config.uPnPActive = mConnMgr->getUPnPEnabled();
|
||||
config.uPnPState = mNetMgr->getUPnPState();
|
||||
config.uPnPActive = mNetMgr->getUPnPEnabled();
|
||||
config.DHTPeers = 20;
|
||||
config.DHTActive = mConnMgr->getDHTEnabled();
|
||||
config.DHTActive = mNetMgr->getDHTEnabled();
|
||||
|
||||
/* Notify of Changes */
|
||||
// iface.setChanged(RsIface::Config);
|
||||
|
@ -175,7 +178,7 @@ void RsServer::rsGlobalShutDown()
|
|||
// TODO: cache should also clean up old files
|
||||
|
||||
ConfigFinalSave(); // save configuration before exit
|
||||
mConnMgr->shutdown(); /* Handles UPnP */
|
||||
mNetMgr->shutdown(); /* Handles UPnP */
|
||||
|
||||
join();
|
||||
ftserver->StopThreads();
|
||||
|
|
|
@ -35,6 +35,11 @@
|
|||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "pqi/p3peermgr.h"
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include "pqi/p3netmgr.h"
|
||||
|
||||
|
||||
/****
|
||||
#define DEBUG_TICK 1
|
||||
****/
|
||||
|
@ -44,7 +49,9 @@ RsServer::RsServer(RsIface &i, NotifyBase &callback)
|
|||
{
|
||||
ftserver = NULL;
|
||||
|
||||
mConnMgr = NULL;
|
||||
mPeerMgr = NULL;
|
||||
mLinkMgr = NULL;
|
||||
mNetMgr = NULL;
|
||||
|
||||
pqih = NULL;
|
||||
|
||||
|
@ -144,8 +151,10 @@ void RsServer::run()
|
|||
|
||||
unlockRsCore();
|
||||
|
||||
/* tick the connection Manager */
|
||||
mConnMgr->tick();
|
||||
/* tick the Managers */
|
||||
mPeerMgr->tick();
|
||||
mLinkMgr->tick();
|
||||
mNetMgr->tick();
|
||||
/******************************** RUN SERVER *****************/
|
||||
|
||||
/* adjust tick rate depending on whether there is more.
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
//#include "pqi/pqissl.h"
|
||||
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
#include "pqi/p3connmgr.h"
|
||||
#include "pqi/pqipersongrp.h"
|
||||
|
||||
#include "retroshare/rsiface.h"
|
||||
|
@ -46,6 +45,11 @@
|
|||
#include "services/p3channels.h"
|
||||
#include "services/p3forums.h"
|
||||
|
||||
class p3PeerMgr;
|
||||
class p3LinkMgr;
|
||||
class p3NetMgr;
|
||||
|
||||
|
||||
/* The Main Interface Class - for controlling the server */
|
||||
|
||||
/* The init functions are actually Defined in p3face-startup.cc
|
||||
|
@ -150,7 +154,9 @@ class RsServer: public RsControl, public RsThread
|
|||
//filedexserver *server;
|
||||
ftServer *ftserver;
|
||||
|
||||
p3ConnectMgr *mConnMgr;
|
||||
p3PeerMgr *mPeerMgr;
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3NetMgr *mNetMgr;
|
||||
|
||||
pqipersongrp *pqih;
|
||||
|
||||
|
|
|
@ -25,7 +25,11 @@
|
|||
|
||||
#include "rsserver/p3peers.h"
|
||||
#include "rsserver/p3face.h"
|
||||
#include "pqi/p3connmgr.h"
|
||||
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include "pqi/p3peermgr.h"
|
||||
#include "pqi/p3netmgr.h"
|
||||
|
||||
#include "pqi/authssl.h"
|
||||
#include "pqi/authgpg.h"
|
||||
#include "retroshare/rsinit.h"
|
||||
|
@ -123,8 +127,8 @@ std::string RsPeerLastConnectString(uint32_t lastConnect)
|
|||
}
|
||||
|
||||
|
||||
p3Peers::p3Peers(p3ConnectMgr *cm)
|
||||
:mConnMgr(cm)
|
||||
p3Peers::p3Peers(p3LinkMgr *lm, p3PeerMgr *pm, p3NetMgr *nm)
|
||||
:mLinkMgr(lm), mPeerMgr(pm), mNetMgr(nm)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -176,7 +180,7 @@ bool p3Peers::getOnlineList(std::list<std::string> &ids)
|
|||
#endif
|
||||
|
||||
/* get from mConnectMgr */
|
||||
mConnMgr->getOnlineList(ids);
|
||||
mLinkMgr->getOnlineList(ids);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -187,7 +191,7 @@ bool p3Peers::getFriendList(std::list<std::string> &ids)
|
|||
#endif
|
||||
|
||||
/* get from mConnectMgr */
|
||||
mConnMgr->getFriendList(ids);
|
||||
mLinkMgr->getFriendList(ids);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -208,9 +212,15 @@ bool p3Peers::getPeerCount (unsigned int *pnFriendCount, unsigned int *pnOnlineC
|
|||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::getPeerCount()" << std::endl;
|
||||
#endif
|
||||
|
||||
/* get from mConnectMgr */
|
||||
return mConnMgr->getPeerCount(pnFriendCount, pnOnlineCount, ssl);
|
||||
// This is no longer accurate!
|
||||
*pnFriendCount = mLinkMgr->getFriendCount();
|
||||
*pnOnlineCount = mLinkMgr->getOnlineCount();
|
||||
|
||||
/* get from mConnectMgr */
|
||||
//return mConnMgr->getPeerCount(pnFriendCount, pnOnlineCount, ssl);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool p3Peers::isOnline(const std::string &id)
|
||||
|
@ -221,7 +231,7 @@ bool p3Peers::isOnline(const std::string &id)
|
|||
|
||||
/* get from mConnectMgr */
|
||||
peerConnectState state;
|
||||
if (mConnMgr->getFriendNetStatus(id, state) &&
|
||||
if (mLinkMgr->getFriendNetStatus(id, state) &&
|
||||
(state.state & RS_PEER_S_CONNECTED))
|
||||
{
|
||||
return true;
|
||||
|
@ -236,23 +246,9 @@ bool p3Peers::isFriend(const std::string &ssl_id)
|
|||
#endif
|
||||
|
||||
/* get from mConnectMgr */
|
||||
return mConnMgr->isFriend(ssl_id);
|
||||
return mPeerMgr->isFriend(ssl_id);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static struct sockaddr_in getPreferredAddress( const struct sockaddr_in& addr1,time_t ts1,
|
||||
const struct sockaddr_in& addr2,time_t ts2,
|
||||
const struct sockaddr_in& addr3,time_t ts3)
|
||||
{
|
||||
time_t ts = ts1 ;
|
||||
struct sockaddr_in addr = addr1 ;
|
||||
|
||||
if(ts2 > ts && strcmp(rs_inet_ntoa(addr2.sin_addr),"0.0.0.0")) { ts = ts2 ; addr = addr2 ; }
|
||||
if(ts3 > ts && strcmp(rs_inet_ntoa(addr3.sin_addr),"0.0.0.0")) { ts = ts3 ; addr = addr3 ; }
|
||||
|
||||
return addr ;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
|
||||
{
|
||||
|
@ -261,8 +257,8 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
|
|||
#endif
|
||||
//first, check if it's a gpg or a ssl id.
|
||||
std::string sOwnId = AuthSSL::getAuthSSL()->OwnId();
|
||||
peerConnectState pcs;
|
||||
if (id != sOwnId && !mConnMgr->getFriendNetStatus(id, pcs)) {
|
||||
peerState ps;
|
||||
if (id != sOwnId && !mPeerMgr->getFriendNetStatus(id, ps)) {
|
||||
//assume is not SSL, because every ssl_id has got a friend correspondance in mConnMgr
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::getPeerDetails() got a gpg id and is returning GPG details only for id : " << id << std::endl;
|
||||
|
@ -275,62 +271,51 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
|
|||
#endif
|
||||
|
||||
if (id == sOwnId) {
|
||||
mConnMgr->getOwnNetStatus(pcs);
|
||||
pcs.gpg_id = AuthGPG::getAuthGPG()->getGPGOwnId();
|
||||
mPeerMgr->getOwnNetStatus(ps);
|
||||
ps.gpg_id = AuthGPG::getAuthGPG()->getGPGOwnId();
|
||||
}
|
||||
|
||||
/* get from gpg (first), to fill in the sign and trust details */
|
||||
/* don't retrun now, we've got fill in the ssl and connection info */
|
||||
this->getGPGDetails(pcs.gpg_id, d);
|
||||
this->getGPGDetails(ps.gpg_id, d);
|
||||
d.isOnlyGPGdetail = false;
|
||||
|
||||
//get the ssl details
|
||||
d.id = id;
|
||||
d.location = pcs.location;
|
||||
d.location = ps.location;
|
||||
|
||||
/* generate */
|
||||
d.authcode = "AUTHCODE";
|
||||
|
||||
/* fill from pcs */
|
||||
|
||||
d.localAddr = rs_inet_ntoa(pcs.currentlocaladdr.sin_addr);
|
||||
d.localPort = ntohs(pcs.currentlocaladdr.sin_port);
|
||||
d.extAddr = rs_inet_ntoa(pcs.currentserveraddr.sin_addr);
|
||||
d.extPort = ntohs(pcs.currentserveraddr.sin_port);
|
||||
d.dyndns = pcs.dyndns;
|
||||
d.lastConnect = pcs.lastcontact;
|
||||
d.localAddr = rs_inet_ntoa(ps.localaddr.sin_addr);
|
||||
d.localPort = ntohs(ps.localaddr.sin_port);
|
||||
d.extAddr = rs_inet_ntoa(ps.serveraddr.sin_addr);
|
||||
d.extPort = ntohs(ps.serveraddr.sin_port);
|
||||
d.dyndns = ps.dyndns;
|
||||
d.lastConnect = ps.lastcontact;
|
||||
d.connectPeriod = 0;
|
||||
|
||||
|
||||
std::list<pqiIpAddress>::iterator it;
|
||||
for(it = pcs.ipAddrs.mLocal.mAddrs.begin();
|
||||
it != pcs.ipAddrs.mLocal.mAddrs.end(); it++)
|
||||
for(it = ps.ipAddrs.mLocal.mAddrs.begin();
|
||||
it != ps.ipAddrs.mLocal.mAddrs.end(); it++)
|
||||
{
|
||||
std::ostringstream toto;
|
||||
toto << ntohs(it->mAddr.sin_port) << " " << (time(NULL) - it->mSeenTime) << " sec";
|
||||
d.ipAddressList.push_back("L:" + std::string(rs_inet_ntoa(it->mAddr.sin_addr)) + ":" + toto.str());
|
||||
}
|
||||
for(it = pcs.ipAddrs.mExt.mAddrs.begin();
|
||||
it != pcs.ipAddrs.mExt.mAddrs.end(); it++)
|
||||
for(it = ps.ipAddrs.mExt.mAddrs.begin();
|
||||
it != ps.ipAddrs.mExt.mAddrs.end(); it++)
|
||||
{
|
||||
std::ostringstream toto;
|
||||
toto << ntohs(it->mAddr.sin_port) << " " << (time(NULL) - it->mSeenTime) << " sec";
|
||||
d.ipAddressList.push_back("E:" + std::string(rs_inet_ntoa(it->mAddr.sin_addr)) + ":" + toto.str());
|
||||
}
|
||||
|
||||
/* Translate */
|
||||
|
||||
d.state = 0;
|
||||
if (pcs.state & RS_PEER_S_FRIEND)
|
||||
d.state |= RS_PEER_STATE_FRIEND;
|
||||
if (pcs.state & RS_PEER_S_ONLINE)
|
||||
d.state |= RS_PEER_STATE_ONLINE;
|
||||
if (pcs.state & RS_PEER_S_CONNECTED)
|
||||
d.state |= RS_PEER_STATE_CONNECTED;
|
||||
if (pcs.state & RS_PEER_S_UNREACHABLE)
|
||||
d.state |= RS_PEER_STATE_UNREACHABLE;
|
||||
|
||||
switch(pcs.netMode & RS_NET_MODE_ACTUAL)
|
||||
switch(ps.netMode & RS_NET_MODE_ACTUAL)
|
||||
{
|
||||
case RS_NET_MODE_EXT:
|
||||
d.netMode = RS_NETMODE_EXT;
|
||||
|
@ -347,12 +332,13 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
|
|||
d.netMode = RS_NETMODE_UNREACHABLE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (pcs.netMode & RS_NET_MODE_TRY_EXT)
|
||||
|
||||
|
||||
if (ps.netMode & RS_NET_MODE_TRY_EXT)
|
||||
{
|
||||
d.tryNetMode = RS_NETMODE_EXT;
|
||||
}
|
||||
else if (pcs.netMode & RS_NET_MODE_TRY_UPNP)
|
||||
else if (ps.netMode & RS_NET_MODE_TRY_UPNP)
|
||||
{
|
||||
d.tryNetMode = RS_NETMODE_UPNP;
|
||||
}
|
||||
|
@ -360,17 +346,44 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
|
|||
{
|
||||
d.tryNetMode = RS_NETMODE_UDP;
|
||||
}
|
||||
|
||||
|
||||
d.visState = 0;
|
||||
if (!(pcs.visState & RS_VIS_STATE_NODISC))
|
||||
if (!(ps.visState & RS_VIS_STATE_NODISC))
|
||||
{
|
||||
d.visState |= RS_VS_DISC_ON;
|
||||
}
|
||||
|
||||
if (!(pcs.visState & RS_VIS_STATE_NODHT))
|
||||
|
||||
if (!(ps.visState & RS_VIS_STATE_NODHT))
|
||||
{
|
||||
d.visState |= RS_VS_DHT_ON;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Translate */
|
||||
peerConnectState pcs;
|
||||
if (!mLinkMgr->getFriendNetStatus(id, pcs))
|
||||
{
|
||||
std::cerr << "p3Peers::getPeerDetails() ERROR No Link Information : " << id << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::getPeerDetails() got a SSL id and is returning SSL and GPG details for id : " << id << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
d.state = 0;
|
||||
if (pcs.state & RS_PEER_S_FRIEND)
|
||||
d.state |= RS_PEER_STATE_FRIEND;
|
||||
if (pcs.state & RS_PEER_S_ONLINE)
|
||||
d.state |= RS_PEER_STATE_ONLINE;
|
||||
if (pcs.state & RS_PEER_S_CONNECTED)
|
||||
d.state |= RS_PEER_STATE_CONNECTED;
|
||||
if (pcs.state & RS_PEER_S_UNREACHABLE)
|
||||
d.state |= RS_PEER_STATE_UNREACHABLE;
|
||||
|
||||
|
||||
|
||||
/* Finally determine AutoConnect Status */
|
||||
|
@ -443,8 +456,8 @@ std::string p3Peers::getPeerName(const std::string &ssl_or_gpg_id)
|
|||
if (ssl_or_gpg_id == AuthSSL::getAuthSSL()->OwnId()) {
|
||||
return AuthGPG::getAuthGPG()->getGPGOwnName();
|
||||
}
|
||||
peerConnectState pcs;
|
||||
if (mConnMgr->getFriendNetStatus(ssl_or_gpg_id, pcs)) {
|
||||
peerState pcs;
|
||||
if (mPeerMgr->getFriendNetStatus(ssl_or_gpg_id, pcs)) {
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::getPeerName() got a ssl id. Name is : " << pcs.name << std::endl;
|
||||
#endif
|
||||
|
@ -507,14 +520,14 @@ bool p3Peers::getSSLChildListOfGPGId(const std::string &gpg_id, std::list<std::s
|
|||
}
|
||||
//let's roll throush the friends
|
||||
std::list<std::string> friendsIds;
|
||||
mConnMgr->getFriendList(friendsIds);
|
||||
peerConnectState pcs;
|
||||
mLinkMgr->getFriendList(friendsIds);
|
||||
peerState pcs;
|
||||
for (std::list<std::string>::iterator it = friendsIds.begin(); it != friendsIds.end(); it++)
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::getSSLChildListOfGPGId() iterating over friends id : " << *it << std::endl;
|
||||
#endif
|
||||
if (mConnMgr->getFriendNetStatus(*it, pcs) && pcs.gpg_id == gpg_id) {
|
||||
if (mPeerMgr->getFriendNetStatus(*it, pcs) && pcs.gpg_id == gpg_id) {
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::getSSLChildListOfGPGId() adding ssl id : " << pcs.id << std::endl;
|
||||
#endif
|
||||
|
@ -528,16 +541,16 @@ bool p3Peers::cleanUnusedLocations()
|
|||
{
|
||||
// Obtain all current locations of each GPG friend.
|
||||
//
|
||||
std::map<std::string,std::list<peerConnectState> > friends_info ;
|
||||
std::map<std::string,std::list<peerState> > friends_info ;
|
||||
std::list<std::string> friendSSLIds ;
|
||||
|
||||
mConnMgr->getFriendList(friendSSLIds);
|
||||
mLinkMgr->getFriendList(friendSSLIds);
|
||||
|
||||
for(std::list<std::string>::const_iterator it(friendSSLIds.begin());it!=friendSSLIds.end();++it)
|
||||
{
|
||||
peerConnectState pcs;
|
||||
peerState pcs;
|
||||
|
||||
if(mConnMgr->getFriendNetStatus(*it, pcs))
|
||||
if(mPeerMgr->getFriendNetStatus(*it, pcs))
|
||||
friends_info[pcs.gpg_id].push_back(pcs) ;
|
||||
}
|
||||
|
||||
|
@ -549,20 +562,20 @@ bool p3Peers::cleanUnusedLocations()
|
|||
|
||||
std::list<std::string> locations_to_remove ;
|
||||
|
||||
for(std::map<std::string,std::list<peerConnectState> >::iterator it(friends_info.begin());it!=friends_info.end();++it)
|
||||
for(std::map<std::string,std::list<peerState> >::iterator it(friends_info.begin());it!=friends_info.end();++it)
|
||||
{
|
||||
std::list<peerConnectState>& locations_list(it->second) ;
|
||||
std::list<peerState>& locations_list(it->second) ;
|
||||
|
||||
int size = locations_list.size() ;
|
||||
|
||||
std::cerr << " GPG id: " << it->first << std::endl ;
|
||||
|
||||
for(std::list<peerConnectState>::const_iterator itloc(locations_list.begin());itloc!=locations_list.end();++itloc)
|
||||
for(std::list<peerState>::const_iterator itloc(locations_list.begin());itloc!=locations_list.end();++itloc)
|
||||
std::cerr << " Location " << (*itloc).id << ", last contact " << now - (*itloc).lastcontact << " seconds ago" << std::endl ;
|
||||
|
||||
// Remove any location that is dummy. Update the list, such that we only look into non dummy friends later.
|
||||
//
|
||||
for(std::list<peerConnectState>::iterator itloc(locations_list.begin());itloc!=locations_list.end();)
|
||||
for(std::list<peerState>::iterator itloc(locations_list.begin());itloc!=locations_list.end();)
|
||||
if(size > 1 && isDummyFriend((*itloc).id))
|
||||
{
|
||||
locations_to_remove.push_back((*itloc).id) ;
|
||||
|
@ -570,7 +583,7 @@ bool p3Peers::cleanUnusedLocations()
|
|||
|
||||
std::cerr << " Removing dummy location: " << (*itloc).id << std::endl ;
|
||||
|
||||
std::list<peerConnectState>::iterator tmp(itloc) ;
|
||||
std::list<peerState>::iterator tmp(itloc) ;
|
||||
++tmp ;
|
||||
locations_list.erase(itloc) ;
|
||||
itloc=tmp ;
|
||||
|
@ -578,7 +591,7 @@ bool p3Peers::cleanUnusedLocations()
|
|||
else
|
||||
++itloc ;
|
||||
|
||||
for(std::list<peerConnectState>::const_iterator itloc(locations_list.begin());itloc!=locations_list.end();++itloc)
|
||||
for(std::list<peerState>::const_iterator itloc(locations_list.begin());itloc!=locations_list.end();++itloc)
|
||||
if(size > 1 && now > (*itloc).lastcontact + MAX_TIME_KEEP_LOCATION_WITHOUT_CONTACT)
|
||||
{
|
||||
locations_to_remove.push_back((*itloc).id) ;
|
||||
|
@ -628,8 +641,8 @@ std::string p3Peers::getGPGId(const std::string &sslid_or_gpgid)
|
|||
if (sslid_or_gpgid == AuthSSL::getAuthSSL()->OwnId()) {
|
||||
return AuthGPG::getAuthGPG()->getGPGOwnId();
|
||||
}
|
||||
peerConnectState pcs;
|
||||
if (mConnMgr->getFriendNetStatus(sslid_or_gpgid, pcs) || mConnMgr->getOthersNetStatus(sslid_or_gpgid, pcs)) {
|
||||
peerState pcs;
|
||||
if (mPeerMgr->getFriendNetStatus(sslid_or_gpgid, pcs) || mPeerMgr->getOthersNetStatus(sslid_or_gpgid, pcs)) {
|
||||
return pcs.gpg_id;
|
||||
} else {
|
||||
if ( AuthGPG::getAuthGPG()->isGPGId(sslid_or_gpgid)) {
|
||||
|
@ -653,7 +666,7 @@ bool p3Peers::addFriend(const std::string &id, const std::string &gpg_id)
|
|||
if (id == gpg_id || id == "") {
|
||||
return addDummyFriend(gpg_id);
|
||||
} else {
|
||||
return mConnMgr->addFriend(id, gpg_id);
|
||||
return mPeerMgr->addFriend(id, gpg_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -664,8 +677,8 @@ bool p3Peers::addDummyFriend(const std::string &gpg_id)
|
|||
#endif
|
||||
std::string dummy_ssl_id = "dummy"+ gpg_id;
|
||||
//check if this gpg_id already got a dummy friend
|
||||
if (!mConnMgr->isFriend(dummy_ssl_id)) {
|
||||
return mConnMgr->addFriend(dummy_ssl_id, gpg_id);
|
||||
if (!mPeerMgr->isFriend(dummy_ssl_id)) {
|
||||
return mPeerMgr->addFriend(dummy_ssl_id, gpg_id);
|
||||
} else {
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::addDummyFriend() dummy friend already exists for gpg_id : " << gpg_id << std::endl;
|
||||
|
@ -706,7 +719,7 @@ bool p3Peers::removeFriend(const std::string &ssl_or_gpgid)
|
|||
AuthGPG::getAuthGPG()->setAcceptToConnectGPGCertificate(ssl_or_gpgid, false);
|
||||
|
||||
//will remove if it's a ssl id
|
||||
mConnMgr->removeFriend(ssl_or_gpgid);
|
||||
mPeerMgr->removeFriend(ssl_or_gpgid);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
@ -718,16 +731,16 @@ bool p3Peers::connectAttempt(const std::string &id)
|
|||
std::cerr << "p3Peers::connectAttempt() " << id << std::endl;
|
||||
#endif
|
||||
|
||||
return mConnMgr->retryConnect(id);
|
||||
return mLinkMgr->retryConnect(id);
|
||||
}
|
||||
|
||||
void p3Peers::getIPServersList(std::list<std::string>& ip_servers)
|
||||
{
|
||||
mConnMgr->getIPServersList(ip_servers) ;
|
||||
mNetMgr->getIPServersList(ip_servers) ;
|
||||
}
|
||||
void p3Peers::allowServerIPDetermination(bool b)
|
||||
{
|
||||
mConnMgr->setIPServersEnabled(b) ;
|
||||
mNetMgr->setIPServersEnabled(b) ;
|
||||
}
|
||||
|
||||
void p3Peers::allowTunnelConnection(bool b)
|
||||
|
@ -735,12 +748,12 @@ void p3Peers::allowTunnelConnection(bool b)
|
|||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::allowTunnelConnection() set tunnel to : " << b << std::endl;
|
||||
#endif
|
||||
mConnMgr->setTunnelConnection(b) ;
|
||||
mLinkMgr->setTunnelConnection(b) ;
|
||||
}
|
||||
|
||||
bool p3Peers::getAllowServerIPDetermination()
|
||||
{
|
||||
return mConnMgr->getIPServersEnabled() ;
|
||||
return mNetMgr->getIPServersEnabled() ;
|
||||
}
|
||||
|
||||
bool p3Peers::getAllowTunnelConnection()
|
||||
|
@ -748,7 +761,7 @@ bool p3Peers::getAllowTunnelConnection()
|
|||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::getAllowTunnelConnection() tunnel is : " << mConnMgr->getTunnelConnection() << std::endl;
|
||||
#endif
|
||||
return mConnMgr->getTunnelConnection() ;
|
||||
return mLinkMgr->getTunnelConnection() ;
|
||||
}
|
||||
|
||||
bool p3Peers::setLocalAddress(const std::string &id, const std::string &addr_str, uint16_t port)
|
||||
|
@ -771,7 +784,7 @@ bool p3Peers::setLocalAddress(const std::string &id, const std::string &addr_st
|
|||
#endif
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART *******************/
|
||||
{
|
||||
return mConnMgr->setLocalAddress(id, addr);
|
||||
return mPeerMgr->setLocalAddress(id, addr);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -782,7 +795,7 @@ bool p3Peers::setLocation(const std::string &ssl_id, const std::string &locatio
|
|||
std::cerr << "p3Peers::setLocation() " << ssl_id << std::endl;
|
||||
#endif
|
||||
|
||||
return mConnMgr->setLocation(ssl_id, location);
|
||||
return mPeerMgr->setLocation(ssl_id, location);
|
||||
}
|
||||
bool p3Peers::setExtAddress(const std::string &id, const std::string &addr_str, uint16_t port)
|
||||
{
|
||||
|
@ -804,7 +817,7 @@ bool p3Peers::setExtAddress(const std::string &id, const std::string &addr_str,
|
|||
#endif
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART *******************/
|
||||
{
|
||||
return mConnMgr->setExtAddress(id, addr);
|
||||
return mPeerMgr->setExtAddress(id, addr);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -814,7 +827,7 @@ bool p3Peers::setDynDNS(const std::string &id, const std::string &dyndns)
|
|||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::setDynDNS() called with id: " << id << " dyndns: " << dyndns <<std::endl;
|
||||
#endif
|
||||
return mConnMgr->setDynDNS(id, dyndns);
|
||||
return mPeerMgr->setDynDNS(id, dyndns);
|
||||
}
|
||||
|
||||
bool p3Peers::setNetworkMode(const std::string &id, uint32_t extNetMode)
|
||||
|
@ -843,7 +856,7 @@ bool p3Peers::setNetworkMode(const std::string &id, uint32_t extNetMode)
|
|||
break;
|
||||
}
|
||||
|
||||
return mConnMgr->setNetworkMode(id, netMode);
|
||||
return mPeerMgr->setNetworkMode(id, netMode);
|
||||
}
|
||||
|
||||
|
||||
|
@ -861,7 +874,7 @@ p3Peers::setVisState(const std::string &id, uint32_t extVisState)
|
|||
if (!(extVisState & RS_VS_DISC_ON))
|
||||
visState |= RS_VIS_STATE_NODISC;
|
||||
|
||||
return mConnMgr->setVisState(id, visState);
|
||||
return mPeerMgr->setVisState(id, visState);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -1189,7 +1202,7 @@ bool p3Peers::setAcceptToConnectGPGCertificate(const std::string &gpg_id, bool
|
|||
std::list<std::string> sslFriends;
|
||||
this->getSSLChildListOfGPGId(gpg_id, sslFriends);
|
||||
for (std::list<std::string>::iterator it = sslFriends.begin(); it != sslFriends.end(); it++) {
|
||||
mConnMgr->removeFriend(*it);
|
||||
mPeerMgr->removeFriend(*it);
|
||||
}
|
||||
return AuthGPG::getAuthGPG()->setAcceptToConnectGPGCertificate(gpg_id, acceptance);
|
||||
}
|
||||
|
@ -1253,7 +1266,7 @@ bool p3Peers::addGroup(RsGroupInfo &groupInfo)
|
|||
std::cerr << "p3Peers::addGroup()" << std::endl;
|
||||
#endif
|
||||
|
||||
return mConnMgr->addGroup(groupInfo);
|
||||
return mPeerMgr->addGroup(groupInfo);
|
||||
}
|
||||
|
||||
bool p3Peers::editGroup(const std::string &groupId, RsGroupInfo &groupInfo)
|
||||
|
@ -1262,7 +1275,7 @@ bool p3Peers::editGroup(const std::string &groupId, RsGroupInfo &groupInfo)
|
|||
std::cerr << "p3Peers::editGroup()" << std::endl;
|
||||
#endif
|
||||
|
||||
return mConnMgr->editGroup(groupId, groupInfo);
|
||||
return mPeerMgr->editGroup(groupId, groupInfo);
|
||||
}
|
||||
|
||||
bool p3Peers::removeGroup(const std::string &groupId)
|
||||
|
@ -1271,7 +1284,7 @@ bool p3Peers::removeGroup(const std::string &groupId)
|
|||
std::cerr << "p3Peers::removeGroup()" << std::endl;
|
||||
#endif
|
||||
|
||||
return mConnMgr->removeGroup(groupId);
|
||||
return mPeerMgr->removeGroup(groupId);
|
||||
}
|
||||
|
||||
bool p3Peers::getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo)
|
||||
|
@ -1280,7 +1293,7 @@ bool p3Peers::getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo)
|
|||
std::cerr << "p3Peers::getGroupInfo()" << std::endl;
|
||||
#endif
|
||||
|
||||
return mConnMgr->getGroupInfo(groupId, groupInfo);
|
||||
return mPeerMgr->getGroupInfo(groupId, groupInfo);
|
||||
}
|
||||
|
||||
bool p3Peers::getGroupInfoList(std::list<RsGroupInfo> &groupInfoList)
|
||||
|
@ -1289,7 +1302,7 @@ bool p3Peers::getGroupInfoList(std::list<RsGroupInfo> &groupInfoList)
|
|||
std::cerr << "p3Peers::getGroupInfoList()" << std::endl;
|
||||
#endif
|
||||
|
||||
return mConnMgr->getGroupInfoList(groupInfoList);
|
||||
return mPeerMgr->getGroupInfoList(groupInfoList);
|
||||
}
|
||||
|
||||
bool p3Peers::assignPeerToGroup(const std::string &groupId, const std::string &peerId, bool assign)
|
||||
|
@ -1306,7 +1319,7 @@ bool p3Peers::assignPeersToGroup(const std::string &groupId, const std::list<std
|
|||
std::cerr << "p3Peers::assignPeersToGroup()" << std::endl;
|
||||
#endif
|
||||
|
||||
return mConnMgr->assignPeersToGroup(groupId, peerIds, assign);
|
||||
return mPeerMgr->assignPeersToGroup(groupId, peerIds, assign);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,13 +27,16 @@
|
|||
*/
|
||||
|
||||
#include "retroshare/rspeers.h"
|
||||
#include "pqi/p3connmgr.h"
|
||||
class p3LinkMgr;
|
||||
class p3PeerMgr;
|
||||
class p3NetMgr;
|
||||
|
||||
|
||||
class p3Peers: public RsPeers
|
||||
{
|
||||
public:
|
||||
|
||||
p3Peers(p3ConnectMgr *cm);
|
||||
p3Peers(p3LinkMgr *lm, p3PeerMgr *pm, p3NetMgr *nm);
|
||||
virtual ~p3Peers() { return; }
|
||||
|
||||
/* Updates ... */
|
||||
|
@ -115,7 +118,10 @@ virtual bool assignPeersToGroup(const std::string &groupId, const std::list<std:
|
|||
|
||||
private:
|
||||
|
||||
p3ConnectMgr *mConnMgr;
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3PeerMgr *mPeerMgr;
|
||||
p3NetMgr *mNetMgr;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1735,9 +1735,15 @@ RsTurtle *rsTurtle = NULL ;
|
|||
|
||||
#include "pqi/p3notify.h" // HACK - moved to pqi for compilation order.
|
||||
|
||||
#include "pqi/p3peermgr.h"
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include "pqi/p3netmgr.h"
|
||||
|
||||
|
||||
#include "tcponudp/tou.h"
|
||||
#include "tcponudp/rsudpstack.h"
|
||||
|
||||
|
||||
#ifdef RS_USE_BITDHT
|
||||
#include "dht/p3bitdht.h"
|
||||
#include "udp/udpstack.h"
|
||||
|
@ -1823,8 +1829,12 @@ int RsServer::StartupRetroShare()
|
|||
/* Setup Notify Early - So we can use it. */
|
||||
rsNotify = new p3Notify();
|
||||
|
||||
mConnMgr = new p3ConnectMgr();
|
||||
|
||||
mPeerMgr = new p3PeerMgr();
|
||||
mNetMgr = new p3NetMgr();
|
||||
mLinkMgr = new p3LinkMgr(mPeerMgr, mNetMgr);
|
||||
|
||||
mNetMgr->setManagers(mPeerMgr, mLinkMgr);
|
||||
|
||||
//load all the SSL certs as friends
|
||||
// std::list<std::string> sslIds;
|
||||
// AuthSSL::getAuthSSL()->getAuthenticatedList(sslIds);
|
||||
|
@ -1899,7 +1909,7 @@ int RsServer::StartupRetroShare()
|
|||
mUdpStack->addReceiver(mDhtStunner);
|
||||
|
||||
// NEXT BITDHT.
|
||||
p3BitDht *mBitDht = new p3BitDht(ownId, mConnMgr, mUdpStack, bootstrapfile);
|
||||
p3BitDht *mBitDht = new p3BitDht(ownId, mLinkMgr, mUdpStack, bootstrapfile);
|
||||
/* install external Pointer for Interface */
|
||||
rsDht = mBitDht;
|
||||
|
||||
|
@ -1956,20 +1966,21 @@ int RsServer::StartupRetroShare()
|
|||
//pqih = new pqipersongrpDummy(none, flags);
|
||||
|
||||
/****** New Ft Server **** !!! */
|
||||
ftserver = new ftServer(mConnMgr);
|
||||
ftserver->setP3Interface(pqih);
|
||||
ftserver = new ftServer(mLinkMgr);
|
||||
ftserver->setP3Interface(pqih);
|
||||
ftserver->setConfigDirectory(RsInitConfig::configDir);
|
||||
|
||||
ftserver->SetupFtServer(&(getNotify()));
|
||||
CacheStrapper *mCacheStrapper = ftserver->getCacheStrapper();
|
||||
CacheTransfer *mCacheTransfer = ftserver->getCacheTransfer();
|
||||
|
||||
/* setup any extra bits (Default Paths) */
|
||||
ftserver->setPartialsDirectory(emergencyPartialsDir);
|
||||
ftserver->setDownloadDirectory(emergencySaveDir);
|
||||
/* setup any extra bits (Default Paths) */
|
||||
ftserver->setPartialsDirectory(emergencyPartialsDir);
|
||||
ftserver->setDownloadDirectory(emergencySaveDir);
|
||||
|
||||
/* This should be set by config ... there is no default */
|
||||
//ftserver->setSharedDirectories(fileList);
|
||||
//ftserver->setSharedDirectories(fileList);
|
||||
|
||||
rsFiles = ftserver;
|
||||
|
||||
|
||||
|
@ -2013,11 +2024,11 @@ int RsServer::StartupRetroShare()
|
|||
mPluginsManager->loadPlugins(plugins_directories) ;
|
||||
|
||||
/* create Services */
|
||||
ad = new p3disc(mConnMgr, pqih);
|
||||
ad = new p3disc(mLinkMgr, pqih);
|
||||
#ifndef MINIMAL_LIBRS
|
||||
msgSrv = new p3MsgService(mConnMgr);
|
||||
chatSrv = new p3ChatService(mConnMgr);
|
||||
mStatusSrv = new p3StatusService(mConnMgr);
|
||||
msgSrv = new p3MsgService(mLinkMgr);
|
||||
chatSrv = new p3ChatService(mLinkMgr);
|
||||
mStatusSrv = new p3StatusService(mLinkMgr);
|
||||
#endif // MINIMAL_LIBRS
|
||||
|
||||
#ifndef PQI_DISABLE_TUNNEL
|
||||
|
@ -2026,7 +2037,7 @@ int RsServer::StartupRetroShare()
|
|||
mConnMgr->setP3tunnel(tn);
|
||||
#endif
|
||||
|
||||
p3turtle *tr = new p3turtle(mConnMgr,ftserver) ;
|
||||
p3turtle *tr = new p3turtle(mLinkMgr,ftserver) ;
|
||||
rsTurtle = tr ;
|
||||
pqih -> addService(tr);
|
||||
ftserver->connectToTurtleRouter(tr) ;
|
||||
|
@ -2064,7 +2075,7 @@ int RsServer::StartupRetroShare()
|
|||
mPluginsManager->registerCacheServices() ;
|
||||
|
||||
#ifndef RS_RELEASE
|
||||
p3GameLauncher *gameLauncher = new p3GameLauncher(mConnMgr);
|
||||
p3GameLauncher *gameLauncher = new p3GameLauncher(mLinkMgr);
|
||||
pqih -> addService(gameLauncher);
|
||||
|
||||
p3PhotoService *photoService = new p3PhotoService(RS_SERVICE_TYPE_PHOTO, /* .... for photo service */
|
||||
|
@ -2079,26 +2090,26 @@ int RsServer::StartupRetroShare()
|
|||
/**************************************************************************/
|
||||
|
||||
#ifdef RS_USE_BITDHT
|
||||
mConnMgr->addNetAssistConnect(1, mBitDht);
|
||||
mConnMgr->addNetListener(mUdpStack);
|
||||
mNetMgr->addNetAssistConnect(1, mBitDht);
|
||||
mNetMgr->addNetListener(mUdpStack);
|
||||
#endif
|
||||
mConnMgr->addNetAssistFirewall(1, mUpnpMgr);
|
||||
mNetMgr->addNetAssistFirewall(1, mUpnpMgr);
|
||||
|
||||
/**************************************************************************/
|
||||
/* need to Monitor too! */
|
||||
mConnMgr->addMonitor(pqih);
|
||||
mConnMgr->addMonitor(mCacheStrapper);
|
||||
mConnMgr->addMonitor(ad);
|
||||
mLinkMgr->addMonitor(pqih);
|
||||
mLinkMgr->addMonitor(mCacheStrapper);
|
||||
mLinkMgr->addMonitor(ad);
|
||||
#ifndef MINIMAL_LIBRS
|
||||
mConnMgr->addMonitor(msgSrv);
|
||||
mConnMgr->addMonitor(mStatusSrv);
|
||||
mConnMgr->addMonitor(chatSrv);
|
||||
mLinkMgr->addMonitor(msgSrv);
|
||||
mLinkMgr->addMonitor(mStatusSrv);
|
||||
mLinkMgr->addMonitor(chatSrv);
|
||||
#endif // MINIMAL_LIBRS
|
||||
|
||||
/* must also add the controller as a Monitor...
|
||||
* a little hack to get it to work.
|
||||
*/
|
||||
mConnMgr->addMonitor(((ftController *) mCacheTransfer));
|
||||
mLinkMgr->addMonitor(((ftController *) mCacheTransfer));
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue