used RsInfo instead of std::cerr in authssl.cc

This commit is contained in:
csoler 2019-09-22 17:36:08 +02:00
commit 9b78447109
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
25 changed files with 954 additions and 254 deletions

View File

@ -153,7 +153,7 @@ build_script:
# scripts to run after build # scripts to run after build
after_build: after_build:
- mkdir %RS_DEPLOY% - mkdir %RS_DEPLOY%
- copy retroshare-nogui\src\retroshare-nogui.exe %RS_DEPLOY%\ - copy retroshare-service\src\retroshare-service.exe %RS_DEPLOY%\
- copy retroshare-gui\src\retroshare.exe %RS_DEPLOY%\ - copy retroshare-gui\src\retroshare.exe %RS_DEPLOY%\
## In Debug build winedeplyqt forget the non debug Qt libs ## In Debug build winedeplyqt forget the non debug Qt libs

View File

@ -145,7 +145,8 @@ void RsControlModule::run()
#endif #endif
RsInit::InitRsConfig(); RsInit::InitRsConfig();
int initResult = RsInit::InitRetroShare(argc, argv, true); RsConfigOptions opt;
int initResult = RsInit::InitRetroShare(opt);
if (initResult < 0) { if (initResult < 0) {
std::cerr << "RsControlModule: FATAL ERROR, initialising libretroshare FAILED." << std::endl; std::cerr << "RsControlModule: FATAL ERROR, initialising libretroshare FAILED." << std::endl;

View File

@ -614,4 +614,4 @@ namespace json
} }
} }
#endif //__SUPER_EASY_JSON_H__ #endif //__SUPER_EASY_JSON_H__

View File

@ -65,6 +65,7 @@ p3FileDatabase::p3FileDatabase(p3ServiceControl *mpeers)
mRemoteDirectories.clear() ; // we should load them! mRemoteDirectories.clear() ; // we should load them!
mOwnId = mpeers->getOwnId() ; mOwnId = mpeers->getOwnId() ;
mBannedFileListNeedsUpdate = false;
mLocalSharedDirs = new LocalDirectoryStorage(mFileSharingDir + "/" + LOCAL_SHARED_DIRS_FILE_NAME,mOwnId); mLocalSharedDirs = new LocalDirectoryStorage(mFileSharingDir + "/" + LOCAL_SHARED_DIRS_FILE_NAME,mOwnId);
mHashCache = new HashStorage(mFileSharingDir + "/" + HASH_CACHE_FILE_NAME) ; mHashCache = new HashStorage(mFileSharingDir + "/" + HASH_CACHE_FILE_NAME) ;

View File

@ -52,6 +52,8 @@ extern JsonApiServer* jsonApiServer;
*/ */
struct JsonApiServer : RsSingleJobThread, p3Config struct JsonApiServer : RsSingleJobThread, p3Config
{ {
static const uint16_t DEFAULT_PORT = 9092 ;
/** /**
* @brief construct a JsonApiServer instance with given parameters * @brief construct a JsonApiServer instance with given parameters
* @param[in] port listening port fpt the JSON API socket * @param[in] port listening port fpt the JSON API socket
@ -62,7 +64,7 @@ struct JsonApiServer : RsSingleJobThread, p3Config
* false otherwise, this usually requires user interacion to confirm access * false otherwise, this usually requires user interacion to confirm access
*/ */
JsonApiServer( JsonApiServer(
uint16_t port = 9092, uint16_t port = DEFAULT_PORT,
const std::string& bindAddress = "127.0.0.1", const std::string& bindAddress = "127.0.0.1",
const std::function<bool(const std::string&)> newAccessRequestCallback = [](const std::string&){return false;} ); const std::function<bool(const std::string&)> newAccessRequestCallback = [](const std::string&){return false;} );

View File

@ -480,6 +480,7 @@ HEADERS += turtle/p3turtle.h \
HEADERS += util/folderiterator.h \ HEADERS += util/folderiterator.h \
util/rsdebug.h \ util/rsdebug.h \
util/rskbdinput.h \
util/rsmemory.h \ util/rsmemory.h \
util/smallobject.h \ util/smallobject.h \
util/rsdir.h \ util/rsdir.h \
@ -626,6 +627,7 @@ SOURCES += turtle/p3turtle.cc \
SOURCES += util/folderiterator.cc \ SOURCES += util/folderiterator.cc \
util/rsdebug.cc \ util/rsdebug.cc \
util/rskbdinput.cc \
util/rsexpr.cc \ util/rsexpr.cc \
util/smallobject.cc \ util/smallobject.cc \
util/rsdir.cc \ util/rsdir.cc \

View File

@ -1128,7 +1128,7 @@ bool AuthSSLimpl::AuthX509WithGPG(X509 *x509,bool verbose, uint32_t& diagnostic)
} }
if(verbose) if(verbose)
std::cerr<< " Verified: " << sigtypestring RsInfo() << " Verified: " << sigtypestring
<< " signature of certificate sslId: " << " signature of certificate sslId: "
<< RsX509Cert::getCertSslId(*x509) << RsX509Cert::getCertSslId(*x509)
<< ", Version " << std::hex << certificate_version << std::dec << ", Version " << std::hex << certificate_version << std::dec

View File

