mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-04 15:15:15 -04:00
Merge remote-tracking branch 'RetroShare/master' into pr_rsconfig
This commit is contained in:
commit
26fdd79b50
1146 changed files with 42987 additions and 27130 deletions
|
@ -41,11 +41,12 @@
|
|||
#include "services/rseventsservice.h"
|
||||
|
||||
|
||||
/****
|
||||
#define DEBUG_TICK 1
|
||||
****/
|
||||
/*******************
|
||||
#define TICK_DEBUG 1
|
||||
*******************/
|
||||
|
||||
#define WARN_BIG_CYCLE_TIME (0.2)
|
||||
|
||||
#ifdef WINDOWS_SYS
|
||||
#include "util/rstime.h"
|
||||
#include <sys/timeb.h>
|
||||
|
@ -73,14 +74,13 @@ static double getCurrentTS()
|
|||
// In some cases (VOIP) it's likely that we will need to set them temporarily to a very low
|
||||
// value, in order to favor a fast feedback
|
||||
|
||||
const double RsServer::minTimeDelta = 0.05; // 25;
|
||||
const double RsServer::maxTimeDelta = 0.2;
|
||||
const double RsServer::kickLimit = 0.15;
|
||||
const double RsServer::minTickInterval = 0.05;
|
||||
const double RsServer::maxTickInterval = 0.2;
|
||||
|
||||
|
||||
RsServer::RsServer() :
|
||||
coreMutex("RsServer"), mShutdownCallback([](int){}),
|
||||
coreReady(false)
|
||||
coreMutex("RsServer"), mShutdownCallback([](int){}),
|
||||
coreReady(false)
|
||||
{
|
||||
{
|
||||
RsEventsService* tmpRsEvtPtr = new RsEventsService();
|
||||
|
@ -108,21 +108,20 @@ RsServer::RsServer() :
|
|||
msgSrv = NULL;
|
||||
chatSrv = NULL;
|
||||
mStatusSrv = NULL;
|
||||
mGxsTunnels = NULL;
|
||||
mGxsTunnels = NULL;
|
||||
|
||||
mMin = 0;
|
||||
mLoop = 0;
|
||||
mLastts = getCurrentTS();
|
||||
mTickInterval = maxTickInterval ;
|
||||
mAvgRunDuration = 0;
|
||||
mLastRunDuration = 0;
|
||||
mCycle1 = 0;
|
||||
mCycle2 = 0;
|
||||
mCycle3 = 0;
|
||||
mCycle4 = 0;
|
||||
|
||||
/* caches (that need ticking) */
|
||||
|
||||
mLastts = getCurrentTS();
|
||||
mLastSec = 0; /* for the slower ticked stuff */
|
||||
mTimeDelta = 0.25 ;
|
||||
|
||||
mAvgTickRate = mTimeDelta;
|
||||
|
||||
/* caches (that need ticking) */
|
||||
|
||||
/* Config */
|
||||
/* config */
|
||||
mConfigMgr = NULL;
|
||||
mGeneralConfig = NULL;
|
||||
}
|
||||
|
@ -132,143 +131,137 @@ RsServer::~RsServer()
|
|||
delete mGxsTrans;
|
||||
}
|
||||
|
||||
/* General Internal Helper Functions
|
||||
----> MUST BE LOCKED!
|
||||
*/
|
||||
// General Internal Helper Functions ----> MUST BE LOCKED!
|
||||
|
||||
|
||||
|
||||
/* Thread Fn: Run the Core */
|
||||
void RsServer::threadTick()
|
||||
{
|
||||
rstime::rs_usleep(mTimeDelta * 1000000);
|
||||
|
||||
double ts = getCurrentTS();
|
||||
double delta = ts - mLastts;
|
||||
|
||||
/* for the fast ticked stuff */
|
||||
if (delta > mTimeDelta)
|
||||
{
|
||||
#ifdef DEBUG_TICK
|
||||
std::cerr << "Delta: " << delta << std::endl;
|
||||
std::cerr << "Time Delta: " << mTimeDelta << std::endl;
|
||||
std::cerr << "Avg Tick Rate: " << mAvgTickRate << std::endl;
|
||||
#ifdef TICK_DEBUG
|
||||
RsDbg() << "TICK_DEBUG ticking interval "<< mTickInterval << std::endl;
|
||||
#endif
|
||||
|
||||
mLastts = ts;
|
||||
// we try to tick at a regular interval which depends on the load
|
||||
// if there is time left, we sleep
|
||||
double timeToSleep = mTickInterval - mAvgRunDuration;
|
||||
|
||||
/******************************** RUN SERVER *****************/
|
||||
lockRsCore();
|
||||
// never sleep less than 50 ms
|
||||
if (timeToSleep < 0.050)
|
||||
timeToSleep = 0.050;
|
||||
|
||||
int moreToTick = pqih->tick();
|
||||
#ifdef TICK_DEBUG
|
||||
RsDbg() << "TICK_DEBUG will sleep " << (int) (1000 * timeToSleep) << " ms" << std::endl;
|
||||
#endif
|
||||
rstime::rs_usleep(timeToSleep * 1000000);
|
||||
|
||||
#ifdef DEBUG_TICK
|
||||
std::cerr << "RsServer::run() ftserver->tick(): moreToTick: " << moreToTick << std::endl;
|
||||
double ts = getCurrentTS();
|
||||
mLastts = ts;
|
||||
|
||||
// stuff we do always
|
||||
// tick the core
|
||||
#ifdef TICK_DEBUG
|
||||
RsDbg() << "TICK_DEBUG ticking server" << std::endl;
|
||||
#endif
|
||||
lockRsCore();
|
||||
int moreToTick = pqih->tick();
|
||||
unlockRsCore();
|
||||
// tick the managers
|
||||
#ifdef TICK_DEBUG
|
||||
RsDbg() << "TICK_DEBUG ticking mPeerMgr" << std::endl;
|
||||
#endif
|
||||
mPeerMgr->tick();
|
||||
#ifdef TICK_DEBUG
|
||||
RsDbg() << "TICK_DEBUG ticking mLinkMgr" << std::endl;
|
||||
#endif
|
||||
mLinkMgr->tick();
|
||||
#ifdef TICK_DEBUG
|
||||
RsDbg() << "TICK_DEBUG ticking mNetMgr" << std::endl;
|
||||
#endif
|
||||
mNetMgr->tick();
|
||||
|
||||
|
||||
// stuff we do every second
|
||||
if (ts - mCycle1 > 1)
|
||||
{
|
||||
#ifdef TICK_DEBUG
|
||||
RsDbg() << "TICK_DEBUG every second" << std::endl;
|
||||
#endif
|
||||
// slow services
|
||||
if (rsPlugins)
|
||||
rsPlugins->slowTickPlugins((rstime_t)ts);
|
||||
// UDP keepalive
|
||||
// tou_tick_stunkeepalive();
|
||||
// other stuff to tick
|
||||
// update();
|
||||
mCycle1 = ts;
|
||||
}
|
||||
|
||||
// stuff we do every five seconds
|
||||
if (ts - mCycle2 > 5)
|
||||
{
|
||||
#ifdef TICK_DEBUG
|
||||
RsDbg() << "TICK_DEBUG every 5 seconds" << std::endl;
|
||||
#endif
|
||||
// save stuff
|
||||
mConfigMgr->tick();
|
||||
mCycle2 = ts;
|
||||
}
|
||||
|
||||
// stuff we do every minute
|
||||
if (ts - mCycle3 > 60)
|
||||
{
|
||||
#ifdef TICK_DEBUG
|
||||
RsDbg() << "TICK_DEBUG every 60 seconds" << std::endl;
|
||||
#endif
|
||||
// force saving FileTransferStatus TODO
|
||||
// ftserver->saveFileTransferStatus();
|
||||
// see if we need to resave certs
|
||||
// AuthSSL::getAuthSSL()->CheckSaveCertificates();
|
||||
mCycle3 = ts;
|
||||
}
|
||||
|
||||
// stuff we do every hour
|
||||
if (ts - mCycle4 > 3600)
|
||||
{
|
||||
#ifdef TICK_DEBUG
|
||||
RsDbg() << "TICK_DEBUG every hour" << std::endl;
|
||||
#endif
|
||||
mCycle4 = ts;
|
||||
}
|
||||
|
||||
// ticking is done, now compute new values of mLastRunDuration, mAvgRunDuration and mTickInterval
|
||||
ts = getCurrentTS();
|
||||
mLastRunDuration = ts - mLastts;
|
||||
|
||||
// low-pass filter and don't let mAvgRunDuration exceeds maxTickInterval
|
||||
mAvgRunDuration = 0.1 * mLastRunDuration + 0.9 * mAvgRunDuration;
|
||||
if (mAvgRunDuration > maxTickInterval)
|
||||
mAvgRunDuration = maxTickInterval;
|
||||
|
||||
#ifdef TICK_DEBUG
|
||||
RsDbg() << "TICK_DEBUG new mLastRunDuration " << mLastRunDuration << " mAvgRunDuration " << mAvgRunDuration << std::endl;
|
||||
if (mLastRunDuration > WARN_BIG_CYCLE_TIME)
|
||||
RsDbg() << "TICK_DEBUG excessively long cycle time " << mLastRunDuration << std::endl;
|
||||
#endif
|
||||
|
||||
// if the core has returned that there is more to tick we decrease the ticking interval, else we increse it
|
||||
// this should be studied closer as I dont think that the core ever returns 1
|
||||
#ifdef TICK_DEBUG
|
||||
RsDbg() << "TICK_DEBUG moreToTick " << moreToTick << std::endl;
|
||||
#endif
|
||||
if (moreToTick == 1)
|
||||
mTickInterval = 0.9 * mTickInterval;
|
||||
else
|
||||
mTickInterval = 1.1 * mTickInterval;
|
||||
#ifdef TICK_DEBUG
|
||||
RsDbg() << "TICK_DEBUG new tick interval " << mTickInterval << std::endl;
|
||||
#endif
|
||||
|
||||
unlockRsCore();
|
||||
|
||||
/* tick the Managers */
|
||||
mPeerMgr->tick();
|
||||
mLinkMgr->tick();
|
||||
mNetMgr->tick();
|
||||
/******************************** RUN SERVER *****************/
|
||||
|
||||
/* adjust tick rate depending on whether there is more.
|
||||
*/
|
||||
|
||||
mAvgTickRate = 0.2 * mTimeDelta + 0.8 * mAvgTickRate;
|
||||
|
||||
if (1 == moreToTick)
|
||||
{
|
||||
mTimeDelta = 0.9 * mAvgTickRate;
|
||||
if (mTimeDelta > kickLimit)
|
||||
{
|
||||
/* force next tick in one sec
|
||||
* if we are reading data.
|
||||
*/
|
||||
mTimeDelta = kickLimit;
|
||||
mAvgTickRate = kickLimit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mTimeDelta = 1.1 * mAvgTickRate;
|
||||
}
|
||||
|
||||
/* limiter */
|
||||
if (mTimeDelta < minTimeDelta)
|
||||
{
|
||||
mTimeDelta = minTimeDelta;
|
||||
}
|
||||
else if (mTimeDelta > maxTimeDelta)
|
||||
{
|
||||
mTimeDelta = maxTimeDelta;
|
||||
}
|
||||
|
||||
/* Fast Updates */
|
||||
|
||||
|
||||
/* now we have the slow ticking stuff */
|
||||
/* stuff ticked once a second (but can be slowed down) */
|
||||
if ((int) ts > mLastSec)
|
||||
{
|
||||
mLastSec = (int) ts;
|
||||
|
||||
// Every second! (UDP keepalive).
|
||||
//tou_tick_stunkeepalive();
|
||||
|
||||
// every five loops (> 5 secs)
|
||||
if (mLoop % 5 == 0)
|
||||
{
|
||||
// update_quick_stats();
|
||||
|
||||
// Update All Every 5 Seconds.
|
||||
// These Update Functions do the locking themselves.
|
||||
#ifdef DEBUG_TICK
|
||||
std::cerr << "RsServer::run() Updates()" << std::endl;
|
||||
#endif
|
||||
|
||||
mConfigMgr->tick(); /* saves stuff */
|
||||
|
||||
}
|
||||
|
||||
// every 60 loops (> 1 min)
|
||||
if (++mLoop >= 60)
|
||||
{
|
||||
mLoop = 0;
|
||||
|
||||
/* force saving FileTransferStatus TODO */
|
||||
//ftserver->saveFileTransferStatus();
|
||||
|
||||
/* see if we need to resave certs */
|
||||
//AuthSSL::getAuthSSL()->CheckSaveCertificates();
|
||||
|
||||
/* hour loop */
|
||||
if (++mMin >= 60)
|
||||
{
|
||||
mMin = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Tick slow services */
|
||||
if(rsPlugins)
|
||||
rsPlugins->slowTickPlugins((rstime_t)ts);
|
||||
|
||||
// slow update tick as well.
|
||||
// update();
|
||||
} // end of slow tick.
|
||||
|
||||
} // end of only once a second.
|
||||
|
||||
#ifdef DEBUG_TICK
|
||||
double endCycleTs = getCurrentTS();
|
||||
double cycleTime = endCycleTs - ts;
|
||||
if (cycleTime > WARN_BIG_CYCLE_TIME)
|
||||
{
|
||||
std::string out;
|
||||
rs_sprintf(out, "RsServer::run() WARNING Excessively Long Cycle Time: %g secs => Please DEBUG", cycleTime);
|
||||
std::cerr << out << std::endl;
|
||||
}
|
||||
// keep the tick interval target within allowed limits
|
||||
if (mTickInterval < minTickInterval)
|
||||
mTickInterval = minTickInterval;
|
||||
else if (mTickInterval > maxTickInterval)
|
||||
mTickInterval = maxTickInterval;
|
||||
#ifdef TICK_DEBUG
|
||||
RsDbg() << "TICK_DEBUG new tick interval after limiter " << mTickInterval << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,9 @@ public:
|
|||
p3ChatService *chatSrv;
|
||||
p3StatusService *mStatusSrv;
|
||||
p3GxsTunnelService *mGxsTunnels;
|
||||
#ifdef RS_USE_I2P_BOB
|
||||
p3I2pBob *mI2pBob;
|
||||
#endif
|
||||
|
||||
// This list contains all threaded services. It will be used to shut them down properly.
|
||||
|
||||
|
@ -172,8 +174,8 @@ public:
|
|||
// p3Posted *mPosted;
|
||||
// p3PhotoService *mPhoto;
|
||||
// p3GxsCircles *mGxsCircles;
|
||||
// p3GxsNetService *mGxsNetService;
|
||||
// p3IdService *mGxsIdService;
|
||||
// p3GxsNetService *mGxsNetService;
|
||||
// p3IdService *mGxsIdService;
|
||||
// p3GxsForums *mGxsForums;
|
||||
// p3GxsChannels *mGxsChannels;
|
||||
// p3Wire *mWire;
|
||||
|
@ -188,16 +190,14 @@ public:
|
|||
|
||||
// Worker Data.....
|
||||
|
||||
int mMin ;
|
||||
int mLoop ;
|
||||
int mLastts ;
|
||||
long mLastSec ;
|
||||
double mAvgTickRate ;
|
||||
double mTimeDelta ;
|
||||
double mLastts;
|
||||
double mTickInterval;
|
||||
double mLastRunDuration;
|
||||
double mAvgRunDuration;
|
||||
double mCycle1, mCycle2, mCycle3, mCycle4;
|
||||
|
||||
static const double minTimeDelta; // 25;
|
||||
static const double maxTimeDelta;
|
||||
static const double kickLimit;
|
||||
static const double minTickInterval;
|
||||
static const double maxTickInterval;
|
||||
|
||||
/// @see RsControl::setShutdownCallback
|
||||
std::function<void(int)> mShutdownCallback;
|
||||
|
|
|
@ -376,11 +376,15 @@ bool p3Msgs::getMessageTagTypes(MsgTagType& tags)
|
|||
}
|
||||
|
||||
bool p3Msgs::MessageStar(const std::string &mid, bool star)
|
||||
|
||||
{
|
||||
return mMsgSrv->setMsgFlag(mid, star ? RS_MSG_FLAGS_STAR : 0, RS_MSG_FLAGS_STAR);
|
||||
}
|
||||
|
||||
bool p3Msgs::MessageJunk(const std::string &mid, bool junk)
|
||||
{
|
||||
return mMsgSrv->setMsgFlag(mid, junk ? RS_MSG_FLAGS_SPAM : 0, RS_MSG_FLAGS_SPAM);
|
||||
}
|
||||
|
||||
bool p3Msgs::setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color)
|
||||
{
|
||||
return mMsgSrv->setMessageTagType(tagId, text, rgb_color);
|
||||
|
|
|
@ -78,6 +78,7 @@ public:
|
|||
virtual bool MessageReplied(const std::string &mid, bool replied);
|
||||
virtual bool MessageForwarded(const std::string &mid, bool forwarded);
|
||||
virtual bool MessageStar(const std::string &mid, bool star);
|
||||
virtual bool MessageJunk(const std::string &mid, bool junk);
|
||||
virtual bool MessageLoadEmbeddedImages(const std::string &mid, bool load);
|
||||
virtual bool getMsgParentId(const std::string &msgId, std::string &msgParentId);
|
||||
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
* *
|
||||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright 2004-2008 by Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2015-2018 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* Copyright (C) 2004-2008 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2015-2020 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* Copyright (C) 2020 Asociación Civil Altermundi <info@altermundi.net> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -20,7 +21,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
#include "util/radix64.h"
|
||||
|
||||
#include "pgp/pgpkeyutil.h"
|
||||
|
||||
#include "rsserver/p3peers.h"
|
||||
|
@ -35,7 +36,8 @@
|
|||
#include "retroshare/rsinit.h"
|
||||
#include "retroshare/rsfiles.h"
|
||||
#include "util/rsurl.h"
|
||||
|
||||
#include "util/radix64.h"
|
||||
#include "util/rsbase64.h"
|
||||
#include "pgp/rscertificate.h"
|
||||
|
||||
#include <iostream>
|
||||
|
@ -1095,51 +1097,59 @@ bool p3Peers::setProxyServer(const uint32_t type, const std::string &addr_str, c
|
|||
|
||||
std::string p3Peers::getPGPKey(const RsPgpId& pgp_id,bool include_signatures)
|
||||
{
|
||||
unsigned char *mem_block = NULL;
|
||||
rs_owner_ptr<unsigned char> mem_block = nullptr;
|
||||
size_t mem_block_size = 0;
|
||||
|
||||
if( !AuthGPG::getAuthGPG()->exportPublicKey(
|
||||
RsPgpId(pgp_id), mem_block, mem_block_size,
|
||||
false, include_signatures ) )
|
||||
{
|
||||
std::cerr << "Cannot output certificate for id \"" << pgp_id
|
||||
<< "\". Sorry." << std::endl;
|
||||
return "" ;
|
||||
RsErr() << __PRETTY_FUNCTION__
|
||||
<< " Failure retriving certificate for id " << pgp_id
|
||||
<< std::endl;
|
||||
return "";
|
||||
}
|
||||
|
||||
RsPeerDetails Detail;
|
||||
if(!getGPGDetails(pgp_id,Detail)) return "";
|
||||
RsPeerDetails details;
|
||||
if(!getGPGDetails(pgp_id, details)) return "";
|
||||
|
||||
RsCertificate cert( Detail,mem_block,mem_block_size );
|
||||
delete[] mem_block ;
|
||||
auto certPtr =
|
||||
RsCertificate::fromMemoryBlock(details, mem_block, mem_block_size);
|
||||
|
||||
return cert.armouredPGPKey();
|
||||
free(mem_block);
|
||||
|
||||
if(certPtr) return certPtr->armouredPGPKey();
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
bool p3Peers::GetPGPBase64StringAndCheckSum( const RsPgpId& gpg_id,
|
||||
std::string& gpg_base64_string,
|
||||
std::string& gpg_base64_checksum)
|
||||
bool p3Peers::GetPGPBase64StringAndCheckSum(
|
||||
const RsPgpId& gpg_id,
|
||||
std::string& gpg_base64_string, std::string& gpg_base64_checksum )
|
||||
{
|
||||
gpg_base64_string = "" ;
|
||||
gpg_base64_checksum = "" ;
|
||||
|
||||
unsigned char *mem_block ;
|
||||
size_t mem_block_size ;
|
||||
rs_owner_ptr<unsigned char> mem_block = nullptr;
|
||||
size_t mem_block_size = 0;
|
||||
if(!AuthGPG::getAuthGPG()->exportPublicKey(
|
||||
gpg_id,mem_block,mem_block_size,false,false ))
|
||||
return false;
|
||||
|
||||
if(!AuthGPG::getAuthGPG()->exportPublicKey(gpg_id,mem_block,mem_block_size,false,false))
|
||||
return false ;
|
||||
RsBase64::encode(mem_block, mem_block_size, gpg_base64_string, true, false);
|
||||
|
||||
Radix64::encode(mem_block,mem_block_size,gpg_base64_string) ;
|
||||
uint32_t crc = PGPKeyManagement::compute24bitsCRC(mem_block,mem_block_size);
|
||||
|
||||
uint32_t crc = PGPKeyManagement::compute24bitsCRC((unsigned char *)mem_block,mem_block_size) ;
|
||||
free(mem_block);
|
||||
|
||||
unsigned char tmp[3] = { uint8_t((crc >> 16) & 0xff), uint8_t((crc >> 8) & 0xff), uint8_t(crc & 0xff) } ;
|
||||
Radix64::encode(tmp,3,gpg_base64_checksum) ;
|
||||
unsigned char tmp[3] = {
|
||||
uint8_t((crc >> 16) & 0xff),
|
||||
uint8_t((crc >> 8) & 0xff),
|
||||
uint8_t(crc & 0xff) } ;
|
||||
RsBase64::encode(tmp, 3, gpg_base64_checksum, true, false);
|
||||
|
||||
delete[] mem_block ;
|
||||
|
||||
return true ;
|
||||
return true;
|
||||
}
|
||||
|
||||
enum class RsShortInviteFieldType : uint8_t
|
||||
|
@ -1543,7 +1553,7 @@ std::string p3Peers::GetRetroshareInvite(
|
|||
}
|
||||
|
||||
RsCertificate cert(detail, mem_block, mem_block_size);
|
||||
delete[] mem_block;
|
||||
free(mem_block);
|
||||
|
||||
return cert.toStdString();
|
||||
}
|
||||
|
|
|
@ -141,7 +141,8 @@ public:
|
|||
virtual std::string GetRetroshareInvite(
|
||||
const RsPeerId& ssl_id = RsPeerId(),
|
||||
bool include_signatures = false, bool includeExtraLocators = true );
|
||||
virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures);
|
||||
RS_DEPRECATED /// @see RsPeers
|
||||
std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) override;
|
||||
|
||||
virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum);
|
||||
|
||||
|
|
|
@ -114,6 +114,8 @@ RsLoginHelper* rsLoginHelper = nullptr;
|
|||
|
||||
RsAccounts* rsAccounts = nullptr;
|
||||
|
||||
const RsInitErrorCategory RsInitErrorCategory::instance;
|
||||
|
||||
RsConfigOptions::RsConfigOptions()
|
||||
:
|
||||
autoLogin(false),
|
||||
|
@ -737,12 +739,13 @@ RsGRouter *rsGRouter = NULL ;
|
|||
#include "pgp/pgpauxutils.h"
|
||||
#include "services/p3idservice.h"
|
||||
#include "services/p3gxscircles.h"
|
||||
#include "services/p3wiki.h"
|
||||
#include "services/p3posted.h"
|
||||
#include "services/p3photoservice.h"
|
||||
#include "services/p3gxsforums.h"
|
||||
#include "services/p3gxschannels.h"
|
||||
|
||||
#include "services/p3wiki.h"
|
||||
#include "services/p3wire.h"
|
||||
#include "services/p3photoservice.h"
|
||||
|
||||
#endif // RS_ENABLE_GXS
|
||||
|
||||
|
@ -920,8 +923,10 @@ int RsServer::StartupRetroShare()
|
|||
mNetMgr->setManagers(mPeerMgr, mLinkMgr);
|
||||
|
||||
rsAutoProxyMonitor *autoProxy = rsAutoProxyMonitor::instance();
|
||||
#ifdef RS_USE_I2P_BOB
|
||||
mI2pBob = new p3I2pBob(mPeerMgr);
|
||||
autoProxy->addProxy(autoProxyType::I2PBOB, mI2pBob);
|
||||
#endif
|
||||
|
||||
//load all the SSL certs as friends
|
||||
// std::list<std::string> sslIds;
|
||||
|
@ -1361,36 +1366,39 @@ int RsServer::StartupRetroShare()
|
|||
|
||||
mGxsChannels->setNetworkExchangeService(gxschannels_ns) ;
|
||||
|
||||
#if 0 // PHOTO IS DISABLED FOR THE MOMENT
|
||||
#ifdef RS_USE_PHOTO
|
||||
/**** Photo service ****/
|
||||
RsGeneralDataService* photo_ds = new RsDataService(currGxsDir + "/", "photoV2_db",
|
||||
RS_SERVICE_GXS_TYPE_PHOTO, NULL, rsInitConfig->gxs_passwd);
|
||||
|
||||
// init gxs services
|
||||
mPhoto = new p3PhotoService(photo_ds, NULL, mGxsIdService);
|
||||
p3PhotoService *mPhoto = new p3PhotoService(photo_ds, NULL, mGxsIdService);
|
||||
|
||||
// create GXS photo service
|
||||
RsGxsNetService* photo_ns = new RsGxsNetService(
|
||||
RS_SERVICE_GXS_TYPE_PHOTO, photo_ds, nxsMgr,
|
||||
mPhoto, mPhoto->getServiceInfo(),
|
||||
mGxsIdService, mGxsCircles,mGxsIdService,
|
||||
mReputations, mGxsCircles,mGxsIdService,
|
||||
pgpAuxUtils);
|
||||
|
||||
mPhoto->setNetworkExchangeService(photo_ns);
|
||||
#endif
|
||||
|
||||
#if 0 // WIRE IS DISABLED FOR THE MOMENT
|
||||
#ifdef RS_USE_WIRE
|
||||
/**** Wire GXS service ****/
|
||||
RsGeneralDataService* wire_ds = new RsDataService(currGxsDir + "/", "wire_db",
|
||||
RS_SERVICE_GXS_TYPE_WIRE,
|
||||
NULL, rsInitConfig->gxs_passwd);
|
||||
RS_SERVICE_GXS_TYPE_WIRE, NULL, rsInitConfig->gxs_passwd);
|
||||
|
||||
mWire = new p3Wire(wire_ds, NULL, mGxsIdService);
|
||||
p3Wire *mWire = new p3Wire(wire_ds, NULL, mGxsIdService);
|
||||
|
||||
// create GXS photo service
|
||||
RsGxsNetService* wire_ns = new RsGxsNetService(
|
||||
RS_SERVICE_GXS_TYPE_WIRE, wire_ds, nxsMgr,
|
||||
mWire, mWire->getServiceInfo(),
|
||||
mGxsIdService, mGxsCircles,mGxsIdService,
|
||||
mReputations, mGxsCircles,mGxsIdService,
|
||||
pgpAuxUtils);
|
||||
|
||||
mWire->setNetworkExchangeService(wire_ns);
|
||||
#endif
|
||||
// now add to p3service
|
||||
pqih->addService(gxsid_ns, true);
|
||||
|
@ -1401,7 +1409,12 @@ int RsServer::StartupRetroShare()
|
|||
#endif
|
||||
pqih->addService(gxsforums_ns, true);
|
||||
pqih->addService(gxschannels_ns, true);
|
||||
//pqih->addService(photo_ns, true);
|
||||
#ifdef RS_USE_PHOTO
|
||||
pqih->addService(photo_ns, true);
|
||||
#endif
|
||||
#ifdef RS_USE_WIRE
|
||||
pqih->addService(wire_ns, true);
|
||||
#endif
|
||||
|
||||
# ifdef RS_GXS_TRANS
|
||||
RsGeneralDataService* gxstrans_ds = new RsDataService(
|
||||
|
@ -1627,13 +1640,20 @@ int RsServer::StartupRetroShare()
|
|||
mConfigMgr->addConfiguration("gxschannels_srv.cfg", mGxsChannels);
|
||||
mConfigMgr->addConfiguration("gxscircles.cfg" , gxscircles_ns);
|
||||
mConfigMgr->addConfiguration("posted.cfg" , posted_ns);
|
||||
mConfigMgr->addConfiguration("gxsposted_srv.cfg", mPosted);
|
||||
#ifdef RS_USE_WIKI
|
||||
mConfigMgr->addConfiguration("wiki.cfg", wiki_ns);
|
||||
#endif
|
||||
//mConfigMgr->addConfiguration("photo.cfg", photo_ns);
|
||||
//mConfigMgr->addConfiguration("wire.cfg", wire_ns);
|
||||
#ifdef RS_USE_PHOTO
|
||||
mConfigMgr->addConfiguration("photo.cfg", photo_ns);
|
||||
#endif
|
||||
#ifdef RS_USE_WIRE
|
||||
mConfigMgr->addConfiguration("wire.cfg", wire_ns);
|
||||
#endif
|
||||
#endif //RS_ENABLE_GXS
|
||||
#ifdef RS_USE_I2P_BOB
|
||||
mConfigMgr->addConfiguration("I2PBOB.cfg", mI2pBob);
|
||||
#endif
|
||||
|
||||
mPluginsManager->addConfigurations(mConfigMgr) ;
|
||||
|
||||
|
@ -1708,7 +1728,7 @@ int RsServer::StartupRetroShare()
|
|||
// now enable bob
|
||||
bobSettings bs;
|
||||
autoProxy->taskSync(autoProxyType::I2PBOB, autoProxyTask::getSettings, &bs);
|
||||
bs.enableBob = true;
|
||||
bs.enable = true;
|
||||
autoProxy->taskSync(autoProxyType::I2PBOB, autoProxyTask::setSettings, &bs);
|
||||
} else {
|
||||
std::cerr << "RsServer::StartupRetroShare failed to receive keys" << std::endl;
|
||||
|
@ -1779,7 +1799,9 @@ int RsServer::StartupRetroShare()
|
|||
/**************************************************************************/
|
||||
|
||||
// auto proxy threads
|
||||
#ifdef RS_USE_I2P_BOB
|
||||
startServiceThread(mI2pBob, "I2P-BOB");
|
||||
#endif
|
||||
|
||||
#ifdef RS_ENABLE_GXS
|
||||
// Must Set the GXS pointers before starting threads.
|
||||
|
@ -1793,8 +1815,12 @@ int RsServer::StartupRetroShare()
|
|||
rsGxsChannels = mGxsChannels;
|
||||
rsGxsTrans = mGxsTrans;
|
||||
|
||||
//rsPhoto = mPhoto;
|
||||
//rsWire = mWire;
|
||||
#if RS_USE_PHOTO
|
||||
rsPhoto = mPhoto;
|
||||
#endif
|
||||
#if RS_USE_WIRE
|
||||
rsWire = mWire;
|
||||
#endif
|
||||
|
||||
/*** start up GXS core runner ***/
|
||||
|
||||
|
@ -1808,8 +1834,12 @@ int RsServer::StartupRetroShare()
|
|||
startServiceThread(mGxsForums, "gxs forums");
|
||||
startServiceThread(mGxsChannels, "gxs channels");
|
||||
|
||||
//createThread(*mPhoto);
|
||||
//createThread(*mWire);
|
||||
#if RS_USE_PHOTO
|
||||
startServiceThread(mPhoto, "gxs photo");
|
||||
#endif
|
||||
#if RS_USE_WIRE
|
||||
startServiceThread(mWire, "gxs wire");
|
||||
#endif
|
||||
|
||||
// cores ready start up GXS net servers
|
||||
startServiceThread(gxsid_ns, "gxs id ns");
|
||||
|
@ -1821,8 +1851,12 @@ int RsServer::StartupRetroShare()
|
|||
startServiceThread(gxsforums_ns, "gxs forums ns");
|
||||
startServiceThread(gxschannels_ns, "gxs channels ns");
|
||||
|
||||
//createThread(*photo_ns);
|
||||
//createThread(*wire_ns);
|
||||
#if RS_USE_PHOTO
|
||||
startServiceThread(photo_ns, "gxs photo ns");
|
||||
#endif
|
||||
#if RS_USE_WIRE
|
||||
startServiceThread(wire_ns, "gxs wire ns");
|
||||
#endif
|
||||
|
||||
# ifdef RS_GXS_TRANS
|
||||
startServiceThread(mGxsTrans, "gxs trans");
|
||||
|
@ -1924,6 +1958,47 @@ void RsLoginHelper::getLocations(std::vector<RsLoginHelper::Location>& store)
|
|||
}
|
||||
}
|
||||
|
||||
std::error_condition RsLoginHelper::createLocationV2(
|
||||
RsPeerId& locationId, RsPgpId& pgpId,
|
||||
const std::string& locationName, const std::string& pgpName,
|
||||
const std::string& password )
|
||||
{
|
||||
if(isLoggedIn()) return RsInitErrorNum::ALREADY_LOGGED_IN;
|
||||
if(locationName.empty()) return RsInitErrorNum::INVALID_LOCATION_NAME;
|
||||
if(pgpId.isNull() && pgpName.empty())
|
||||
return RsInitErrorNum::PGP_NAME_OR_ID_NEEDED;
|
||||
|
||||
std::string errorMessage;
|
||||
if(pgpId.isNull() && !RsAccounts::GeneratePGPCertificate(
|
||||
pgpName, "", password, pgpId, 4096, errorMessage ) )
|
||||
{
|
||||
RS_ERR("Failure creating PGP key: ", errorMessage);
|
||||
return RsInitErrorNum::PGP_KEY_CREATION_FAILED;
|
||||
}
|
||||
|
||||
std::string sslPassword =
|
||||
RsRandom::random_alphaNumericString(RsInit::getSslPwdLen());
|
||||
|
||||
rsNotify->cachePgpPassphrase(password);
|
||||
rsNotify->setDisableAskPassword(true);
|
||||
|
||||
bool ret = RsAccounts::createNewAccount(
|
||||
pgpId, "", locationName, "", false, false, sslPassword,
|
||||
locationId, errorMessage );
|
||||
if(!ret)
|
||||
{
|
||||
RS_ERR("Failure creating SSL key: ", errorMessage);
|
||||
return RsInitErrorNum::SSL_KEY_CREATION_FAILED;
|
||||
}
|
||||
|
||||
RsInit::LoadPassword(sslPassword);
|
||||
ret = (RsInit::OK == attemptLogin(locationId, password));
|
||||
rsNotify->setDisableAskPassword(false);
|
||||
|
||||
return (ret ? std::error_condition() : RsInitErrorNum::LOGIN_FAILED);
|
||||
}
|
||||
|
||||
#if !RS_VERSION_AT_LEAST(0,6,6)
|
||||
bool RsLoginHelper::createLocation(
|
||||
RsLoginHelper::Location& l, const std::string& password,
|
||||
std::string& errorMessage, bool makeHidden, bool makeAutoTor )
|
||||
|
@ -1965,6 +2040,7 @@ bool RsLoginHelper::createLocation(
|
|||
rsNotify->setDisableAskPassword(false);
|
||||
return ret;
|
||||
}
|
||||
#endif // !RS_VERSION_AT_LEAST(0,6,6)
|
||||
|
||||
bool RsLoginHelper::isLoggedIn()
|
||||
{
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "rsloginhandler.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "retroshare/rsinit.h"
|
||||
#include "util/rsdebug.h"
|
||||
|
||||
//#define DEBUG_RSLOGINHANDLER 1
|
||||
|
||||
|
@ -497,8 +498,15 @@ bool RsLoginHandler::enableAutoLogin(const RsPeerId& ssl_id,const std::string& s
|
|||
NULL);
|
||||
|
||||
if (error) {
|
||||
RsErr() << __PRETTY_FUNCTION__
|
||||
<< " Could not store passwd using libsecret with"
|
||||
<< " error.code=" << error->code
|
||||
<< " error.domain=" << error->domain
|
||||
<< " error.message=\"" << error->message << "\"" << std::endl;
|
||||
if (error->code == 2)
|
||||
RsErr() << "Do have a key wallet installed?" << std::endl
|
||||
<< "Like gnome-keyring or other using \"Secret Service\" by DBus." << std::endl;
|
||||
g_error_free (error);
|
||||
std::cerr << "Could not store passwd using libsecret" << std::endl;
|
||||
return false;
|
||||
}
|
||||
std::cout << "Stored passwd " << "************************" << " using libsecret" << std::endl;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue