mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
used RsInfo instead of std::cerr in authssl.cc
This commit is contained in:
commit
9b78447109
@ -153,7 +153,7 @@ build_script:
|
||||
# scripts to run after build
|
||||
after_build:
|
||||
- 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%\
|
||||
|
||||
## In Debug build winedeplyqt forget the non debug Qt libs
|
||||
|
@ -145,7 +145,8 @@ void RsControlModule::run()
|
||||
#endif
|
||||
|
||||
RsInit::InitRsConfig();
|
||||
int initResult = RsInit::InitRetroShare(argc, argv, true);
|
||||
RsConfigOptions opt;
|
||||
int initResult = RsInit::InitRetroShare(opt);
|
||||
|
||||
if (initResult < 0) {
|
||||
std::cerr << "RsControlModule: FATAL ERROR, initialising libretroshare FAILED." << std::endl;
|
||||
|
@ -614,4 +614,4 @@ namespace json
|
||||
}
|
||||
}
|
||||
|
||||
#endif //__SUPER_EASY_JSON_H__
|
||||
#endif //__SUPER_EASY_JSON_H__
|
||||
|
@ -65,6 +65,7 @@ p3FileDatabase::p3FileDatabase(p3ServiceControl *mpeers)
|
||||
mRemoteDirectories.clear() ; // we should load them!
|
||||
mOwnId = mpeers->getOwnId() ;
|
||||
|
||||
mBannedFileListNeedsUpdate = false;
|
||||
mLocalSharedDirs = new LocalDirectoryStorage(mFileSharingDir + "/" + LOCAL_SHARED_DIRS_FILE_NAME,mOwnId);
|
||||
mHashCache = new HashStorage(mFileSharingDir + "/" + HASH_CACHE_FILE_NAME) ;
|
||||
|
||||
|
@ -52,6 +52,8 @@ extern JsonApiServer* jsonApiServer;
|
||||
*/
|
||||
struct JsonApiServer : RsSingleJobThread, p3Config
|
||||
{
|
||||
static const uint16_t DEFAULT_PORT = 9092 ;
|
||||
|
||||
/**
|
||||
* @brief construct a JsonApiServer instance with given parameters
|
||||
* @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
|
||||
*/
|
||||
JsonApiServer(
|
||||
uint16_t port = 9092,
|
||||
uint16_t port = DEFAULT_PORT,
|
||||
const std::string& bindAddress = "127.0.0.1",
|
||||
const std::function<bool(const std::string&)> newAccessRequestCallback = [](const std::string&){return false;} );
|
||||
|
||||
|
@ -480,6 +480,7 @@ HEADERS += turtle/p3turtle.h \
|
||||
|
||||
HEADERS += util/folderiterator.h \
|
||||
util/rsdebug.h \
|
||||
util/rskbdinput.h \
|
||||
util/rsmemory.h \
|
||||
util/smallobject.h \
|
||||
util/rsdir.h \
|
||||
@ -626,6 +627,7 @@ SOURCES += turtle/p3turtle.cc \
|
||||
|
||||
SOURCES += util/folderiterator.cc \
|
||||
util/rsdebug.cc \
|
||||
util/rskbdinput.cc \
|
||||
util/rsexpr.cc \
|
||||
util/smallobject.cc \
|
||||
util/rsdir.cc \
|
||||
|
@ -1128,7 +1128,7 @@ bool AuthSSLimpl::AuthX509WithGPG(X509 *x509,bool verbose, uint32_t& diagnostic)
|
||||
}
|
||||
|
||||
if(verbose)
|
||||
std::cerr<< " Verified: " << sigtypestring
|
||||
RsInfo() << " Verified: " << sigtypestring
|
||||
<< " signature of certificate sslId: "
|
||||
<< RsX509Cert::getCertSslId(*x509)
|
||||
<< ", Version " << std::hex << certificate_version << std::dec
|
||||
|
@ -3,8 +3,8 @@
|
||||
* *
|
||||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright (C) 2012 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* 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 *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -32,6 +32,7 @@
|
||||
#include "retroshare/rsgxsifacehelper.h"
|
||||
#include "retroshare/rsidentity.h"
|
||||
#include "serialiser/rsserializable.h"
|
||||
#include "util/rsmemory.h"
|
||||
|
||||
|
||||
class RsGxsCircles;
|
||||
@ -74,8 +75,6 @@ static const uint32_t GXS_EXTERNAL_CIRCLE_FLAGS_ALLOWED = 0x0007 ;// user
|
||||
|
||||
struct RsGxsCircleGroup : RsSerializable
|
||||
{
|
||||
virtual ~RsGxsCircleGroup() {}
|
||||
|
||||
RsGroupMetaData mMeta;
|
||||
|
||||
std::set<RsPgpId> mLocalFriends;
|
||||
@ -95,17 +94,17 @@ struct RsGxsCircleGroup : RsSerializable
|
||||
RS_SERIAL_PROCESS(mInvitedMembers);
|
||||
RS_SERIAL_PROCESS(mSubCircles);
|
||||
}
|
||||
|
||||
~RsGxsCircleGroup() override;
|
||||
};
|
||||
|
||||
struct RsGxsCircleMsg : RsSerializable
|
||||
{
|
||||
virtual ~RsGxsCircleMsg() {}
|
||||
|
||||
RsMsgMetaData mMeta;
|
||||
|
||||
#ifndef V07_NON_BACKWARD_COMPATIBLE_CHANGE_UNNAMED
|
||||
/* 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;
|
||||
#endif
|
||||
|
||||
@ -116,6 +115,8 @@ struct RsGxsCircleMsg : RsSerializable
|
||||
RS_SERIAL_PROCESS(mMeta);
|
||||
RS_SERIAL_PROCESS(stuff);
|
||||
}
|
||||
|
||||
~RsGxsCircleMsg() override;
|
||||
};
|
||||
|
||||
struct RsGxsCircleDetails : RsSerializable
|
||||
@ -123,7 +124,7 @@ struct RsGxsCircleDetails : RsSerializable
|
||||
RsGxsCircleDetails() :
|
||||
mCircleType(static_cast<uint32_t>(RsGxsCircleType::EXTERNAL)),
|
||||
mAmIAllowed(false) {}
|
||||
~RsGxsCircleDetails() override {}
|
||||
~RsGxsCircleDetails() override;
|
||||
|
||||
RsGxsCircleId mCircleId;
|
||||
std::string mCircleName;
|
||||
@ -162,16 +163,29 @@ class RsGxsCircles: public RsGxsIfaceHelper
|
||||
public:
|
||||
|
||||
RsGxsCircles(RsGxsIface& gxs) : RsGxsIfaceHelper(gxs) {}
|
||||
virtual ~RsGxsCircles() {}
|
||||
virtual ~RsGxsCircles();
|
||||
|
||||
/**
|
||||
* @brief Create new circle
|
||||
* @jsonapi{development}
|
||||
* @param[inout] cData input name and flags of the circle, storage for
|
||||
* generated circle data id etc.
|
||||
* @param[in] circleName String containing cirlce name
|
||||
* @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
|
||||
*/
|
||||
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
|
||||
|
@ -30,6 +30,7 @@
|
||||
#define RS_INIT_AUTH_FAILED -1 // 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_EXECUTABLE -4 // executable path hasn't been set in config options
|
||||
|
||||
#include <stdint.h>
|
||||
#include <list>
|
||||
@ -37,7 +38,7 @@
|
||||
#include <vector>
|
||||
#include <retroshare/rstypes.h>
|
||||
|
||||
struct RsLoginHelper;
|
||||
class RsLoginHelper;
|
||||
|
||||
/**
|
||||
* Pointer to global instance of RsLoginHelper
|
||||
@ -45,6 +46,38 @@ struct 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)
|
||||
@ -57,7 +90,7 @@ public:
|
||||
OK, /// Everything go as expected, no error occurred
|
||||
ERR_ALREADY_RUNNING, /// Another istance is running already
|
||||
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 */
|
||||
@ -77,12 +110,19 @@ public:
|
||||
* invalid argument passed and vice versa
|
||||
* @return RS_INIT_...
|
||||
*/
|
||||
static int InitRetroShare(int argc, char **argv, bool strictCheck=true);
|
||||
static int InitRetroShare(const RsConfigOptions&);
|
||||
|
||||
static bool isPortable();
|
||||
static bool isWindowsXP();
|
||||
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;
|
||||
*/
|
||||
@ -270,8 +310,10 @@ extern RsAccounts* rsAccounts;
|
||||
* This helper class have been implemented because there was not reasonable way
|
||||
* to login in the API that could be exposed via JSON API
|
||||
*/
|
||||
struct RsLoginHelper
|
||||
class RsLoginHelper
|
||||
{
|
||||
public:
|
||||
RsLoginHelper() {}
|
||||
/**
|
||||
* @brief Normal way to attempt login
|
||||
* @jsonapi{development,manualwrapper}
|
||||
@ -295,7 +337,7 @@ struct RsLoginHelper
|
||||
RsPeerId mLocationId;
|
||||
RsPgpId mPgpId;
|
||||
std::string mLocationName;
|
||||
std::string mPpgName;
|
||||
std::string mPgpName;
|
||||
|
||||
/// @see RsSerializable::serial_process
|
||||
void serial_process( RsGenericSerializer::SerializeJob j,
|
||||
|
@ -522,6 +522,7 @@ public:
|
||||
* @return true on success
|
||||
*/
|
||||
virtual bool getMessage(const std::string &msgId, Rs::Msgs::MessageInfo &msg) = 0;
|
||||
|
||||
/**
|
||||
* @brief getMessageCount
|
||||
* @jsonapi{development}
|
||||
|
@ -42,6 +42,8 @@
|
||||
#include "util/folderiterator.h"
|
||||
#include "util/rsstring.h"
|
||||
#include "retroshare/rsinit.h"
|
||||
#include "retroshare/rsnotify.h"
|
||||
#include "retroshare/rsiface.h"
|
||||
#include "plugins/pluginmanager.h"
|
||||
|
||||
#include "rsserver/rsloginhandler.h"
|
||||
@ -112,9 +114,30 @@ RsLoginHelper* rsLoginHelper = 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
|
||||
{
|
||||
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;
|
||||
|
||||
@ -155,6 +178,7 @@ struct RsInitConfig
|
||||
|
||||
bool udpListenerOnly;
|
||||
std::string opModeStr;
|
||||
std::string optBaseDir;
|
||||
|
||||
uint16_t jsonApiPort;
|
||||
std::string jsonApiBindAddress;
|
||||
@ -243,14 +267,6 @@ void RsInit::InitRsConfig()
|
||||
setOutputLevel(RsLog::Warning);
|
||||
}
|
||||
|
||||
/********
|
||||
* LOCALNET_TESTING - allows port restrictions
|
||||
*
|
||||
* #define LOCALNET_TESTING 1
|
||||
*
|
||||
********/
|
||||
|
||||
|
||||
#ifdef LOCALNET_TESTING
|
||||
|
||||
std::string portRestrictions;
|
||||
@ -264,165 +280,117 @@ bool doPortRestrictions = false;
|
||||
#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
|
||||
for(int i=0; i<argc; i++) printf("%d: %s\n", i, argv[i]);
|
||||
#endif
|
||||
rsInitConfig->autoLogin = conf.autoLogin;
|
||||
rsInitConfig->outStderr = conf.outStderr;
|
||||
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
|
||||
// for static PThreads under windows... we need to init the library...
|
||||
pthread_win32_process_attach_np();
|
||||
#endif
|
||||
|
||||
std::string prefUserString = "";
|
||||
std::string opt_base_dir;
|
||||
|
||||
#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;
|
||||
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;
|
||||
if( rsInitConfig->port != 0) rsInitConfig->forceExtPort = true;
|
||||
#ifdef LOCALNET_TESTING
|
||||
if(!portRestrictions.empty()) doPortRestrictions = true;
|
||||
#endif
|
||||
|
||||
setOutputLevel((RsLog::logLvl)rsInitConfig->debugLevel);
|
||||
|
||||
argstream as(argc,argv);
|
||||
as >> option('m',"minimized" ,rsInitConfig->startMinimised ,"Start minimized." )
|
||||
>> option('s',"stderr" ,rsInitConfig->outStderr ,"output to stderr instead of log file." )
|
||||
>> 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);
|
||||
// set the debug file.
|
||||
if (rsInitConfig->haveLogFile)
|
||||
setDebugFile(rsInitConfig->logfname.c_str());
|
||||
|
||||
#ifdef RS_JSONAPI
|
||||
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 ******************/
|
||||
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#ifndef WINDOWS_SYS
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#else
|
||||
// Windows Networking Init.
|
||||
WORD wVerReq = MAKEWORD(2,2);
|
||||
WSADATA wsaData;
|
||||
// Windows Networking Init.
|
||||
WORD wVerReq = MAKEWORD(2,2);
|
||||
WSADATA wsaData;
|
||||
|
||||
if (0 != WSAStartup(wVerReq, &wsaData))
|
||||
{
|
||||
std::cerr << "Failed to Startup Windows Networking";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Started Windows Networking";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
if (0 != WSAStartup(wVerReq, &wsaData))
|
||||
{
|
||||
std::cerr << "Failed to Startup Windows Networking";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Started Windows Networking";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
#endif
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
// SWITCH off the SIGPIPE - kills process on Linux.
|
||||
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
// SWITCH off the SIGPIPE - kills process on Linux.
|
||||
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#ifndef WINDOWS_SYS
|
||||
struct sigaction sigact;
|
||||
sigact.sa_handler = SIG_IGN;
|
||||
sigact.sa_flags = 0;
|
||||
struct sigaction sigact;
|
||||
sigact.sa_handler = SIG_IGN;
|
||||
sigact.sa_flags = 0;
|
||||
|
||||
sigset_t set;
|
||||
sigemptyset(&set);
|
||||
//sigaddset(&set, SIGINT); // or whatever other signal
|
||||
sigact.sa_mask = set;
|
||||
sigset_t set;
|
||||
sigemptyset(&set);
|
||||
//sigaddset(&set, SIGINT); // or whatever other signal
|
||||
sigact.sa_mask = set;
|
||||
|
||||
if (0 == sigaction(SIGPIPE, &sigact, NULL))
|
||||
{
|
||||
std::cerr << "RetroShare:: Successfully installed the SIGPIPE Block" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "RetroShare:: Failed to install the SIGPIPE Block" << std::endl;
|
||||
}
|
||||
if (0 == sigaction(SIGPIPE, &sigact, NULL))
|
||||
{
|
||||
std::cerr << "RetroShare:: Successfully installed the SIGPIPE Block" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "RetroShare:: Failed to install the SIGPIPE Block" << std::endl;
|
||||
}
|
||||
#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))
|
||||
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;
|
||||
if(conf.main_executable_path.empty())
|
||||
{
|
||||
std::cerr << "Executable path is unknown. It should normally have been set in passed RsConfigOptions structure" << 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.
|
||||
* 3) Get Prefered Id.
|
||||
* 2) Get List of Available Accounts.
|
||||
* 4) Get List of GPG Accounts.
|
||||
*/
|
||||
/* Initialize AuthSSL */
|
||||
AuthSSL::instance().InitAuth(nullptr, nullptr, nullptr, "");
|
||||
/* Initialize AuthSSL */
|
||||
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))
|
||||
return error_code ;
|
||||
if(!RsAccounts::init(rsInitConfig->optBaseDir,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
|
||||
/* check that we have selected someone */
|
||||
@ -443,9 +411,7 @@ int RsInit::InitRetroShare(int argc, char **argv, bool /* strictCheck */)
|
||||
#ifdef RS_JSONAPI
|
||||
if(rsInitConfig->jsonApiPort)
|
||||
{
|
||||
jsonApiServer = new JsonApiServer(
|
||||
rsInitConfig->jsonApiPort,
|
||||
rsInitConfig->jsonApiBindAddress );
|
||||
jsonApiServer = new JsonApiServer( rsInitConfig->jsonApiPort, rsInitConfig->jsonApiBindAddress );
|
||||
jsonApiServer->start("JSON API Server");
|
||||
}
|
||||
#endif // ifdef RS_JSONAPI
|
||||
@ -477,7 +443,7 @@ RsInit::LoadCertificateStatus RsInit::LockConfigDirectory(
|
||||
case 0: return RsInit::OK;
|
||||
case 1: return RsInit::ERR_ALREADY_RUNNING;
|
||||
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;
|
||||
}
|
||||
|
||||
std::string RsInit::lockFilePath()
|
||||
{
|
||||
return RsAccounts::AccountDirectory() + "/lock" ;
|
||||
}
|
||||
|
||||
RsInit::LoadCertificateStatus RsInit::LockAndLoadCertificates(
|
||||
bool autoLoginNT, std::string& lockFilePath )
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!RsAccounts::lockPreferredAccount())
|
||||
throw RsInit::ERR_UNKOWN; // invalid PreferredAccount.
|
||||
throw RsInit::ERR_UNKNOWN; // invalid PreferredAccount.
|
||||
|
||||
// Logic that used to be external to RsInit...
|
||||
RsPeerId accountId;
|
||||
if (!RsAccounts::GetPreferredAccountId(accountId))
|
||||
throw RsInit::ERR_UNKOWN; // invalid PreferredAccount;
|
||||
throw RsInit::ERR_UNKNOWN; // invalid PreferredAccount;
|
||||
|
||||
RsPgpId pgpId;
|
||||
std::string 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))
|
||||
throw RsInit::ERR_UNKOWN; // PGP Error.
|
||||
throw RsInit::ERR_UNKNOWN; // PGP Error.
|
||||
|
||||
LoadCertificateStatus retVal =
|
||||
LockConfigDirectory(RsAccounts::AccountDirectory(), lockFilePath);
|
||||
@ -541,7 +512,7 @@ RsInit::LoadCertificateStatus RsInit::LockAndLoadCertificates(
|
||||
if(LoadCertificates(autoLoginNT) != 1)
|
||||
{
|
||||
UnlockConfigDirectory();
|
||||
throw RsInit::ERR_UNKOWN;
|
||||
throw RsInit::ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
return RsInit::OK;
|
||||
@ -1210,7 +1181,8 @@ int RsServer::StartupRetroShare()
|
||||
plugins_directories.push_back(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
|
||||
plugins_directories.push_back(".") ; // this list should be saved/set to some correct value.
|
||||
@ -1909,21 +1881,24 @@ int RsServer::StartupRetroShare()
|
||||
return 1;
|
||||
}
|
||||
|
||||
RsInit::LoadCertificateStatus RsLoginHelper::attemptLogin(
|
||||
const RsPeerId& account, const std::string& password)
|
||||
RsInit::LoadCertificateStatus RsLoginHelper::attemptLogin(const RsPeerId& account, const std::string& password)
|
||||
{
|
||||
if(isLoggedIn()) return RsInit::ERR_ALREADY_RUNNING;
|
||||
if(!rsNotify->cachePgpPassphrase(password)) return RsInit::ERR_UNKOWN;
|
||||
if(!rsNotify->setDisableAskPassword(true)) return RsInit::ERR_UNKOWN;
|
||||
if(!RsAccounts::SelectAccount(account)) return RsInit::ERR_UNKOWN;
|
||||
|
||||
if(!password.empty())
|
||||
{
|
||||
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;
|
||||
RsInit::LoadCertificateStatus ret =
|
||||
RsInit::LockAndLoadCertificates(false, _ignore_lockFilePath);
|
||||
if(!rsNotify->setDisableAskPassword(false)) return RsInit::ERR_UNKOWN;
|
||||
if(!rsNotify->clearPgpPassphrase()) return RsInit::ERR_UNKOWN;
|
||||
RsInit::LoadCertificateStatus ret = RsInit::LockAndLoadCertificates(false, _ignore_lockFilePath);
|
||||
|
||||
if(!rsNotify->setDisableAskPassword(false)) return RsInit::ERR_UNKNOWN;
|
||||
if(!rsNotify->clearPgpPassphrase()) return RsInit::ERR_UNKNOWN;
|
||||
if(ret != RsInit::OK) return ret;
|
||||
if(RsControl::instance()->StartupRetroShare() == 1) return RsInit::OK;
|
||||
return RsInit::ERR_UNKOWN;
|
||||
return RsInit::ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
/*static*/ bool RsLoginHelper::collectEntropy(uint32_t bytes)
|
||||
@ -1939,7 +1914,7 @@ void RsLoginHelper::getLocations(std::vector<RsLoginHelper::Location>& store)
|
||||
{
|
||||
Location l; l.mLocationId = locId;
|
||||
std::string discardPgpMail;
|
||||
RsAccounts::GetAccountDetails( locId, l.mPgpId, l.mPpgName,
|
||||
RsAccounts::GetAccountDetails( locId, l.mPgpId, l.mPgpName,
|
||||
discardPgpMail, l.mLocationName );
|
||||
store.push_back(l);
|
||||
}
|
||||
@ -1957,14 +1932,14 @@ bool RsLoginHelper::createLocation(
|
||||
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";
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
return false;
|
||||
@ -1999,7 +1974,7 @@ void RsLoginHelper::Location::serial_process(
|
||||
RS_SERIAL_PROCESS(mLocationId);
|
||||
RS_SERIAL_PROCESS(mPgpId);
|
||||
RS_SERIAL_PROCESS(mLocationName);
|
||||
RS_SERIAL_PROCESS(mPpgName);
|
||||
RS_SERIAL_PROCESS(mPgpName);
|
||||
}
|
||||
|
||||
/*static*/ bool RsAccounts::getCurrentAccountId(RsPeerId& id)
|
||||
|
@ -732,11 +732,13 @@ bool RsTypeSerializer::to_JSON(
|
||||
rapidjson::Document::AllocatorType& allocator = jDoc.GetAllocator();
|
||||
|
||||
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;
|
||||
Radix64::encode( reinterpret_cast<uint8_t*>(member.first),
|
||||
member.second, encodedValue );
|
||||
static_cast<int>(member.second), encodedValue );
|
||||
|
||||
rapidjson::Value value;
|
||||
value.SetString(encodedValue.data(), allocator);
|
||||
|
@ -3,7 +3,8 @@
|
||||
* *
|
||||
* 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 *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -27,7 +28,7 @@
|
||||
#include "util/rsdir.h"
|
||||
#include "util/radix64.h"
|
||||
#include "util/rsstring.h"
|
||||
|
||||
#include "util/rsdebug.h"
|
||||
#include "pgp/pgpauxutils.h"
|
||||
#include "retroshare/rsgxscircles.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
@ -153,8 +154,76 @@ RsServiceInfo p3GxsCircles::getServiceInfo()
|
||||
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;
|
||||
createGroup(token, cData);
|
||||
|
||||
@ -172,8 +241,9 @@ bool p3GxsCircles::createCircle(RsGxsCircleGroup& cData)
|
||||
return false;
|
||||
}
|
||||
|
||||
circleId = static_cast<RsGxsCircleId>(cData.mMeta.mGroupId);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
bool p3GxsCircles::editCircle(RsGxsCircleGroup& cData)
|
||||
{
|
||||
@ -2157,3 +2227,8 @@ bool p3GxsCircles::processMembershipRequests(uint32_t token)
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
RsGxsCircles::~RsGxsCircles() = default;
|
||||
RsGxsCircleMsg::~RsGxsCircleMsg() = default;
|
||||
RsGxsCircleDetails::~RsGxsCircleDetails() = default;
|
||||
RsGxsCircleGroup::~RsGxsCircleGroup() = default;
|
||||
|
@ -3,7 +3,8 @@
|
||||
* *
|
||||
* 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 *
|
||||
* 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/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
#ifndef P3_CIRCLES_SERVICE_HEADER
|
||||
#define P3_CIRCLES_SERVICE_HEADER
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "retroshare/rsgxscircles.h" // External Interfaces.
|
||||
@ -180,7 +180,14 @@ virtual RsServiceInfo getServiceInfo();
|
||||
/*********** External Interface ***************/
|
||||
|
||||
/// @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
|
||||
bool editCircle(RsGxsCircleGroup& cData) override;
|
||||
@ -315,5 +322,3 @@ virtual RsServiceInfo getServiceInfo();
|
||||
std::list<RsGxsId> mDummyPgpLinkedIds;
|
||||
std::list<RsGxsId> mDummyOwnIds;
|
||||
};
|
||||
|
||||
#endif // P3_CIRCLES_SERVICE_HEADER
|
||||
|
@ -968,6 +968,11 @@ bool p3IdService::createIdentity(
|
||||
|
||||
id = RsGxsId(meta.mGroupId);
|
||||
|
||||
{
|
||||
RS_STACK_MUTEX(mIdMtx);
|
||||
mOwnIds.push_back(id);
|
||||
if(!pseudonimous) mOwnSignedIds.push_back(id);
|
||||
}
|
||||
|
||||
LabelCreateIdentityCleanup:
|
||||
if(!pseudonimous && !pgpPassword.empty())
|
||||
@ -3036,7 +3041,7 @@ bool p3IdService::cache_request_ownids()
|
||||
|
||||
RsGenExchange::getTokenService()->requestGroupInfo(token, ansType, opts);
|
||||
GxsTokenQueue::queueRequest(token, GXSIDREQ_CACHEOWNIDS);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
130
libretroshare/src/util/rskbdinput.cc
Normal file
130
libretroshare/src/util/rskbdinput.cc
Normal 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
|
27
libretroshare/src/util/rskbdinput.h
Normal file
27
libretroshare/src/util/rskbdinput.h
Normal 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) ;
|
||||
|
||||
}
|
@ -128,10 +128,25 @@ public:
|
||||
|
||||
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 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
|
||||
@ -683,7 +698,7 @@ void NewFriendList::peerTreeWidgetCustomPopupMenu()
|
||||
contextMenu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy certificate link"), this, SLOT(copyFullCertificate()));
|
||||
|
||||
//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()));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -231,6 +231,8 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
||||
// fill quick view
|
||||
fillQuickView();
|
||||
|
||||
sortColumn(RsMessageModel::COLUMN_THREAD_DATE,Qt::DescendingOrder);
|
||||
|
||||
// load settings
|
||||
processSettings(true);
|
||||
|
||||
|
@ -80,6 +80,7 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
|
||||
ui.setupUi(this);
|
||||
|
||||
manager = NULL ;
|
||||
mOngoingConnectivityCheck = -1;
|
||||
|
||||
if(RsAccounts::isHiddenNode())
|
||||
{
|
||||
|
@ -21,6 +21,7 @@
|
||||
*******************************************************************************/
|
||||
|
||||
#include "util/stacktrace.h"
|
||||
#include "util/argstream.h"
|
||||
|
||||
CrashStackTrace gCrashStackTrace;
|
||||
|
||||
@ -50,6 +51,7 @@ CrashStackTrace gCrashStackTrace;
|
||||
#include "util/RsGxsUpdateBroadcast.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "util/rstime.h"
|
||||
#include "retroshare/rsinit.h"
|
||||
|
||||
#ifdef MESSENGER_WINDOW
|
||||
#include "gui/MessengerWindow.h"
|
||||
@ -228,7 +230,36 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
|
||||
|
||||
/* RetroShare Core Objects */
|
||||
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.
|
||||
{
|
||||
@ -252,7 +283,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
|
||||
if(!RsAccounts::CopyGnuPGKeyrings())
|
||||
return 0 ;
|
||||
|
||||
initResult = RsInit::InitRetroShare(argc, argv);
|
||||
initResult = RsInit::InitRetroShare(conf);
|
||||
|
||||
displayWarningAboutDSAKeys() ;
|
||||
|
||||
|
@ -57,8 +57,10 @@
|
||||
|
||||
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();
|
||||
uint16_t httpPort = 0;
|
||||
std::string listenAddress;
|
||||
@ -77,8 +79,9 @@ int main(int argc, char **argv)
|
||||
std::cerr << args.usage() << std::endl;
|
||||
// print libretroshare command line args and exit
|
||||
RsInit::InitRsConfig();
|
||||
RsInit::InitRetroShare(argc, argv, true);
|
||||
return 0;
|
||||
|
||||
RsInit::InitRetroShare(conf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
resource_api::ApiServer api;
|
||||
@ -126,7 +129,7 @@ int main(int argc, char **argv)
|
||||
|
||||
bool strictCheck = true;
|
||||
RsInit::InitRsConfig();
|
||||
int initResult = RsInit::InitRetroShare(argc, argv, strictCheck);
|
||||
int initResult = RsInit::InitRetroShare(conf);
|
||||
|
||||
if (initResult < 0) {
|
||||
/* Error occured */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* 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
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
@ -17,61 +17,301 @@
|
||||
*/
|
||||
|
||||
#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 <QObject>
|
||||
#include <QStringList>
|
||||
#include <iomanip>
|
||||
#include <atomic>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
# include <QAndroidService>
|
||||
# include <QCoreApplication>
|
||||
# include <QObject>
|
||||
# include <QStringList>
|
||||
|
||||
# include "util/androiddebug.h"
|
||||
#endif // def __ANDROID__
|
||||
|
||||
#include "retroshare/rsinit.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__
|
||||
# include "util/androiddebug.h"
|
||||
#endif
|
||||
void signalHandler(int /*signal*/) { QCoreApplication::exit(0); }
|
||||
#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[])
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
AndroidStdIOCatcher dbg; (void) dbg;
|
||||
QAndroidService app(argc, argv);
|
||||
#else // def __ANDROID__
|
||||
QCoreApplication app(argc, argv);
|
||||
#endif // def __ANDROID__
|
||||
|
||||
signal(SIGINT, QCoreApplication::exit);
|
||||
signal(SIGTERM, QCoreApplication::exit);
|
||||
signal(SIGINT, signalHandler);
|
||||
signal(SIGTERM, signalHandler);
|
||||
#ifdef SIGBREAK
|
||||
signal(SIGBREAK, QCoreApplication::exit);
|
||||
signal(SIGBREAK, signalHandler);
|
||||
#endif // ifdef SIGBREAK
|
||||
|
||||
RsInfo() << "\n" <<
|
||||
"+================================================================+\n"
|
||||
"| o---o o |\n"
|
||||
"| \\ / - Retroshare Service - / \\ |\n"
|
||||
"| o o---o |\n"
|
||||
"+================================================================+"
|
||||
<< std::endl << std::endl;
|
||||
|
||||
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();
|
||||
|
||||
#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);
|
||||
|
||||
QObject::connect(
|
||||
&app, &QCoreApplication::aboutToQuit,
|
||||
[](){
|
||||
@ -79,4 +319,12 @@ int main(int argc, char* argv[])
|
||||
RsControl::instance()->rsGlobalShutDown(); } );
|
||||
|
||||
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
|
||||
}
|
||||
|
@ -40,3 +40,75 @@ unix {
|
||||
target.path = "$${RS_BIN_DIR}"
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,19 +1,20 @@
|
||||
################################################################################
|
||||
# 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 #
|
||||
# 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 #
|
||||
# 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 #
|
||||
# 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/>. #
|
||||
# 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
|
||||
# assignation to qmake command line "CONFIG+=no_retroshare_nogui"
|
||||
CONFIG *= retroshare_nogui
|
||||
no_retroshare_nogui:CONFIG -= retroshare_nogui
|
||||
CONFIG *= no_retroshare_nogui
|
||||
retroshare_nogui:CONFIG -= no_retroshare_nogui
|
||||
|
||||
# To disable cmark append the following
|
||||
# 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
|
||||
# qmake command line "CONFIG+=retroshare_service"
|
||||
CONFIG *= no_retroshare_service
|
||||
CONFIG *= retroshare_service
|
||||
retroshare_service:CONFIG -= no_retroshare_service
|
||||
|
||||
# To disable libresapi append the following assignation to qmake command line
|
||||
#"CONFIG+=no_libresapi"
|
||||
CONFIG *= libresapi
|
||||
no_libresapi:CONFIG -= libresapi
|
||||
# To enable libresapi (deprecated) append the following assignation to qmake command line
|
||||
CONFIG+=no_libresapi
|
||||
libresapi:CONFIG -= no_libresapi
|
||||
|
||||
# To enable libresapi via local socket (unix domain socket or windows named
|
||||
# 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
|
||||
# assignation to qmake command line "CONFIG+=no_libresapihttpserver"
|
||||
CONFIG *= libresapihttpserver
|
||||
no_libresapihttpserver:CONFIG -= libresapihttpserver
|
||||
CONFIG *= no_libresapihttpserver
|
||||
libresapihttpserver:CONFIG -= no_libresapihttpserver
|
||||
|
||||
# To disable SQLCipher support append the following assignation to qmake
|
||||
# command line "CONFIG+=no_sqlcipher"
|
||||
@ -173,11 +173,26 @@ rs_deep_search:CONFIG -= no_rs_deep_search
|
||||
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"
|
||||
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
|
||||
# assignation to qmake command line
|
||||
# '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
|
||||
rs_gxs:DEFINES *= RS_ENABLE_GXS
|
||||
rs_gxs_send_all:DEFINES *= RS_GXS_SEND_ALL
|
||||
libresapilocalserver:DEFINES *= LIBRESAPI_LOCAL_SERVER
|
||||
libresapi_settings:DEFINES *= LIBRESAPI_SETTINGS
|
||||
libresapihttpserver:DEFINES *= ENABLE_WEBUI
|
||||
rs_webui:DEFINES *= RS_WEBUI
|
||||
rs_service_webui_terminal_password:DEFINES *= RS_SERVICE_TERMINAL_WEBUI_PASSWORD
|
||||
rs_service_terminal_login:DEFINES *= RS_SERVICE_TERMINAL_LOGIN
|
||||
|
||||
sqlcipher {
|
||||
DEFINES -= NO_SQLCIPHER
|
||||
@ -448,7 +463,7 @@ no_sqlcipher {
|
||||
|
||||
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 \
|
||||
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 \
|
||||
@ -471,7 +486,7 @@ no_rs_deprecatedwarning {
|
||||
QMAKE_CXXFLAGS += -Wno-deprecated
|
||||
QMAKE_CXXFLAGS += -Wno-deprecated-declarations
|
||||
DEFINES *= RS_NO_WARN_DEPRECATED
|
||||
message("QMAKE: You have disabled deprecated warnings.")
|
||||
warning("QMAKE: You have disabled deprecated warnings.")
|
||||
}
|
||||
|
||||
no_rs_cppwarning {
|
||||
@ -479,7 +494,7 @@ no_rs_cppwarning {
|
||||
QMAKE_CXXFLAGS += -Wno-inconsistent-missing-override
|
||||
|
||||
DEFINES *= RS_NO_WARN_CPP
|
||||
message("QMAKE: You have disabled C preprocessor warnings.")
|
||||
warning("QMAKE: You have disabled C preprocessor warnings.")
|
||||
}
|
||||
|
||||
rs_gxs_trans {
|
||||
@ -496,7 +511,7 @@ bitdht {
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@ -516,6 +531,37 @@ to contain the path to an host executable jsonapi-generator")
|
||||
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 {
|
||||
DEFINES *= RS_DEEP_SEARCH
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user