Rewrite of the discovery system to be more private, with less traffic.

Split the visState into seperate vs_disc and vs_dht for easier handling.
Split the heartbeat system into a separate service.
Added IPv4 and IPv6 local/ext addresses into discovery & peer config.
Fixed up samenet and samesubnet ipv4 calls.




git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-initdev@6773 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2013-09-28 08:09:59 +00:00
parent 70c947ba90
commit 90aa57a0f0
38 changed files with 3248 additions and 1543 deletions

View file

@ -1,67 +0,0 @@
/*
* libretroshare/src/rsserver: p3discovery.cc
*
* RetroShare C++ Interface.
*
* Copyright 2008-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "rsserver/p3discovery.h"
#include <iostream>
RsDisc *rsDisc = NULL;
bool p3Discovery::getDiscGPGFriends(std::string id, std::list<std::string>& gpg_friends)
{
if (mDisc)
{
return mDisc->potentialGPGproxies(id, gpg_friends);
}
return false;
}
bool p3Discovery::getDiscFriends(std::string id, std::list<std::string> &friends)
{
if (mDisc)
{
return mDisc->potentialproxies(id, friends);
}
return false;
}
bool p3Discovery::getDiscVersions(std::map<std::string, std::string> &versions)
{
if (mDisc)
{
mDisc->getversions(versions);
return true;
}
return false;
}
bool p3Discovery::getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCount)
{
if (mDisc)
{
mDisc->getWaitingDiscCount(sendCount, recvCount);
return true;
}
return false;
}

View file

@ -1,51 +0,0 @@
#ifndef RETROSHARE_P3_DISC_INTERFACE_H
#define RETROSHARE_P3_DISC_INTERFACE_H
/*
* libretroshare/src/rsserver: p3discovery.h
*
* RetroShare C++ Interface.
*
* Copyright 2008-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "retroshare/rsdisc.h"
#include "services/p3disc.h"
class p3Discovery: public RsDisc
{
public:
p3Discovery(p3disc *disc)
:mDisc(disc) { return; }
virtual ~p3Discovery() { return; }
virtual bool getDiscFriends(std::string id, std::list<std::string> &friends);
virtual bool getDiscGPGFriends(std::string id, std::list<std::string> &gpg_friends);
virtual bool getDiscVersions(std::map<std::string, std::string> &versions);
virtual bool getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCount);
private:
p3disc *mDisc;
};
#endif

View file

@ -65,7 +65,8 @@ RsServer::RsServer(NotifyBase &callback)
mPluginsManager = NULL;
/* services */
ad = NULL;
mHeart = NULL;
mDisc = NULL;
msgSrv = NULL;
chatSrv = NULL;
mStatusSrv = NULL;

View file

@ -37,11 +37,13 @@
#include "retroshare/rstypes.h"
#include "util/rsthreads.h"
#include "services/p3disc.h"
#include "services/p3msgservice.h"
#include "services/p3chatservice.h"
#include "services/p3statusservice.h"
class p3heartbeat;
class p3discovery2;
/* GXS Classes - just declare the classes.
so we don't have to totally recompile to switch */
@ -171,7 +173,8 @@ class RsServer: public RsControl, public RsThread
//sslroot *sslr;
/* services */
p3disc *ad;
p3heartbeat *mHeart;
p3discovery2 *mDisc;
p3MsgService *msgSrv;
p3ChatService *chatSrv;
p3StatusService *mStatusSrv;

View file

@ -373,18 +373,8 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
break;
}
d.visState = 0;
if (!(ps.visState & RS_VIS_STATE_NODISC))
{
d.visState |= RS_VS_DISC_ON;
}
if (!(ps.visState & RS_VIS_STATE_NODHT))
{
d.visState |= RS_VS_DHT_ON;
}
d.vs_disc = ps.vs_disc;
d.vs_dht = ps.vs_dht;
/* Translate */
@ -645,7 +635,7 @@ bool p3Peers::addFriend(const std::string &ssl_id, const std::string &gpg_id,Se
* This will cause the SSL certificate to be retained for 30 days... and give the person a chance to connect!
* */
time_t now = time(NULL);
return mPeerMgr->addFriend(ssl_id, gpg_id, RS_NET_MODE_UDP, RS_VIS_STATE_STD, now, perm_flags);
return mPeerMgr->addFriend(ssl_id, gpg_id, RS_NET_MODE_UDP, RS_VS_DISC_FULL, RS_VS_DHT_FULL, now, perm_flags);
}
bool p3Peers::removeKeysFromPGPKeyring(const std::list<std::string>& pgp_ids,std::string& backup_file,uint32_t& error_code)
@ -875,20 +865,15 @@ bool p3Peers::setNetworkMode(const std::string &id, uint32_t extNetMode)
bool
p3Peers::setVisState(const std::string &id, uint32_t extVisState)
p3Peers::setVisState(const std::string &id, uint16_t vs_disc, uint16_t vs_dht)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setVisState() " << id << std::endl;
#endif
std::cerr << "p3Peers::setVisState() " << id << " " << extVisState << std::endl;
std::cerr << "p3Peers::setVisState() " << id << " DISC: " << vs_disc;
std::cerr << " DHT: " << vs_dht << std::endl;
uint32_t visState = 0;
if (!(extVisState & RS_VS_DHT_ON))
visState |= RS_VIS_STATE_NODHT;
if (!(extVisState & RS_VS_DISC_ON))
visState |= RS_VIS_STATE_NODISC;
return mPeerMgr->setVisState(id, visState);
return mPeerMgr->setVisState(id, vs_disc, vs_dht);
}
//===========================================================================
@ -1242,7 +1227,7 @@ RsPeerDetails::RsPeerDetails()
org(""),issuer(""),fpr(""),authcode(""),
trustLvl(0), validLvl(0),ownsign(false),
hasSignedMe(false),accept_connection(false),
state(0),localAddr(""),localPort(0),extAddr(""),extPort(0),netMode(0),visState(0),
state(0),localAddr(""),localPort(0),extAddr(""),extPort(0),netMode(0),vs_disc(0), vs_dht(0),
lastConnect(0),connectState(0),connectStateString(""),connectPeriod(0),foundDHT(false),
wasDeniedConnection(false), deniedTS(0)
{

View file

@ -90,7 +90,7 @@ virtual bool setLocalAddress(const std::string &id, const std::string &addr, uin
virtual bool setExtAddress(const std::string &id, const std::string &addr, uint16_t port);
virtual bool setDynDNS(const std::string &id, const std::string &dyndns);
virtual bool setNetworkMode(const std::string &id, uint32_t netMode);
virtual bool setVisState(const std::string &id, uint32_t mode);
virtual bool setVisState(const std::string &id, uint16_t vs_disc, uint16_t vs_dht);
virtual void getIPServersList(std::list<std::string>& ip_servers) ;
virtual void allowServerIPDetermination(bool) ;

View file

@ -289,7 +289,6 @@ void RsInit::InitRsConfig()
//setZoneLevel(PQL_DEBUG_BASIC, 82371); // pqiperson.
//setZoneLevel(PQL_DEBUG_BASIC, 34283); // pqihandler.
//setZoneLevel(PQL_DEBUG_BASIC, 44863); // discItems.
//setZoneLevel(PQL_DEBUG_BASIC, 2482); // p3disc
//setZoneLevel(PQL_DEBUG_BASIC, 1728); // pqi/p3proxy
//setZoneLevel(PQL_DEBUG_BASIC, 1211); // sslroot.
//setZoneLevel(PQL_DEBUG_BASIC, 37714); // pqissl.
@ -1780,8 +1779,9 @@ RsTurtle *rsTurtle = NULL ;
#include "upnp/upnphandler_miniupnp.h"
#endif
#endif
#include "services/p3disc.h"
#include "services/p3heartbeat.h"
#include "services/p3discovery2.h"
#include "services/p3msgservice.h"
#include "services/p3chatservice.h"
#include "services/p3statusservice.h"
@ -1815,7 +1815,6 @@ RsTurtle *rsTurtle = NULL ;
#include "rsserver/p3face.h"
#include "rsserver/p3peers.h"
#include "rsserver/p3msgs.h"
#include "rsserver/p3discovery.h"
#include "rsserver/p3status.h"
#include "rsserver/p3history.h"
#include "rsserver/p3serverconfig.h"
@ -2238,7 +2237,8 @@ int RsServer::StartupRetroShare()
mPluginsManager->setInterfaces(interfaces);
/* create Services */
ad = new p3disc(mPeerMgr, mLinkMgr, mNetMgr, pqih);
mDisc = new p3discovery2(mPeerMgr, mLinkMgr, mNetMgr);
mHeart = new p3heartbeat(mLinkMgr, pqih);
msgSrv = new p3MsgService(mLinkMgr);
chatSrv = new p3ChatService(mLinkMgr, mHistoryMgr);
mStatusSrv = new p3StatusService(mLinkMgr);
@ -2251,7 +2251,8 @@ int RsServer::StartupRetroShare()
chatSrv->connectToTurtleRouter(tr) ;
msgSrv->connectToTurtleRouter(tr) ;
pqih -> addService(ad);
pqih -> addService(mHeart);
pqih -> addService(mDisc);
pqih -> addService(msgSrv);
pqih -> addService(chatSrv);
pqih ->addService(mStatusSrv);
@ -2503,7 +2504,7 @@ int RsServer::StartupRetroShare()
/* need to Monitor too! */
mLinkMgr->addMonitor(pqih);
mLinkMgr->addMonitor(mCacheStrapper);
//mLinkMgr->addMonitor(ad);
mLinkMgr->addMonitor(mDisc);
mLinkMgr->addMonitor(msgSrv);
mLinkMgr->addMonitor(mStatusSrv);
mLinkMgr->addMonitor(chatSrv);
@ -2529,7 +2530,6 @@ int RsServer::StartupRetroShare()
mConfigMgr->addConfiguration("p3History.cfg", mHistoryMgr);
mConfigMgr->addConfiguration("p3Status.cfg", mStatusSrv);
mConfigMgr->addConfiguration("turtle.cfg", tr);
//mConfigMgr->addConfiguration("p3disc.cfg", ad);
#ifdef RS_USE_BITDHT
mConfigMgr->addConfiguration("bitdht.cfg", mBitDht);
@ -2583,7 +2583,7 @@ int RsServer::StartupRetroShare()
if (RsInitConfig::forceExtPort)
{
mPeerMgr->setOwnNetworkMode(RS_NET_MODE_EXT);
mPeerMgr->setOwnVisState(RS_VIS_STATE_STD);
mPeerMgr->setOwnVisState(RS_VS_DISC_FULL, RS_VS_DHT_FULL);
}
@ -2633,7 +2633,7 @@ int RsServer::StartupRetroShare()
/* Add AuthGPG services */
/**************************************************************************/
AuthGPG::getAuthGPG()->addService(ad);
AuthGPG::getAuthGPG()->addService(mDisc);
/**************************************************************************/
/* Force Any Last Configuration Options */
@ -2701,7 +2701,7 @@ int RsServer::StartupRetroShare()
/* Setup GUI Interfaces. */
rsDisc = new p3Discovery(ad);
rsDisc = mDisc;
rsBandwidthControl = mBwCtrl;
rsConfig = serverConfig;