@ -3,8 +3,8 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright (C) 2012 Robert Fernie <retroshare@lunamutt.com> * * Copyright (C) 2012-2014 Robert Fernie <retroshare@lunamutt.com> *
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org> * * Copyright (C) 2018-2019 Gioacchino Mazzurco <gio@eigenlab.org> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -32,6 +32,7 @@
#include "retroshare/rsgxsifacehelper.h" #include "retroshare/rsgxsifacehelper.h"
#include "retroshare/rsidentity.h" #include "retroshare/rsidentity.h"
#include "serialiser/rsserializable.h" #include "serialiser/rsserializable.h"
#include "util/rsmemory.h"
class RsGxsCircles; class RsGxsCircles;
@ -74,8 +75,6 @@ static const uint32_t GXS_EXTERNAL_CIRCLE_FLAGS_ALLOWED = 0x0007 ;// user
struct RsGxsCircleGroup : RsSerializable struct RsGxsCircleGroup : RsSerializable
{ {
virtual ~RsGxsCircleGroup() {}
RsGroupMetaData mMeta; RsGroupMetaData mMeta;
std::set<RsPgpId> mLocalFriends; std::set<RsPgpId> mLocalFriends;
@ -95,17 +94,17 @@ struct RsGxsCircleGroup : RsSerializable
RS_SERIAL_PROCESS(mInvitedMembers); RS_SERIAL_PROCESS(mInvitedMembers);
RS_SERIAL_PROCESS(mSubCircles); RS_SERIAL_PROCESS(mSubCircles);
} }
~RsGxsCircleGroup() override;
}; };
struct RsGxsCircleMsg : RsSerializable struct RsGxsCircleMsg : RsSerializable
{ {
virtual ~RsGxsCircleMsg() {}
RsMsgMetaData mMeta; RsMsgMetaData mMeta;
#ifndef V07_NON_BACKWARD_COMPATIBLE_CHANGE_UNNAMED #ifndef V07_NON_BACKWARD_COMPATIBLE_CHANGE_UNNAMED
/* This is horrible and should be changed into yet to be defined something /* This is horrible and should be changed into yet to be defined something
* reasonable in next non retrocompatible version */ * reasonable in next non-retrocompatible version */
std::string stuff; std::string stuff;
#endif #endif
@ -116,6 +115,8 @@ struct RsGxsCircleMsg : RsSerializable
RS_SERIAL_PROCESS(mMeta); RS_SERIAL_PROCESS(mMeta);
RS_SERIAL_PROCESS(stuff); RS_SERIAL_PROCESS(stuff);
} }
~RsGxsCircleMsg() override;
}; };
struct RsGxsCircleDetails : RsSerializable struct RsGxsCircleDetails : RsSerializable
@ -123,7 +124,7 @@ struct RsGxsCircleDetails : RsSerializable
RsGxsCircleDetails() : RsGxsCircleDetails() :
mCircleType(static_cast<uint32_t>(RsGxsCircleType::EXTERNAL)), mCircleType(static_cast<uint32_t>(RsGxsCircleType::EXTERNAL)),
mAmIAllowed(false) {} mAmIAllowed(false) {}
~RsGxsCircleDetails() override {} ~RsGxsCircleDetails() override;
RsGxsCircleId mCircleId; RsGxsCircleId mCircleId;
std::string mCircleName; std::string mCircleName;
@ -162,16 +163,29 @@ class RsGxsCircles: public RsGxsIfaceHelper
public: public:
RsGxsCircles(RsGxsIface& gxs) : RsGxsIfaceHelper(gxs) {} RsGxsCircles(RsGxsIface& gxs) : RsGxsIfaceHelper(gxs) {}
virtual ~RsGxsCircles() {} virtual ~RsGxsCircles();
/** /**
* @brief Create new circle * @brief Create new circle
* @jsonapi{development} * @jsonapi{development}
* @param[inout] cData input name and flags of the circle, storage for * @param[in] circleName String containing cirlce name
* generated circle data id etc. * @param[in] circleType Circle type
* @param[out] circleId Optional storage to output created circle id
* @param[in] restrictedId Optional id of a pre-existent circle that see the
* created circle. Meaningful only if circleType == EXTERNAL, must be null
* in all other cases.
* @param[in] authorId Optional author of the circle.
* @param[in] gxsIdMembers GXS ids of the members of the circle.
* @param[in] localMembers PGP ids of the members if the circle.
* @return false if something failed, true otherwhise * @return false if something failed, true otherwhise
*/ */
virtual bool createCircle(RsGxsCircleGroup& cData) = 0; virtual bool createCircle(
const std::string& circleName, RsGxsCircleType circleType,
RsGxsCircleId& circleId = RS_DEFAULT_STORAGE_PARAM(RsGxsCircleId),
const RsGxsCircleId& restrictedId = RsGxsCircleId(),
const RsGxsId& authorId = RsGxsId(),
const std::set<RsGxsId>& gxsIdMembers = std::set<RsGxsId>(),
const std::set<RsPgpId>& localMembers = std::set<RsPgpId>() ) = 0;
/** /**
* @brief Edit own existing circle * @brief Edit own existing circle

View File

@ -30,6 +30,7 @@
#define RS_INIT_AUTH_FAILED -1 // AuthGPG::InitAuth failed #define RS_INIT_AUTH_FAILED -1 // AuthGPG::InitAuth failed
#define RS_INIT_BASE_DIR_ERROR -2 // AuthGPG::InitAuth failed #define RS_INIT_BASE_DIR_ERROR -2 // AuthGPG::InitAuth failed
#define RS_INIT_NO_KEYRING -3 // Keyring is empty. Need to import it. #define RS_INIT_NO_KEYRING -3 // Keyring is empty. Need to import it.
#define RS_INIT_NO_EXECUTABLE -4 // executable path hasn't been set in config options
#include <stdint.h> #include <stdint.h>
#include <list> #include <list>
@ -37,7 +38,7 @@
#include <vector> #include <vector>
#include <retroshare/rstypes.h> #include <retroshare/rstypes.h>
struct RsLoginHelper; class RsLoginHelper;
/** /**
* Pointer to global instance of RsLoginHelper * Pointer to global instance of RsLoginHelper
@ -45,6 +46,38 @@ struct RsLoginHelper;
*/ */
extern RsLoginHelper* rsLoginHelper; extern RsLoginHelper* rsLoginHelper;
/**
* @brief The RsInitConfig struct
* This class contains common configuration options, that executables using libretroshare may want to
* set using e.g. commandline options. To be passed to RsInit::InitRetroShare().
*/
struct RsConfigOptions
{
RsConfigOptions();
// required
std::string main_executable_path;/* this should be set to argv[0] */
// Optional. Only change if needed.
bool autoLogin; /* try auto-login */
bool udpListenerOnly; /* only listen to udp */
std::string forcedInetAddress; /* inet address to use.*/
uint16_t forcedPort; /* port to listen to */
bool outStderr;
int debugLevel;
std::string logfname; /* output filename for log */
std::string opModeStr; /* operating mode. Acceptable values: "Full", "NoTurtle", "Gaming", "Minimal" */
std::string optBaseDir; /* base directory where to find profiles, etc */
uint16_t jsonApiPort; /* port to use fo Json API */
std::string jsonApiBindAddress; /* bind address for Json API */
};
/*! /*!
* Initialisation Class (not publicly disclosed to RsIFace) * Initialisation Class (not publicly disclosed to RsIFace)
@ -57,7 +90,7 @@ public:
OK, /// Everything go as expected, no error occurred OK, /// Everything go as expected, no error occurred
ERR_ALREADY_RUNNING, /// Another istance is running already ERR_ALREADY_RUNNING, /// Another istance is running already
ERR_CANT_ACQUIRE_LOCK, /// Another istance is already running? ERR_CANT_ACQUIRE_LOCK, /// Another istance is already running?
ERR_UNKOWN /// Unkown error, maybe password is wrong? ERR_UNKNOWN /// Unkown error, maybe password is wrong?
}; };
/* reorganised RsInit system */ /* reorganised RsInit system */
@ -77,12 +110,19 @@ public:
* invalid argument passed and vice versa * invalid argument passed and vice versa
* @return RS_INIT_... * @return RS_INIT_...
*/ */
static int InitRetroShare(int argc, char **argv, bool strictCheck=true); static int InitRetroShare(const RsConfigOptions&);
static bool isPortable(); static bool isPortable();
static bool isWindowsXP(); static bool isWindowsXP();
static bool collectEntropy(uint32_t bytes) ; static bool collectEntropy(uint32_t bytes) ;
/*!
* \brief lockFilePath
* \return
* full path for the lock file. Can be used to warn the user about a non deleted lock that would prevent to start.
*/
static std::string lockFilePath();
/* /*
* Setup Hidden Location; * Setup Hidden Location;
*/ */
@ -270,8 +310,10 @@ extern RsAccounts* rsAccounts;
* This helper class have been implemented because there was not reasonable way * This helper class have been implemented because there was not reasonable way
* to login in the API that could be exposed via JSON API * to login in the API that could be exposed via JSON API
*/ */
struct RsLoginHelper class RsLoginHelper
{ {
public:
RsLoginHelper() {}
/** /**
* @brief Normal way to attempt login * @brief Normal way to attempt login
* @jsonapi{development,manualwrapper} * @jsonapi{development,manualwrapper}
@ -295,7 +337,7 @@ struct RsLoginHelper
RsPeerId mLocationId; RsPeerId mLocationId;
RsPgpId mPgpId; RsPgpId mPgpId;
std::string mLocationName; std::string mLocationName;
std::string mPpgName; std::string mPgpName;
/// @see RsSerializable::serial_process /// @see RsSerializable::serial_process
void serial_process( RsGenericSerializer::SerializeJob j, void serial_process( RsGenericSerializer::SerializeJob j,

View File

@ -522,6 +522,7 @@ public:
* @return true on success * @return true on success
*/ */
virtual bool getMessage(const std::string &msgId, Rs::Msgs::MessageInfo &msg) = 0; virtual bool getMessage(const std::string &msgId, Rs::Msgs::MessageInfo &msg) = 0;
/** /**
* @brief getMessageCount * @brief getMessageCount
* @jsonapi{development} * @jsonapi{development}

View File

@ -42,6 +42,8 @@
#include "util/folderiterator.h" #include "util/folderiterator.h"
#include "util/rsstring.h" #include "util/rsstring.h"
#include "retroshare/rsinit.h" #include "retroshare/rsinit.h"
#include "retroshare/rsnotify.h"
#include "retroshare/rsiface.h"
#include "plugins/pluginmanager.h" #include "plugins/pluginmanager.h"
#include "rsserver/rsloginhandler.h" #include "rsserver/rsloginhandler.h"
@ -112,9 +114,30 @@ RsLoginHelper* rsLoginHelper = nullptr;
RsAccounts* rsAccounts = nullptr; RsAccounts* rsAccounts = nullptr;
RsConfigOptions::RsConfigOptions()
:
autoLogin(false),
udpListenerOnly(false),
forcedInetAddress("127.0.0.1"), /* inet address to use.*/
forcedPort(0),
outStderr(false),
debugLevel(5)
#ifdef RS_JSONAPI
,jsonApiPort(0) // JSonAPI server is enabled in each main()
,jsonApiBindAddress("127.0.0.1")
#endif
{
}
struct RsInitConfig struct RsInitConfig
{ {
RsInitConfig() : jsonApiPort(0), jsonApiBindAddress("127.0.0.1") {} RsInitConfig()
#ifdef RS_JSONAPI
: jsonApiPort(JsonApiServer::DEFAULT_PORT),
jsonApiBindAddress("127.0.0.1")
#endif
{}
RsFileHash main_executable_hash; RsFileHash main_executable_hash;
@ -155,6 +178,7 @@ struct RsInitConfig
bool udpListenerOnly; bool udpListenerOnly;
std::string opModeStr; std::string opModeStr;
std::string optBaseDir;
uint16_t jsonApiPort; uint16_t jsonApiPort;
std::string jsonApiBindAddress; std::string jsonApiBindAddress;
@ -243,14 +267,6 @@ void RsInit::InitRsConfig()
setOutputLevel(RsLog::Warning); setOutputLevel(RsLog::Warning);
} }
/********
* LOCALNET_TESTING - allows port restrictions
*
* #define LOCALNET_TESTING 1
*
********/
#ifdef LOCALNET_TESTING #ifdef LOCALNET_TESTING
std::string portRestrictions; std::string portRestrictions;
@ -264,165 +280,117 @@ bool doPortRestrictions = false;
#endif #endif
#endif #endif
int RsInit::InitRetroShare(int argc, char **argv, bool /* strictCheck */) /********
* LOCALNET_TESTING - allows port restrictions
*
* #define LOCALNET_TESTING 1
*
********/
int RsInit::InitRetroShare(const RsConfigOptions& conf)
{ {
#ifdef DEBUG_RSINIT rsInitConfig->autoLogin = conf.autoLogin;
for(int i=0; i<argc; i++) printf("%d: %s\n", i, argv[i]); rsInitConfig->outStderr = conf.outStderr;
#endif rsInitConfig->logfname = conf.logfname ;
rsInitConfig->inet = conf.forcedInetAddress ;
rsInitConfig->port = conf.forcedPort ;
rsInitConfig->debugLevel = conf.debugLevel;
rsInitConfig->optBaseDir = conf.optBaseDir;
rsInitConfig->jsonApiPort = conf.jsonApiPort;
rsInitConfig->jsonApiBindAddress = conf.jsonApiBindAddress;
#ifdef PTW32_STATIC_LIB #ifdef PTW32_STATIC_LIB
// for static PThreads under windows... we need to init the library... // for static PThreads under windows... we need to init the library...
pthread_win32_process_attach_np(); pthread_win32_process_attach_np();
#endif #endif
if( rsInitConfig->autoLogin) rsInitConfig->startMinimised = true ;
std::string prefUserString = ""; if( rsInitConfig->outStderr) rsInitConfig->haveLogFile = false ;
std::string opt_base_dir; if(!rsInitConfig->logfname.empty()) rsInitConfig->haveLogFile = true;
if( rsInitConfig->inet != "127.0.0.1") rsInitConfig->forceLocalAddr = true;
#ifdef __APPLE__ if( rsInitConfig->port != 0) rsInitConfig->forceExtPort = true;
// TODO: is this still needed with argstream? #ifdef LOCALNET_TESTING
/* HACK to avoid stupid OSX Finder behaviour if(!portRestrictions.empty()) doPortRestrictions = true;
* remove the commandline arguments - if we detect we are launched from Finder,
* and we have the unparsable "-psn_0_12332" option.
* this is okay, as you cannot pass commandline arguments via Finder anyway
*/
if ((argc >= 2) && (0 == strncmp(argv[1], "-psn", 4))) argc = 1;
#endif #endif
setOutputLevel((RsLog::logLvl)rsInitConfig->debugLevel);
argstream as(argc,argv); // set the debug file.
as >> option('m',"minimized" ,rsInitConfig->startMinimised ,"Start minimized." ) if (rsInitConfig->haveLogFile)
>> option('s',"stderr" ,rsInitConfig->outStderr ,"output to stderr instead of log file." ) setDebugFile(rsInitConfig->logfname.c_str());
>> option('u',"udp" ,rsInitConfig->udpListenerOnly,"Only listen to UDP." )
>> option('e',"external-port" ,rsInitConfig->forceExtPort ,"Use a forwarded external port." )
>> parameter('l',"log-file" ,rsInitConfig->logfname ,"logfile" ,"Set Log filename." ,false)
>> parameter('d',"debug-level" ,rsInitConfig->debugLevel ,"level" ,"Set debug level." ,false)
>> parameter('i',"ip-address" ,rsInitConfig->inet ,"nnn.nnn.nnn.nnn", "Force IP address to use (if cannot be detected)." ,false)
>> parameter('o',"opmode" ,rsInitConfig->opModeStr ,"opmode" ,"Set Operating mode (Full, NoTurtle, Gaming, Minimal)." ,false)
>> parameter('p',"port" ,rsInitConfig->port ,"port", "Set listenning port to use." ,false)
>> parameter('c',"base-dir" ,opt_base_dir ,"directory", "Set base directory." ,false)
>> parameter('U',"user-id" ,prefUserString ,"ID", "[ocation Id] Sets Account to Use, Useful when Autologin is enabled.",false);
#ifdef RS_JSONAPI /******************************** WINDOWS/UNIX SPECIFIC PART ******************/
as >> parameter(
"jsonApiPort", rsInitConfig->jsonApiPort, "jsonApiPort",
"Enable JSON API on the specified port", false )
>> parameter(
"jsonApiBindAddress", rsInitConfig->jsonApiBindAddress,
"jsonApiBindAddress", "JSON API Bind Address.", false);
#endif // ifdef RS_JSONAPI
#ifdef LOCALNET_TESTING
as >> parameter('R',"restrict-port" ,portRestrictions ,"port1-port2","Apply port restriction" ,false);
#endif // ifdef LOCALNET_TESTING
#ifdef RS_AUTOLOGIN
as >> option('a',"auto-login" ,rsInitConfig->autoLogin ,"AutoLogin (Windows Only) + StartMinimised");
#endif // ifdef RS_AUTOLOGIN
as >> help('h',"help","Display this Help");
as.defaultErrorHandling(true,true);
if(rsInitConfig->autoLogin) rsInitConfig->startMinimised = true ;
if(rsInitConfig->outStderr) rsInitConfig->haveLogFile = false ;
if(!rsInitConfig->logfname.empty()) rsInitConfig->haveLogFile = true;
if(rsInitConfig->inet != "127.0.0.1") rsInitConfig->forceLocalAddr = true;
#ifdef LOCALNET_TESTING
if(!portRestrictions.empty()) doPortRestrictions = true;
#endif
setOutputLevel((RsLog::logLvl)rsInitConfig->debugLevel);
// set the debug file.
if (rsInitConfig->haveLogFile)
setDebugFile(rsInitConfig->logfname.c_str());
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS #ifndef WINDOWS_SYS
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/ /********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#else #else
// Windows Networking Init. // Windows Networking Init.
WORD wVerReq = MAKEWORD(2,2); WORD wVerReq = MAKEWORD(2,2);
WSADATA wsaData; WSADATA wsaData;
if (0 != WSAStartup(wVerReq, &wsaData)) if (0 != WSAStartup(wVerReq, &wsaData))
{ {
std::cerr << "Failed to Startup Windows Networking"; std::cerr << "Failed to Startup Windows Networking";
std::cerr << std::endl; std::cerr << std::endl;
} }
else else
{ {
std::cerr << "Started Windows Networking"; std::cerr << "Started Windows Networking";
std::cerr << std::endl; std::cerr << std::endl;
} }
#endif #endif
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/ /********************************** WINDOWS/UNIX SPECIFIC PART ******************/
// SWITCH off the SIGPIPE - kills process on Linux. // SWITCH off the SIGPIPE - kills process on Linux.
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ /******************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS #ifndef WINDOWS_SYS
struct sigaction sigact; struct sigaction sigact;
sigact.sa_handler = SIG_IGN; sigact.sa_handler = SIG_IGN;
sigact.sa_flags = 0; sigact.sa_flags = 0;
sigset_t set; sigset_t set;
sigemptyset(&set); sigemptyset(&set);
//sigaddset(&set, SIGINT); // or whatever other signal //sigaddset(&set, SIGINT); // or whatever other signal
sigact.sa_mask = set; sigact.sa_mask = set;
if (0 == sigaction(SIGPIPE, &sigact, NULL)) if (0 == sigaction(SIGPIPE, &sigact, NULL))
{ {
std::cerr << "RetroShare:: Successfully installed the SIGPIPE Block" << std::endl; std::cerr << "RetroShare:: Successfully installed the SIGPIPE Block" << std::endl;
} }
else else
{ {
std::cerr << "RetroShare:: Failed to install the SIGPIPE Block" << std::endl; std::cerr << "RetroShare:: Failed to install the SIGPIPE Block" << std::endl;
} }
#endif #endif
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ /******************************** WINDOWS/UNIX SPECIFIC PART ******************/
// Hash the main executable. // Hash the main executable.
uint64_t tmp_size ; uint64_t tmp_size ;
if(!RsDirUtil::getFileHash(argv[0],rsInitConfig->main_executable_hash,tmp_size,NULL)) if(conf.main_executable_path.empty())
std::cerr << "Cannot hash executable! Plugins will not be loaded correctly." << std::endl; {
else std::cerr << "Executable path is unknown. It should normally have been set in passed RsConfigOptions structure" << std::endl;
std::cerr << "Hashed main executable: " << rsInitConfig->main_executable_hash << std::endl; return 1;
}
if(!RsDirUtil::getFileHash(conf.main_executable_path,rsInitConfig->main_executable_hash,tmp_size,NULL))
std::cerr << "Cannot hash executable! Plugins will not be loaded correctly." << std::endl;
else
std::cerr << "Hashed main executable: " << rsInitConfig->main_executable_hash << std::endl;
/* At this point we want to. /* At this point we want to.
* 1) Load up Dase Directory. * 1) Load up Dase Directory.
* 3) Get Prefered Id. * 3) Get Prefered Id.
* 2) Get List of Available Accounts. * 2) Get List of Available Accounts.
* 4) Get List of GPG Accounts. * 4) Get List of GPG Accounts.
*/ */
/* Initialize AuthSSL */ /* Initialize AuthSSL */
AuthSSL::instance().InitAuth(nullptr, nullptr, nullptr, ""); AuthSSL::instance().InitAuth(nullptr, nullptr, nullptr, "");
rsLoginHelper = new RsLoginHelper; rsLoginHelper = new RsLoginHelper;
int error_code ; int error_code ;
if(!RsAccounts::init(opt_base_dir,error_code)) if(!RsAccounts::init(rsInitConfig->optBaseDir,error_code))
return error_code ; return error_code ;
// choose alternative account.
if(prefUserString != "")
{
RsPeerId ssl_id(prefUserString);
if(ssl_id.isNull())
{
std::cerr << "Invalid User location id: not found in list";
std::cerr << std::endl;
return RS_INIT_AUTH_FAILED ;
}
if(RsAccounts::SelectAccount(ssl_id))
{
std::cerr << "Auto-selectng account ID " << ssl_id << std::endl;
return RS_INIT_HAVE_ACCOUNT;
}
}
#ifdef RS_AUTOLOGIN #ifdef RS_AUTOLOGIN
/* check that we have selected someone */ /* check that we have selected someone */
@ -443,9 +411,7 @@ int RsInit::InitRetroShare(int argc, char **argv, bool /* strictCheck */)
#ifdef RS_JSONAPI #ifdef RS_JSONAPI
if(rsInitConfig->jsonApiPort) if(rsInitConfig->jsonApiPort)
{ {
jsonApiServer = new JsonApiServer( jsonApiServer = new JsonApiServer( rsInitConfig->jsonApiPort, rsInitConfig->jsonApiBindAddress );
rsInitConfig->jsonApiPort,
rsInitConfig->jsonApiBindAddress );
jsonApiServer->start("JSON API Server"); jsonApiServer->start("JSON API Server");
} }
#endif // ifdef RS_JSONAPI #endif // ifdef RS_JSONAPI
@ -477,7 +443,7 @@ RsInit::LoadCertificateStatus RsInit::LockConfigDirectory(
case 0: return RsInit::OK; case 0: return RsInit::OK;
case 1: return RsInit::ERR_ALREADY_RUNNING; case 1: return RsInit::ERR_ALREADY_RUNNING;
case 2: return RsInit::ERR_CANT_ACQUIRE_LOCK; case 2: return RsInit::ERR_CANT_ACQUIRE_LOCK;
default: return RsInit::ERR_UNKOWN; default: return RsInit::ERR_UNKNOWN;
} }
} }
@ -510,27 +476,32 @@ bool RsInit::LoadPassword(const std::string& inPwd)
return true; return true;
} }
std::string RsInit::lockFilePath()
{
return RsAccounts::AccountDirectory() + "/lock" ;
}
RsInit::LoadCertificateStatus RsInit::LockAndLoadCertificates( RsInit::LoadCertificateStatus RsInit::LockAndLoadCertificates(
bool autoLoginNT, std::string& lockFilePath ) bool autoLoginNT, std::string& lockFilePath )
{ {
try try
{ {
if (!RsAccounts::lockPreferredAccount()) if (!RsAccounts::lockPreferredAccount())
throw RsInit::ERR_UNKOWN; // invalid PreferredAccount. throw RsInit::ERR_UNKNOWN; // invalid PreferredAccount.
// Logic that used to be external to RsInit... // Logic that used to be external to RsInit...
RsPeerId accountId; RsPeerId accountId;
if (!RsAccounts::GetPreferredAccountId(accountId)) if (!RsAccounts::GetPreferredAccountId(accountId))
throw RsInit::ERR_UNKOWN; // invalid PreferredAccount; throw RsInit::ERR_UNKNOWN; // invalid PreferredAccount;
RsPgpId pgpId; RsPgpId pgpId;
std::string pgpName, pgpEmail, location; std::string pgpName, pgpEmail, location;
if(!RsAccounts::GetAccountDetails(accountId, pgpId, pgpName, pgpEmail, location)) if(!RsAccounts::GetAccountDetails(accountId, pgpId, pgpName, pgpEmail, location))
throw RsInit::ERR_UNKOWN; // invalid PreferredAccount; throw RsInit::ERR_UNKNOWN; // invalid PreferredAccount;
if(0 == AuthGPG::getAuthGPG() -> GPGInit(pgpId)) if(0 == AuthGPG::getAuthGPG() -> GPGInit(pgpId))
throw RsInit::ERR_UNKOWN; // PGP Error. throw RsInit::ERR_UNKNOWN; // PGP Error.
LoadCertificateStatus retVal = LoadCertificateStatus retVal =
LockConfigDirectory(RsAccounts::AccountDirectory(), lockFilePath); LockConfigDirectory(RsAccounts::AccountDirectory(), lockFilePath);
@ -541,7 +512,7 @@ RsInit::LoadCertificateStatus RsInit::LockAndLoadCertificates(
if(LoadCertificates(autoLoginNT) != 1) if(LoadCertificates(autoLoginNT) != 1)
{ {
UnlockConfigDirectory(); UnlockConfigDirectory();
throw RsInit::ERR_UNKOWN; throw RsInit::ERR_UNKNOWN;
} }
return RsInit::OK; return RsInit::OK;
@ -1210,7 +1181,8 @@ int RsServer::StartupRetroShare()
plugins_directories.push_back(extensions_dir) ; plugins_directories.push_back(extensions_dir) ;
if(!RsDirUtil::checkCreateDirectory(extensions_dir)) if(!RsDirUtil::checkCreateDirectory(extensions_dir))
std::cerr << "(EE) Cannot create extensions directory " + extensions_dir + ". This is not mandatory, but you probably have a permission problem." << std::endl; std::cerr << "(EE) Cannot create extensions directory " << extensions_dir
<< ". This is not mandatory, but you probably have a permission problem." << std::endl;
#ifdef DEBUG_PLUGIN_SYSTEM #ifdef DEBUG_PLUGIN_SYSTEM
plugins_directories.push_back(".") ; // this list should be saved/set to some correct value. plugins_directories.push_back(".") ; // this list should be saved/set to some correct value.
@ -1909,21 +1881,24 @@ int RsServer::StartupRetroShare()
return 1; return 1;
} }
RsInit::LoadCertificateStatus RsLoginHelper::attemptLogin( RsInit::LoadCertificateStatus RsLoginHelper::attemptLogin(const RsPeerId& account, const std::string& password)
const RsPeerId& account, const std::string& password)
{ {
if(isLoggedIn()) return RsInit::ERR_ALREADY_RUNNING; if(isLoggedIn()) return RsInit::ERR_ALREADY_RUNNING;
if(!rsNotify->cachePgpPassphrase(password)) return RsInit::ERR_UNKOWN;
if(!rsNotify->setDisableAskPassword(true)) return RsInit::ERR_UNKOWN; if(!password.empty())
if(!RsAccounts::SelectAccount(account)) return RsInit::ERR_UNKOWN; {
if(!rsNotify->cachePgpPassphrase(password)) return RsInit::ERR_UNKNOWN;
if(!rsNotify->setDisableAskPassword(true)) return RsInit::ERR_UNKNOWN;
}
if(!RsAccounts::SelectAccount(account)) return RsInit::ERR_UNKNOWN;
std::string _ignore_lockFilePath; std::string _ignore_lockFilePath;
RsInit::LoadCertificateStatus ret = RsInit::LoadCertificateStatus ret = RsInit::LockAndLoadCertificates(false, _ignore_lockFilePath);
RsInit::LockAndLoadCertificates(false, _ignore_lockFilePath);
if(!rsNotify->setDisableAskPassword(false)) return RsInit::ERR_UNKOWN; if(!rsNotify->setDisableAskPassword(false)) return RsInit::ERR_UNKNOWN;
if(!rsNotify->clearPgpPassphrase()) return RsInit::ERR_UNKOWN; if(!rsNotify->clearPgpPassphrase()) return RsInit::ERR_UNKNOWN;
if(ret != RsInit::OK) return ret; if(ret != RsInit::OK) return ret;
if(RsControl::instance()->StartupRetroShare() == 1) return RsInit::OK; if(RsControl::instance()->StartupRetroShare() == 1) return RsInit::OK;
return RsInit::ERR_UNKOWN; return RsInit::ERR_UNKNOWN;
} }
/*static*/ bool RsLoginHelper::collectEntropy(uint32_t bytes) /*static*/ bool RsLoginHelper::collectEntropy(uint32_t bytes)
@ -1939,7 +1914,7 @@ void RsLoginHelper::getLocations(std::vector<RsLoginHelper::Location>& store)
{ {
Location l; l.mLocationId = locId; Location l; l.mLocationId = locId;
std::string discardPgpMail; std::string discardPgpMail;
RsAccounts::GetAccountDetails( locId, l.mPgpId, l.mPpgName, RsAccounts::GetAccountDetails( locId, l.mPgpId, l.mPgpName,
discardPgpMail, l.mLocationName ); discardPgpMail, l.mLocationName );
store.push_back(l); store.push_back(l);
} }
@ -1957,14 +1932,14 @@ bool RsLoginHelper::createLocation(
return false; return false;
} }
if(l.mPgpId.isNull() && l.mPpgName.empty()) if(l.mPgpId.isNull() && l.mPgpName.empty())
{ {
errorMessage = "Either PGP name or PGP id is needed"; errorMessage = "Either PGP name or PGP id is needed";
return false; return false;
} }
if(l.mPgpId.isNull() && !RsAccounts::GeneratePGPCertificate( if(l.mPgpId.isNull() && !RsAccounts::GeneratePGPCertificate(
l.mPpgName, "", password, l.mPgpId, 4096, errorMessage) ) l.mPgpName, "", password, l.mPgpId, 4096, errorMessage) )
{ {
errorMessage = "Failure creating PGP key: " + errorMessage; errorMessage = "Failure creating PGP key: " + errorMessage;
return false; return false;
@ -1999,7 +1974,7 @@ void RsLoginHelper::Location::serial_process(
RS_SERIAL_PROCESS(mLocationId); RS_SERIAL_PROCESS(mLocationId);
RS_SERIAL_PROCESS(mPgpId); RS_SERIAL_PROCESS(mPgpId);
RS_SERIAL_PROCESS(mLocationName); RS_SERIAL_PROCESS(mLocationName);
RS_SERIAL_PROCESS(mPpgName); RS_SERIAL_PROCESS(mPgpName);
} }
/*static*/ bool RsAccounts::getCurrentAccountId(RsPeerId& id) /*static*/ bool RsAccounts::getCurrentAccountId(RsPeerId& id)

View File

@ -732,11 +732,13 @@ bool RsTypeSerializer::to_JSON(
rapidjson::Document::AllocatorType& allocator = jDoc.GetAllocator(); rapidjson::Document::AllocatorType& allocator = jDoc.GetAllocator();
rapidjson::Value key; rapidjson::Value key;
key.SetString(memberName.c_str(), memberName.length(), allocator); key.SetString( memberName.c_str(),
static_cast<rapidjson::SizeType>(memberName.length()),
allocator );
std::string encodedValue; std::string encodedValue;
Radix64::encode( reinterpret_cast<uint8_t*>(member.first), Radix64::encode( reinterpret_cast<uint8_t*>(member.first),
member.second, encodedValue ); static_cast<int>(member.second), encodedValue );
rapidjson::Value value; rapidjson::Value value;
value.SetString(encodedValue.data(), allocator); value.SetString(encodedValue.data(), allocator);

View File

@ -3,7 +3,8 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2012-2012 Robert Fernie <retroshare@lunamutt.com> * * Copyright (C) 2012-2014 Robert Fernie <retroshare@lunamutt.com> *
* Copyright (C) 2018-2019 Gioacchino Mazzurco <gio@eigenlab.org> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -27,7 +28,7 @@
#include "util/rsdir.h" #include "util/rsdir.h"
#include "util/radix64.h" #include "util/radix64.h"
#include "util/rsstring.h" #include "util/rsstring.h"
#include "util/rsdebug.h"
#include "pgp/pgpauxutils.h" #include "pgp/pgpauxutils.h"
#include "retroshare/rsgxscircles.h" #include "retroshare/rsgxscircles.h"
#include "retroshare/rspeers.h" #include "retroshare/rspeers.h"
@ -153,8 +154,76 @@ RsServiceInfo p3GxsCircles::getServiceInfo()
GXS_CIRCLES_MIN_MINOR_VERSION); GXS_CIRCLES_MIN_MINOR_VERSION);
} }
bool p3GxsCircles::createCircle(RsGxsCircleGroup& cData) bool p3GxsCircles::createCircle(
const std::string& circleName, RsGxsCircleType circleType,
RsGxsCircleId& circleId, const RsGxsCircleId& restrictedId,
const RsGxsId& authorId, const std::set<RsGxsId>& gxsIdMembers,
const std::set<RsPgpId>& localMembers )
{ {
if(circleName.empty())
{
RsErr() << __PRETTY_FUNCTION__ << " Circle name is empty" << std::endl;
return false;
}
switch(circleType)
{
case RsGxsCircleType::PUBLIC:
if(!restrictedId.isNull())
{
RsErr() << __PRETTY_FUNCTION__ << " restrictedId: " << restrictedId
<< " must be null with RsGxsCircleType::PUBLIC"
<< std::endl;
return false;
}
break;
case RsGxsCircleType::EXTERNAL:
if(restrictedId.isNull())
{
RsErr() << __PRETTY_FUNCTION__ << " restrictedId can't be null "
<< "with RsGxsCircleType::EXTERNAL" << std::endl;
return false;
}
break;
case RsGxsCircleType::NODES_GROUP:
if(localMembers.empty())
{
RsErr() << __PRETTY_FUNCTION__ << " localMembers can't be empty "
<< "with RsGxsCircleType::NODES_GROUP" << std::endl;
return false;
}
break;
case RsGxsCircleType::LOCAL:
break;
case RsGxsCircleType::EXT_SELF:
if(!restrictedId.isNull())
{
RsErr() << __PRETTY_FUNCTION__ << " restrictedId: " << restrictedId
<< " must be null with RsGxsCircleType::EXT_SELF"
<< std::endl;
return false;
}
if(gxsIdMembers.empty())
{
RsErr() << __PRETTY_FUNCTION__ << " gxsIdMembers can't be empty "
<< "with RsGxsCircleType::EXT_SELF" << std::endl;
return false;
}
break;
case RsGxsCircleType::YOUR_EYES_ONLY:
break;
default:
RsErr() << __PRETTY_FUNCTION__ << " Invalid circle type: "
<< static_cast<uint32_t>(circleType) << std::endl;
return false;
}
RsGxsCircleGroup cData;
cData.mMeta.mGroupName = circleName;
cData.mMeta.mAuthorId = authorId;
cData.mMeta.mCircleType = static_cast<uint32_t>(circleType);
cData.mMeta.mGroupFlags = GXS_SERV::FLAG_PRIVACY_PUBLIC;
uint32_t token; uint32_t token;
createGroup(token, cData); createGroup(token, cData);
@ -172,8 +241,9 @@ bool p3GxsCircles::createCircle(RsGxsCircleGroup& cData)
return false; return false;
} }
circleId = static_cast<RsGxsCircleId>(cData.mMeta.mGroupId);
return true; return true;
} };
bool p3GxsCircles::editCircle(RsGxsCircleGroup& cData) bool p3GxsCircles::editCircle(RsGxsCircleGroup& cData)
{ {
@ -2157,3 +2227,8 @@ bool p3GxsCircles::processMembershipRequests(uint32_t token)
return true ; return true ;
} }
RsGxsCircles::~RsGxsCircles() = default;
RsGxsCircleMsg::~RsGxsCircleMsg() = default;
RsGxsCircleDetails::~RsGxsCircleDetails() = default;
RsGxsCircleGroup::~RsGxsCircleGroup() = default;

View File

@ -3,7 +3,8 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2012-2012 Robert Fernie <retroshare@lunamutt.com> * * Copyright (C) 2012-2014 Robert Fernie <retroshare@lunamutt.com> *
* Copyright (C) 2018-2019 Gioacchino Mazzurco <gio@eigenlab.org> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -19,8 +20,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * * along with this program. If not, see <https://www.gnu.org/licenses/>. *
* * * *
*******************************************************************************/ *******************************************************************************/
#ifndef P3_CIRCLES_SERVICE_HEADER #pragma once
#define P3_CIRCLES_SERVICE_HEADER
#include "retroshare/rsgxscircles.h" // External Interfaces. #include "retroshare/rsgxscircles.h" // External Interfaces.
@ -180,7 +180,14 @@ virtual RsServiceInfo getServiceInfo();
/*********** External Interface ***************/ /*********** External Interface ***************/
/// @see RsGxsCircles /// @see RsGxsCircles
bool createCircle(RsGxsCircleGroup& cData) override; bool createCircle(
const std::string& circleName, RsGxsCircleType circleType,
RsGxsCircleId& circleId = RS_DEFAULT_STORAGE_PARAM(RsGxsCircleId),
const RsGxsCircleId& restrictedId = RsGxsCircleId(),
const RsGxsId& authorId = RsGxsId(),
const std::set<RsGxsId>& gxsIdMembers = std::set<RsGxsId>(),
const std::set<RsPgpId>& localMembers = std::set<RsPgpId>()
) override;
/// @see RsGxsCircles /// @see RsGxsCircles
bool editCircle(RsGxsCircleGroup& cData) override; bool editCircle(RsGxsCircleGroup& cData) override;
@ -315,5 +322,3 @@ virtual RsServiceInfo getServiceInfo();
std::list<RsGxsId> mDummyPgpLinkedIds; std::list<RsGxsId> mDummyPgpLinkedIds;
std::list<RsGxsId> mDummyOwnIds; std::list<RsGxsId> mDummyOwnIds;
}; };
#endif // P3_CIRCLES_SERVICE_HEADER

View File

@ -968,6 +968,11 @@ bool p3IdService::createIdentity(
id = RsGxsId(meta.mGroupId); id = RsGxsId(meta.mGroupId);
{
RS_STACK_MUTEX(mIdMtx);
mOwnIds.push_back(id);
if(!pseudonimous) mOwnSignedIds.push_back(id);
}
LabelCreateIdentityCleanup: LabelCreateIdentityCleanup:
if(!pseudonimous && !pgpPassword.empty()) if(!pseudonimous && !pgpPassword.empty())
@ -3036,7 +3041,7 @@ bool p3IdService::cache_request_ownids()
RsGenExchange::getTokenService()->requestGroupInfo(token, ansType, opts); RsGenExchange::getTokenService()->requestGroupInfo(token, ansType, opts);
GxsTokenQueue::queueRequest(token, GXSIDREQ_CACHEOWNIDS); GxsTokenQueue::queueRequest(token, GXSIDREQ_CACHEOWNIDS);
return 1; return true;
} }

View File

@ -0,0 +1,130 @@
/*******************************************************************************
* libretroshare/src/retroshare/util/rskbdinput.cc *
* *
* Copyright (C) 2019 Cyril Soler <csoler@users.sourceforge.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 *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program 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 Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
#ifndef __ANDROID__
#include <iostream>
#include <util/rskbdinput.h>
#ifdef WINDOWS_SYS
#include <conio.h>
#include <stdio.h>
#define PASS_MAX 512
namespace RsUtil {
std::string rs_getpass(const std::string& prompt,bool no_echo)
{
static char getpassbuf [PASS_MAX + 1];
size_t i = 0;
int c;
if (!prompt.empty()) {
std::cerr << prompt ;
std::cerr.flush();
}
for (;;) {
c = _getch ();
if (c == '\r') {
getpassbuf [i] = '\0';
break;
}
else if (i < PASS_MAX) {
getpassbuf[i++] = c;
}
if (i >= PASS_MAX) {
getpassbuf [i] = '\0';
break;
}
}
if (!prompt.empty()) {
std::cerr << "\r\n" ;
std::cerr.flush();
}
return std::string(getpassbuf);
}
}
#else
#include <stdio.h>
#include <string>
#include <iostream>
#include <termios.h>
#include <unistd.h>
static int getch()
{
int ch;
struct termios t_old, t_new;
tcgetattr(STDIN_FILENO, &t_old);
t_new = t_old;
t_new.c_lflag &= ~(ICANON | ECHO);
tcsetattr(STDIN_FILENO, TCSANOW, &t_new);
ch = getchar();
tcsetattr(STDIN_FILENO, TCSANOW, &t_old);
return ch;
}
namespace RsUtil {
std::string rs_getpass(const std::string& prompt, bool no_echo)
{
const char BACKSPACE=127;
const char RETURN=10;
std::string password;
unsigned char ch=0;
std::cout <<prompt; std::cout.flush();
while((ch=getch())!=RETURN)
{
if(ch==BACKSPACE)
{
if(password.length()!=0)
{
if(no_echo)
std::cout <<"\b \b";
password.resize(password.length()-1);
}
}
else
{
password+=ch;
if(no_echo)
std::cout <<'*';
else
std::cout << ch,std::cout.flush();
}
}
std::cout <<std::endl;
return std::string(password);
}
}
#endif
#endif

View File

@ -0,0 +1,27 @@
/*******************************************************************************
* libretroshare/src/retroshare/util/rskbdinput.h *
* *
* Copyright (C) 2019 Cyril Soler <csoler@users.sourceforge.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 *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program 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 Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
#include <string>
namespace RsUtil {
std::string rs_getpass(const std::string& prompt,bool no_echo=true) ;
}

View File

@ -128,10 +128,25 @@ public:
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override
{ {
if(!m_showOfflineNodes && !sourceModel()->index(source_row,0,source_parent).data(RsFriendListModel::OnlineRole).toBool()) // do not show empty groups
QModelIndex index = sourceModel()->index(source_row,0,source_parent);
if(index.data(RsFriendListModel::TypeRole) == RsFriendListModel::ENTRY_TYPE_GROUP)
{
RsGroupInfo group_info ;
static_cast<RsFriendListModel*>(sourceModel())->getGroupData(index,group_info);
if(group_info.peerIds.empty())
return false;
}
// Filter offline friends
if(!m_showOfflineNodes && !index.data(RsFriendListModel::OnlineRole).toBool())
return false; return false;
return sourceModel()->index(source_row,0,source_parent).data(RsFriendListModel::FilterRole).toString() == RsFriendListModel::FilterString ; return index.data(RsFriendListModel::FilterRole).toString() == RsFriendListModel::FilterString ;
} }
void sort( int column, Qt::SortOrder order = Qt::AscendingOrder ) override void sort( int column, Qt::SortOrder order = Qt::AscendingOrder ) override
@ -683,7 +698,7 @@ void NewFriendList::peerTreeWidgetCustomPopupMenu()
contextMenu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy certificate link"), this, SLOT(copyFullCertificate())); contextMenu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy certificate link"), this, SLOT(copyFullCertificate()));
//this is a SSL key //this is a SSL key
contextMenu.addAction(QIcon(IMAGE_REMOVEFRIEND), tr("Remove Friend Node"), this, SLOT(removefriend())); contextMenu.addAction(QIcon(IMAGE_REMOVEFRIEND), tr("Remove Friend Node"), this, SLOT(removeNode()));
} }
} }

View File

@ -231,6 +231,8 @@ MessagesDialog::MessagesDialog(QWidget *parent)
// fill quick view // fill quick view
fillQuickView(); fillQuickView();
sortColumn(RsMessageModel::COLUMN_THREAD_DATE,Qt::DescendingOrder);
// load settings // load settings
processSettings(true); processSettings(true);

View File

@ -80,6 +80,7 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
ui.setupUi(this); ui.setupUi(this);
manager = NULL ; manager = NULL ;
mOngoingConnectivityCheck = -1;
if(RsAccounts::isHiddenNode()) if(RsAccounts::isHiddenNode())
{ {

View File

@ -21,6 +21,7 @@
*******************************************************************************/ *******************************************************************************/
#include "util/stacktrace.h" #include "util/stacktrace.h"
#include "util/argstream.h"
CrashStackTrace gCrashStackTrace; CrashStackTrace gCrashStackTrace;
@ -50,6 +51,7 @@ CrashStackTrace gCrashStackTrace;
#include "util/RsGxsUpdateBroadcast.h" #include "util/RsGxsUpdateBroadcast.h"
#include "util/rsdir.h" #include "util/rsdir.h"
#include "util/rstime.h" #include "util/rstime.h"
#include "retroshare/rsinit.h"
#ifdef MESSENGER_WINDOW #ifdef MESSENGER_WINDOW
#include "gui/MessengerWindow.h" #include "gui/MessengerWindow.h"
@ -228,7 +230,36 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
/* RetroShare Core Objects */ /* RetroShare Core Objects */
RsInit::InitRsConfig(); RsInit::InitRsConfig();
int initResult = RsInit::InitRetroShare(argc, argv);
RsConfigOptions conf;
conf.jsonApiPort = 0 ; // disable JSon API at start. The JSonAPI preference UI will enable it according to saved parameters.
argstream as(argc,argv);
as >> option('s',"stderr" ,conf.outStderr ,"output to stderr instead of log file." )
>> option('u',"udp" ,conf.udpListenerOnly,"Only listen to UDP." )
>> parameter('c',"base-dir" ,conf.optBaseDir ,"directory", "Set base directory." ,false)
>> parameter('l',"log-file" ,conf.logfname ,"logfile" ,"Set Log filename." ,false)
>> parameter('d',"debug-level" ,conf.debugLevel ,"level" ,"Set debug level." ,false)
>> parameter('i',"ip-address" ,conf.forcedInetAddress,"nnn.nnn.nnn.nnn", "Force IP address to use (if cannot be detected)." ,false)
>> parameter('p',"port" ,conf.forcedPort ,"port" ,"Set listenning port to use." ,false)
>> parameter('o',"opmode" ,conf.opModeStr ,"opmode" ,"Set Operating mode (Full, NoTurtle, Gaming, Minimal)." ,false);
#ifdef RS_JSONAPI
as >> parameter('J', "jsonApiPort", conf.jsonApiPort, "jsonApiPort", "Enable JSON API on the specified port", false )
>> parameter('P', "jsonApiBindAddress", conf.jsonApiBindAddress, "jsonApiBindAddress", "JSON API Bind Address.", false);
#endif // ifdef RS_JSONAPI
#ifdef LOCALNET_TESTING
as >> parameter('R',"restrict-port" ,portRestrictions ,"port1-port2","Apply port restriction" ,false);
#endif // ifdef LOCALNET_TESTING
#ifdef RS_AUTOLOGIN
as >> option('a',"auto-login" ,conf.autoLogin ,"AutoLogin (Windows Only) + StartMinimised");
#endif // ifdef RS_AUTOLOGIN
conf.main_executable_path = argv[0];
int initResult = RsInit::InitRetroShare(conf);
if(initResult == RS_INIT_NO_KEYRING) // happens when we already have accounts, but no pgp key. This is when switching to the openpgp-sdk version. if(initResult == RS_INIT_NO_KEYRING) // happens when we already have accounts, but no pgp key. This is when switching to the openpgp-sdk version.
{ {
@ -252,7 +283,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
if(!RsAccounts::CopyGnuPGKeyrings()) if(!RsAccounts::CopyGnuPGKeyrings())
return 0 ; return 0 ;
initResult = RsInit::InitRetroShare(argc, argv); initResult = RsInit::InitRetroShare(conf);
displayWarningAboutDSAKeys() ; displayWarningAboutDSAKeys() ;

View File

@ -57,8 +57,10 @@
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
#ifdef ENABLE_WEBUI RsConfigOptions conf;
conf.main_executable_path = argv[0];
#ifdef ENABLE_WEBUI
std::string docroot = resource_api::getDefaultDocroot(); std::string docroot = resource_api::getDefaultDocroot();
uint16_t httpPort = 0; uint16_t httpPort = 0;
std::string listenAddress; std::string listenAddress;
@ -77,8 +79,9 @@ int main(int argc, char **argv)
std::cerr << args.usage() << std::endl; std::cerr << args.usage() << std::endl;
// print libretroshare command line args and exit // print libretroshare command line args and exit
RsInit::InitRsConfig(); RsInit::InitRsConfig();
RsInit::InitRetroShare(argc, argv, true);
return 0; RsInit::InitRetroShare(conf);
return 0;
} }
resource_api::ApiServer api; resource_api::ApiServer api;
@ -126,7 +129,7 @@ int main(int argc, char **argv)
bool strictCheck = true; bool strictCheck = true;
RsInit::InitRsConfig(); RsInit::InitRsConfig();
int initResult = RsInit::InitRetroShare(argc, argv, strictCheck); int initResult = RsInit::InitRetroShare(conf);
if (initResult < 0) { if (initResult < 0) {
/* Error occured */ /* Error occured */

View File

@ -1,6 +1,6 @@
/* /*
* RetroShare Service * RetroShare Service
* Copyright (C) 2016-2018 Gioacchino Mazzurco <gio@eigenlab.org> * Copyright (C) 2016-2019 Gioacchino Mazzurco <gio@eigenlab.org>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@ -17,61 +17,301 @@
*/ */
#include "util/stacktrace.h" #include "util/stacktrace.h"
#include "util/argstream.h"
#include "util/rskbdinput.h"
#include "retroshare/rsinit.h"
CrashStackTrace gCrashStackTrace; #ifdef RS_JSONAPI
#include "jsonapi/jsonapi.h"
#endif
#include <QCoreApplication> static CrashStackTrace gCrashStackTrace;
#include <cmath>
#include <csignal> #include <csignal>
#include <QObject> #include <iomanip>
#include <QStringList> #include <atomic>
#ifdef __ANDROID__ #ifdef __ANDROID__
# include <QAndroidService> # include <QAndroidService>
# include <QCoreApplication>
# include <QObject>
# include <QStringList>
# include "util/androiddebug.h"
#endif // def __ANDROID__ #endif // def __ANDROID__
#include "retroshare/rsinit.h" #include "retroshare/rsinit.h"
#include "retroshare/rsiface.h" #include "retroshare/rsiface.h"
#include "util/rsdebug.h"
#ifdef RS_SERVICE_TERMINAL_LOGIN
class RsServiceNotify: public NotifyClient
{
public:
RsServiceNotify() = default;
virtual ~RsServiceNotify() = default;
virtual bool askForPassword(
const std::string& title, const std::string& question,
bool /*prev_is_bad*/, std::string& password, bool& cancel )
{
std::string question1 = title +
"\nPlease enter your PGP password for key:\n " +
question + " :";
password = RsUtil::rs_getpass(question1.c_str()) ;
cancel = false ;
return !password.empty();
}
};
#endif // def RS_SERVICE_TERMINAL_LOGIN
#ifdef __ANDROID__ #ifdef __ANDROID__
# include "util/androiddebug.h" void signalHandler(int /*signal*/) { QCoreApplication::exit(0); }
#endif #else
static std::atomic<bool> keepRunning(true);
static int receivedSignal = 0;
void signalHandler(int signal)
{
if(RsControl::instance()->isReady())
RsControl::instance()->rsGlobalShutDown();
receivedSignal = signal;
keepRunning = false;
}
#endif // def __ANDROID__
#ifndef RS_JSONAPI
# error Inconsistent build configuration retroshare_service needs rs_jsonapi
#endif
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#ifdef __ANDROID__ #ifdef __ANDROID__
AndroidStdIOCatcher dbg; (void) dbg; AndroidStdIOCatcher dbg; (void) dbg;
QAndroidService app(argc, argv); QAndroidService app(argc, argv);
#else // def __ANDROID__
QCoreApplication app(argc, argv);
#endif // def __ANDROID__ #endif // def __ANDROID__
signal(SIGINT, QCoreApplication::exit); signal(SIGINT, signalHandler);
signal(SIGTERM, QCoreApplication::exit); signal(SIGTERM, signalHandler);
#ifdef SIGBREAK #ifdef SIGBREAK
signal(SIGBREAK, QCoreApplication::exit); signal(SIGBREAK, signalHandler);
#endif // ifdef SIGBREAK #endif // ifdef SIGBREAK
RsInfo() << "\n" <<
"+================================================================+\n"
"| o---o o |\n"
"| \\ / - Retroshare Service - / \\ |\n"
"| o o---o |\n"
"+================================================================+"
<< std::endl << std::endl;
RsInit::InitRsConfig(); RsInit::InitRsConfig();
// clumsy way to enable JSON API by default
if(!QCoreApplication::arguments().contains("--jsonApiPort"))
{
int argc2 = argc + 2;
char* argv2[argc2]; for (int i = 0; i < argc; ++i ) argv2[i] = argv[i];
char opt[] = "--jsonApiPort";
char val[] = "9092";
argv2[argc] = opt;
argv2[argc+1] = val;
RsInit::InitRetroShare(argc2, argv2, true);
}
else RsInit::InitRetroShare(argc, argv, true);
RsControl::earlyInitNotificationSystem(); RsControl::earlyInitNotificationSystem();
#ifdef __APPLE__
// TODO: is this still needed with argstream?
/* HACK to avoid stupid OSX Finder behaviour
* remove the commandline arguments - if we detect we are launched from
* Finder, and we have the unparsable "-psn_0_12332" option.
* this is okay, as you cannot pass commandline arguments via Finder anyway
*/
if ((argc >= 2) && (0 == strncmp(argv[1], "-psn", 4))) argc = 1;
#endif
std::string prefUserString;
RsConfigOptions conf;
#ifdef RS_JSONAPI
conf.jsonApiPort = JsonApiServer::DEFAULT_PORT; // enable JSonAPI by default
#endif
argstream as(argc,argv);
as >> option( 's', "stderr", conf.outStderr,
"output to stderr instead of log file." )
>> option( 'u',"udp", conf.udpListenerOnly,
"Only listen to UDP." )
>> parameter( 'c',"base-dir", conf.optBaseDir, "directory",
"Set base directory.", false )
>> parameter( 'l', "log-file", conf.logfname, "logfile",
"Set Log filename.", false )
>> parameter( 'd', "debug-level", conf.debugLevel, "level",
"Set debug level.", false )
>> parameter( 'i', "ip-address", conf.forcedInetAddress, "IP",
"Force IP address to use (if cannot be detected).", false )
>> parameter( 'o', "opmode", conf.opModeStr, "opmode",
"Set Operating mode (Full, NoTurtle, Gaming, Minimal).",
false )
>> parameter( 'p', "port", conf.forcedPort, "port",
"Set listenning port to use.", false );
#ifdef RS_SERVICE_TERMINAL_LOGIN
as >> parameter( 'U', "user-id", prefUserString, "ID",
"[node Id] Selected account to use and asks for passphrase"
". Use \"-U list\" in order to list available accounts.",
false );
#endif // RS_SERVICE_TERMINAL_LOGIN
#ifdef RS_JSONAPI
as >> parameter( 'J', "jsonApiPort", conf.jsonApiPort, "TCP Port",
"Enable JSON API on the specified port", false )
>> parameter( 'P', "jsonApiBindAddress", conf.jsonApiBindAddress,
"TCP bind address", "JSON API Bind Address default "
"127.0.0.1.", false );
#endif // def RS_JSONAPI
#if defined(RS_JSONAPI) && defined(RS_WEBUI) \
&& defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD)
bool askWebUiPassword = false;
as >> option( 'W', "webui-password", askWebUiPassword,
"Ask WebUI password on the console." );
#endif /* defined(RS_JSONAPI) && defined(RS_WEBUI) \
&& defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD) */
#ifdef LOCALNET_TESTING
as >> parameter( 'R', "restrict-port" , portRestrictions, "port1-port2",
"Apply port restriction", false);
#endif // ifdef LOCALNET_TESTING
#ifdef RS_AUTOLOGIN
as >> option( 'a', "auto-login", conf.autoLogin,
"enable auto-login." );
#endif // ifdef RS_AUTOLOGIN
as >> help( 'h', "help", "Display this Help" );
as.defaultErrorHandling(true, true);
#if defined(RS_JSONAPI) && defined(RS_WEBUI) \
&& defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD)
std::string webui_pass1 = "Y";
if(askWebUiPassword)
{
std::string webui_pass2 = "N";
while(keepRunning)
{
webui_pass1 = RsUtil::rs_getpass(
"Please register a password for the web interface: " );
webui_pass2 = RsUtil::rs_getpass(
"Please enter the same password again : " );
if(webui_pass1 != webui_pass2)
{
std::cout << "Passwords do not match!" << std::endl;
continue;
}
if(webui_pass1.empty())
{
std::cout << "Password cannot be empty!" << std::endl;
continue;
}
break;
}
}
#endif /* defined(RS_JSONAPI) && defined(RS_WEBUI)
&& defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD) */
conf.main_executable_path = argv[0];
int initResult = RsInit::InitRetroShare(conf);
if(initResult != RS_INIT_OK)
{
RsErr() << "Retroshare core initalization failed with: " << initResult
<< std::endl;
return -initResult;
}
#ifdef RS_SERVICE_TERMINAL_LOGIN
if(!prefUserString.empty()) // Login from terminal requested
{
if(prefUserString == "list")
{
std::cout << std::endl << std::endl
<< "Available accounts:" << std::endl;
std::vector<RsLoginHelper::Location> locations;
rsLoginHelper->getLocations(locations);
int accountCountDigits = static_cast<int>(
ceil(log(locations.size())/log(10.0)) );
for( uint32_t i=0; i<locations.size(); ++i )
std::cout << "[" << std::setw(accountCountDigits)
<< std::setfill('0') << i+1 << "] "
<< locations[i].mLocationId << " ("
<< locations[i].mPgpId << "): "
<< locations[i].mPgpName
<< " \t (" << locations[i].mLocationName << ")"
<< std::endl;
uint32_t nacc = 0;
while(keepRunning && (nacc < 1 || nacc >= locations.size()))
{
std::cout << "Please enter account number: ";
std::cout.flush();
std::string inputStr;
std::getline(std::cin, inputStr);
nacc = static_cast<uint32_t>(atoi(inputStr.c_str())-1);
if(nacc < locations.size())
{
prefUserString = locations[nacc].mLocationId.toStdString();
break;
}
nacc=0; // allow to continue if something goes wrong.
}
}
RsPeerId ssl_id(prefUserString);
if(ssl_id.isNull())
{
RsErr() << "Invalid User location id: a hexadecimal ID is expected."
<< std::endl;
return -EINVAL;
}
RsServiceNotify* notify = new RsServiceNotify();
rsNotify->registerNotifyClient(notify);
// supply empty passwd so that it is properly asked 3 times on console
RsInit::LoadCertificateStatus result =
rsLoginHelper->attemptLogin(ssl_id, "");
switch(result)
{
case RsInit::OK: break;
case RsInit::ERR_ALREADY_RUNNING:
RsErr() << "Another RetroShare using the same profile is already "
"running on your system. Please close that instance "
"first." << std::endl << "Lock file: "
<< RsInit::lockFilePath() << std::endl;
return -RsInit::ERR_ALREADY_RUNNING;
case RsInit::ERR_CANT_ACQUIRE_LOCK:
RsErr() << "An unexpected error occurred when Retroshare tried to "
"acquire the single instance lock file." << std::endl
<< "Lock file: " << RsInit::lockFilePath() << std::endl;
return -RsInit::ERR_CANT_ACQUIRE_LOCK;
case RsInit::ERR_UNKNOWN: // Fall-throug
default:
RsErr() << "Cannot login. Check your passphrase." << std::endl
<< std::endl;
return -result;
}
}
#endif // def RS_SERVICE_TERMINAL_LOGIN
#if defined(RS_JSONAPI) && defined(RS_WEBUI) \
&& defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD)
if(jsonApiServer && !webui_pass1.empty())
jsonApiServer->authorizeToken("webui:"+webui_pass1);
#endif /* defined(RS_JSONAPI) && defined(RS_WEBUI) \
&& defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD) */
#ifdef __ANDROID__
rsControl->setShutdownCallback(QCoreApplication::exit); rsControl->setShutdownCallback(QCoreApplication::exit);
QObject::connect( QObject::connect(
&app, &QCoreApplication::aboutToQuit, &app, &QCoreApplication::aboutToQuit,
[](){ [](){
@ -79,4 +319,12 @@ int main(int argc, char* argv[])
RsControl::instance()->rsGlobalShutDown(); } ); RsControl::instance()->rsGlobalShutDown(); } );
return app.exec(); return app.exec();
#else // def __ANDROID__
rsControl->setShutdownCallback([&](int){keepRunning = false;});
while(keepRunning)
std::this_thread::sleep_for(std::chrono::milliseconds(500));
return 0;
#endif
} }

View File

@ -40,3 +40,75 @@ unix {
target.path = "$${RS_BIN_DIR}" target.path = "$${RS_BIN_DIR}"
INSTALLS += target INSTALLS += target
} }
macx {
# ENABLE THIS OPTION FOR Univeral Binary BUILD.
#CONFIG += ppc x86
#QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4
LIBS += -lz
#LIBS += -lssl -lcrypto -lz -lgpgme -lgpg-error -lassuan
for(lib, LIB_DIR):exists($$lib/libminiupnpc.a){ LIBS += $$lib/libminiupnpc.a}
LIBS += -framework CoreFoundation
LIBS += -framework Security
LIBS += -framework Carbon
for(lib, LIB_DIR):LIBS += -L"$$lib"
for(bin, BIN_DIR):LIBS += -L"$$bin"
DEPENDPATH += . $$INC_DIR
INCLUDEPATH += . $$INC_DIR
}
win32-g++ {
CONFIG(debug, debug|release) {
# show console output
CONFIG += console
} else {
CONFIG -= console
}
# Switch on extra warnings
QMAKE_CFLAGS += -Wextra
QMAKE_CXXFLAGS += -Wextra
CONFIG(debug, debug|release) {
} else {
# Tell linker to use ASLR protection
QMAKE_LFLAGS += -Wl,-dynamicbase
# Tell linker to use DEP protection
QMAKE_LFLAGS += -Wl,-nxcompat
}
# Fix linking error (ld.exe: Error: export ordinal too large) due to too
# many exported symbols.
QMAKE_LFLAGS+=-Wl,--exclude-libs,ALL
# Switch off optimization for release version
QMAKE_CXXFLAGS_RELEASE -= -O2
QMAKE_CXXFLAGS_RELEASE += -O0
QMAKE_CFLAGS_RELEASE -= -O2
QMAKE_CFLAGS_RELEASE += -O0
# Switch on optimization for debug version
#QMAKE_CXXFLAGS_DEBUG += -O2
#QMAKE_CFLAGS_DEBUG += -O2
OBJECTS_DIR = temp/obj
dLib = ws2_32 gdi32 uuid ole32 iphlpapi crypt32 winmm
LIBS *= $$linkDynamicLibs(dLib)
# export symbols for the plugins
LIBS += -Wl,--export-all-symbols,--out-implib,lib/libretroshare-service.a
# create lib directory
isEmpty(QMAKE_SH) {
QMAKE_PRE_LINK = $(CHK_DIR_EXISTS) lib $(MKDIR) lib
} else {
QMAKE_PRE_LINK = $(CHK_DIR_EXISTS) lib || $(MKDIR) lib
}
}

View File

@ -1,19 +1,20 @@
################################################################################ ################################################################################
# retroshare.pri # # retroshare.pri #
# Copyright (C) 2018, Retroshare team <retroshare.team@gmailcom> # # Copyright (C) 2004-2019, Retroshare Team <contact@retroshare.cc> #
# Copyright (C) 2016-2019, Gioacchino Mazzurco <gio@eigenlab.org> #
# # # #
# This program is free software: you can redistribute it and/or modify # # This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU Affero General Public License as # # it under the terms of the GNU Lesser General Public License as #
# published by the Free Software Foundation, either version 3 of the # # published by the Free Software Foundation, either version 3 of the #
# License, or (at your option) any later version. # # License, or (at your option) any later version. #
# # # #
# This program is distributed in the hope that it will be useful, # # This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of # # but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU Lesser General Public License for more details. # # GNU Lesser General Public License for more details. #
# # # #
# You should have received a copy of the GNU Lesser General Public License # # You should have received a copy of the GNU Lesser General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. # # along with this program. If not, see <https://www.gnu.org/licenses/>. #
################################################################################ ################################################################################
################################################################################ ################################################################################
@ -33,8 +34,8 @@ CONFIG *= gxsdistsync
# To disable RetroShare-nogui append the following # To disable RetroShare-nogui append the following
# assignation to qmake command line "CONFIG+=no_retroshare_nogui" # assignation to qmake command line "CONFIG+=no_retroshare_nogui"
CONFIG *= retroshare_nogui CONFIG *= no_retroshare_nogui
no_retroshare_nogui:CONFIG -= retroshare_nogui retroshare_nogui:CONFIG -= no_retroshare_nogui
# To disable cmark append the following # To disable cmark append the following
# assignation to qmake command line "CONFIG+=no_cmark" # assignation to qmake command line "CONFIG+=no_cmark"
@ -64,13 +65,12 @@ retroshare_qml_app:CONFIG -= no_retroshare_qml_app
# To enable RetroShare service append the following assignation to # To enable RetroShare service append the following assignation to
# qmake command line "CONFIG+=retroshare_service" # qmake command line "CONFIG+=retroshare_service"
CONFIG *= no_retroshare_service CONFIG *= retroshare_service
retroshare_service:CONFIG -= no_retroshare_service retroshare_service:CONFIG -= no_retroshare_service
# To disable libresapi append the following assignation to qmake command line # To enable libresapi (deprecated) append the following assignation to qmake command line
#"CONFIG+=no_libresapi" CONFIG+=no_libresapi
CONFIG *= libresapi libresapi:CONFIG -= no_libresapi
no_libresapi:CONFIG -= libresapi
# To enable libresapi via local socket (unix domain socket or windows named # To enable libresapi via local socket (unix domain socket or windows named
# pipes) append the following assignation to qmake command line # pipes) append the following assignation to qmake command line
@ -85,8 +85,8 @@ libresapi_settings:CONFIG -= no_libresapi_settings
# To disable libresapi via HTTP (based on libmicrohttpd) append the following # To disable libresapi via HTTP (based on libmicrohttpd) append the following
# assignation to qmake command line "CONFIG+=no_libresapihttpserver" # assignation to qmake command line "CONFIG+=no_libresapihttpserver"
CONFIG *= libresapihttpserver CONFIG *= no_libresapihttpserver
no_libresapihttpserver:CONFIG -= libresapihttpserver libresapihttpserver:CONFIG -= no_libresapihttpserver
# To disable SQLCipher support append the following assignation to qmake # To disable SQLCipher support append the following assignation to qmake
# command line "CONFIG+=no_sqlcipher" # command line "CONFIG+=no_sqlcipher"
@ -173,11 +173,26 @@ rs_deep_search:CONFIG -= no_rs_deep_search
CONFIG *= no_rs_use_native_dialogs CONFIG *= no_rs_use_native_dialogs
rs_use_native_dialogs:CONFIG -= no_rs_use_native_dialogs rs_use_native_dialogs:CONFIG -= no_rs_use_native_dialogs
# To disable broadcast discovery happend the following assignation to qmake # To disable broadcast discovery append the following assignation to qmake
# command line "CONFIG+=no_rs_broadcast_discovery" # command line "CONFIG+=no_rs_broadcast_discovery"
CONFIG *= rs_broadcast_discovery CONFIG *= rs_broadcast_discovery
no_rs_broadcast_discovery:CONFIG -= rs_broadcast_discovery no_rs_broadcast_discovery:CONFIG -= rs_broadcast_discovery
# To enable webui append the following assignation to qmake
# command line "CONFIG+=rs_webui"
CONFIG *= no_rs_webui
rs_webui:CONFIG -= no_rs_webui
# To enable webui append the following assignation to qmake
# command line "CONFIG+=rs_service_webui_terminal_password"
CONFIG *= no_rs_service_webui_terminal_password
rs_service_webui_terminal_password:CONFIG -= no_rs_service_webui_terminal_password
# To enable retroshare-service terminal login append the following assignation
# to qmake command line "CONFIG+=rs_service_terminal_login"
CONFIG *= no_rs_service_terminal_login
rs_service_terminal_login:CONFIG -= no_rs_service_terminal_login
# Specify host precompiled jsonapi-generator path, appending the following # Specify host precompiled jsonapi-generator path, appending the following
# assignation to qmake command line # assignation to qmake command line
# 'JSONAPI_GENERATOR_EXE=/myBuildDir/jsonapi-generator'. Required for JSON API # 'JSONAPI_GENERATOR_EXE=/myBuildDir/jsonapi-generator'. Required for JSON API
@ -433,9 +448,9 @@ gxsdistsync:DEFINES *= RS_USE_GXS_DISTANT_SYNC
wikipoos:DEFINES *= RS_USE_WIKI wikipoos:DEFINES *= RS_USE_WIKI
rs_gxs:DEFINES *= RS_ENABLE_GXS rs_gxs:DEFINES *= RS_ENABLE_GXS
rs_gxs_send_all:DEFINES *= RS_GXS_SEND_ALL rs_gxs_send_all:DEFINES *= RS_GXS_SEND_ALL
libresapilocalserver:DEFINES *= LIBRESAPI_LOCAL_SERVER rs_webui:DEFINES *= RS_WEBUI
libresapi_settings:DEFINES *= LIBRESAPI_SETTINGS rs_service_webui_terminal_password:DEFINES *= RS_SERVICE_TERMINAL_WEBUI_PASSWORD
libresapihttpserver:DEFINES *= ENABLE_WEBUI rs_service_terminal_login:DEFINES *= RS_SERVICE_TERMINAL_LOGIN
sqlcipher { sqlcipher {
DEFINES -= NO_SQLCIPHER DEFINES -= NO_SQLCIPHER
@ -448,7 +463,7 @@ no_sqlcipher {
rs_autologin { rs_autologin {
DEFINES *= RS_AUTOLOGIN DEFINES *= RS_AUTOLOGIN
RS_AUTOLOGIN_WARNING_MSG = \ RS_AUTOLOGIN_WARNING_MSG = QMAKE: \
You have enabled RetroShare auto-login, this is discouraged. The usage \ You have enabled RetroShare auto-login, this is discouraged. The usage \
of auto-login on some linux distributions may allow someone having \ of auto-login on some linux distributions may allow someone having \
access to your session to steal the SSL keys of your node location and \ access to your session to steal the SSL keys of your node location and \
@ -471,7 +486,7 @@ no_rs_deprecatedwarning {
QMAKE_CXXFLAGS += -Wno-deprecated QMAKE_CXXFLAGS += -Wno-deprecated
QMAKE_CXXFLAGS += -Wno-deprecated-declarations QMAKE_CXXFLAGS += -Wno-deprecated-declarations
DEFINES *= RS_NO_WARN_DEPRECATED DEFINES *= RS_NO_WARN_DEPRECATED
message("QMAKE: You have disabled deprecated warnings.") warning("QMAKE: You have disabled deprecated warnings.")
} }
no_rs_cppwarning { no_rs_cppwarning {
@ -479,7 +494,7 @@ no_rs_cppwarning {
QMAKE_CXXFLAGS += -Wno-inconsistent-missing-override QMAKE_CXXFLAGS += -Wno-inconsistent-missing-override
DEFINES *= RS_NO_WARN_CPP DEFINES *= RS_NO_WARN_CPP
message("QMAKE: You have disabled C preprocessor warnings.") warning("QMAKE: You have disabled C preprocessor warnings.")
} }
rs_gxs_trans { rs_gxs_trans {
@ -496,7 +511,7 @@ bitdht {
} }
direct_chat { direct_chat {
warning("You have enabled RetroShare direct chat which is deprecated!") warning("QMAKE: You have enabled RetroShare direct chat which is deprecated!")
DEFINES *= RS_DIRECT_CHAT DEFINES *= RS_DIRECT_CHAT
} }
@ -516,6 +531,37 @@ to contain the path to an host executable jsonapi-generator")
DEFINES *= RS_JSONAPI DEFINES *= RS_JSONAPI
} }
libresapilocalserver {
warning("QMAKE: you have enabled libresapilocalserver which is deprecated")
DEFINES *= LIBRESAPI_LOCAL_SERVER
}
libresapi_settings {
warning("QMAKE: you have enabled libresapi_settings which is deprecated")
DEFINES *= LIBRESAPI_SETTINGS
}
libresapihttpserver {
warning("QMAKE: you have enabled libresapihttpserver which is deprecated")
DEFINES *= ENABLE_WEBUI
}
retroshare_nogui {
warning("QMAKE: you have enabled retroshare_nogui which is deprecated")
}
retroshare_android_service {
warning("QMAKE: you have enabled retroshare_android_service which is deprecated")
}
retroshare_android_notify_service {
warning("QMAKE: you have enabled retroshare_android_notify_service which is deprecated")
}
retroshare_qml_app {
warning("QMAKE: you have enabled retroshare_qml_app which is deprecated")
}
rs_deep_search { rs_deep_search {
DEFINES *= RS_DEEP_SEARCH DEFINES *= RS_DEEP_SEARCH