2018-05-28 16:28:51 -04:00
/*******************************************************************************
* libretroshare / src / retroshare : rsinit . cc *
* *
* libretroshare : retroshare core library *
* *
* Copyright 2004 - 2006 by Robert Fernie < retroshare @ lunamutt . com > *
* *
* 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/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-11-14 22:18:48 -05:00
2009-07-30 17:27:47 -04:00
/* This is an updated startup class. Class variables are hidden from
* the GUI / External via a hidden class * /
2008-11-02 06:38:11 -05:00
2009-07-30 17:27:47 -04:00
# include <unistd.h>
2010-07-01 16:30:36 -04:00
# ifndef WINDOWS_SYS
2012-10-09 19:07:51 -04:00
// for locking instances
2010-07-01 16:30:36 -04:00
# include <errno.h>
2012-10-09 19:07:51 -04:00
# else
# include "util/rswin.h"
2010-07-01 16:30:36 -04:00
# endif
2018-01-29 07:26:43 -05:00
# ifdef __ANDROID__
# include <QFile> // To install bdboot.txt
# include <QString> // for String::fromStdString(...)
# endif
2013-08-06 13:01:38 -04:00
# include "util/argstream.h"
2008-07-10 12:29:18 -04:00
# include "util/rsdebug.h"
2007-11-14 22:18:48 -05:00
# include "util/rsdir.h"
2011-02-01 18:27:53 -05:00
# include "util/rsrandom.h"
2011-04-03 19:11:38 -04:00
# include "util/folderiterator.h"
2011-10-01 09:12:28 -04:00
# include "util/rsstring.h"
2010-08-06 05:40:23 -04:00
# include "retroshare/rsinit.h"
2011-06-16 17:59:26 -04:00
# include "plugins/pluginmanager.h"
2014-01-17 21:32:55 -05:00
2011-02-01 18:27:53 -05:00
# include "rsserver/rsloginhandler.h"
2014-01-17 21:32:55 -05:00
# include "rsserver/rsaccounts.h"
2009-03-13 17:14:30 -04:00
2007-11-14 22:18:48 -05:00
# include <list>
# include <string>
2009-07-30 17:27:47 -04:00
# include <dirent.h>
# include <sys/types.h>
# include <sys/stat.h>
2013-09-23 16:55:34 -04:00
# include <openssl/rand.h>
2009-07-30 17:27:47 -04:00
# include <fcntl.h>
2016-08-13 04:15:02 -04:00
# include "gxstunnel/p3gxstunnel.h"
2018-07-15 05:14:58 -04:00
# include "retroshare/rsgxsdistsync.h"
2016-08-13 04:15:02 -04:00
# include "file_sharing/p3filelists.h"
2015-11-26 20:40:06 -05:00
2014-03-29 10:18:05 -04:00
# define ENABLE_GROUTER
2012-02-19 15:05:41 -05:00
# if (defined(__unix__) || defined(unix)) && !defined(USG)
# include <sys/param.h>
# endif
2017-12-31 11:27:21 -05:00
// This needs to be defined here, because when USE_BITDHT is unset, the variable, that is defined in libbitdht (not compiled!) will be missing.
# ifndef RS_USE_BITDHT
RsDht * rsDht = NULL ;
# endif
2007-11-14 22:18:48 -05:00
// for blocking signals
# include <signal.h>
2013-09-26 19:53:06 -04:00
# include <openssl/ssl.h>
2010-01-13 15:52:31 -05:00
# include "pqi/authssl.h"
2010-06-26 08:31:24 -04:00
# include "pqi/sslfns.h"
2010-01-13 15:56:55 -05:00
# include "pqi/authgpg.h"
2008-01-25 02:58:29 -05:00
2014-03-29 10:18:05 -04:00
# ifdef ENABLE_GROUTER
2013-11-02 10:35:33 -04:00
# include "grouter/p3grouter.h"
# endif
2016-06-21 07:55:23 -04:00
# ifdef RS_USE_DHT_STUNNER
2011-06-29 14:02:44 -04:00
# include "tcponudp/udpstunner.h"
2016-06-21 07:55:23 -04:00
# endif // RS_USE_DHT_STUNNER
2011-06-29 14:02:44 -04:00
2017-03-01 20:37:53 -05:00
# ifdef RS_GXS_TRANS
# include "gxstrans / p3gxstrans.h"
2017-01-15 15:45:03 -05:00
# endif
2018-09-19 15:28:26 -04:00
# ifdef RS_JSONAPI
# include "jsonapi / jsonapi.h"
# endif
2012-07-25 18:43:43 -04:00
// #define GPG_DEBUG
// #define AUTHSSL_DEBUG
// #define FIM_DEBUG
2017-07-09 16:12:01 -04:00
// #define DEBUG_RSINIT
2012-07-25 18:43:43 -04:00
2014-01-17 21:32:55 -05:00
//std::map<std::string,std::vector<std::string> > RsInit::unsupported_keys ;
2009-07-30 17:27:47 -04:00
2018-08-30 13:06:20 -04:00
RsLoginHelper * rsLoginHelper = nullptr ;
RsAccounts * rsAccounts = nullptr ;
2018-06-27 02:52:03 -04:00
2018-09-19 15:28:26 -04:00
struct RsInitConfig
2009-07-30 17:27:47 -04:00
{
2018-09-19 15:28:26 -04:00
RsInitConfig ( ) : jsonApiPort ( 0 ) , jsonApiBindAddress ( " 127.0.0.1 " ) { }
2014-01-17 21:32:55 -05:00
2018-09-19 15:28:26 -04:00
RsFileHash main_executable_hash ;
2014-01-17 21:32:55 -05:00
2010-04-30 10:34:48 -04:00
# ifdef WINDOWS_SYS
2018-09-19 15:28:26 -04:00
bool portable ;
bool isWindowsXP ;
2010-04-30 10:34:48 -04:00
# endif
2014-08-25 17:07:07 -04:00
rs_lock_handle_t lockHandle ;
2010-07-01 16:30:36 -04:00
2014-08-25 17:07:07 -04:00
std : : string passwd ;
std : : string gxs_passwd ;
2009-07-30 17:27:47 -04:00
2014-08-25 17:07:07 -04:00
bool autoLogin ; /* autoLogin allowed */
bool startMinimised ; /* Icon or Full Window */
2009-07-30 17:27:47 -04:00
2014-08-25 17:07:07 -04:00
/* Key Parameters that must be set before
* RetroShare will start up :
*/
2009-07-30 17:27:47 -04:00
2014-08-25 17:07:07 -04:00
/* Listening Port */
bool forceExtPort ;
bool forceLocalAddr ;
unsigned short port ;
std : : string inet ;
2009-07-30 17:27:47 -04:00
2013-09-08 22:10:49 -04:00
/* v0.6 features */
2014-08-25 17:07:07 -04:00
bool hiddenNodeSet ;
std : : string hiddenNodeAddress ;
uint16_t hiddenNodePort ;
2013-09-08 22:10:49 -04:00
2016-10-09 08:32:52 -04:00
bool hiddenNodeI2PBOB ;
2014-08-25 17:07:07 -04:00
/* Logging */
bool haveLogFile ;
bool outStderr ;
int debugLevel ;
std : : string logfname ;
2009-07-30 17:27:47 -04:00
2014-08-25 17:07:07 -04:00
bool udpListenerOnly ;
2016-08-13 08:34:31 -04:00
std : : string opModeStr ;
2009-07-30 17:27:47 -04:00
2018-09-19 15:28:26 -04:00
uint16_t jsonApiPort ;
std : : string jsonApiBindAddress ;
} ;
2007-11-14 22:18:48 -05:00
2018-09-19 15:28:26 -04:00
static RsInitConfig * rsInitConfig = nullptr ;
2014-01-17 21:32:55 -05:00
2007-11-14 22:18:48 -05:00
static const std : : string configLogFileName = " retro.log " ;
2011-01-29 09:27:16 -05:00
static const int SSLPWD_LEN = 64 ;
2007-11-14 22:18:48 -05:00
2014-08-25 17:07:07 -04:00
void RsInit : : InitRsConfig ( )
{
2018-09-19 15:28:26 -04:00
rsInitConfig = new RsInitConfig ;
/* TODO almost all of this should be moved to RsInitConfig::RsInitConfig
* initializers */
2009-02-08 09:30:28 -05:00
2014-08-25 17:07:07 -04:00
/* Directories */
2010-04-30 10:34:48 -04:00
# ifdef WINDOWS_SYS
2014-08-25 17:07:07 -04:00
rsInitConfig - > portable = false ;
rsInitConfig - > isWindowsXP = false ;
2010-04-30 10:34:48 -04:00
# endif
2014-08-25 17:07:07 -04:00
/* v0.6 features */
rsInitConfig - > hiddenNodeSet = false ;
2009-02-08 09:30:28 -05:00
2018-09-19 15:28:26 -04:00
// This doesn't seems a configuration...
2007-11-14 22:18:48 -05:00
# ifndef WINDOWS_SYS
2014-08-25 17:07:07 -04:00
rsInitConfig - > lockHandle = - 1 ;
2007-11-14 22:18:48 -05:00
# else
2014-08-25 17:07:07 -04:00
rsInitConfig - > lockHandle = NULL ;
2007-11-14 22:18:48 -05:00
# endif
2014-08-25 17:07:07 -04:00
rsInitConfig - > port = 0 ;
rsInitConfig - > forceLocalAddr = false ;
rsInitConfig - > haveLogFile = false ;
rsInitConfig - > outStderr = false ;
rsInitConfig - > forceExtPort = false ;
2009-07-30 17:27:47 -04:00
2014-08-25 17:07:07 -04:00
rsInitConfig - > inet = std : : string ( " 127.0.0.1 " ) ;
2009-07-30 17:27:47 -04:00
2014-08-25 17:07:07 -04:00
rsInitConfig - > autoLogin = false ; // .
rsInitConfig - > startMinimised = false ;
rsInitConfig - > passwd = " " ;
rsInitConfig - > debugLevel = PQL_WARNING ;
rsInitConfig - > udpListenerOnly = false ;
2017-10-17 09:39:25 -04:00
rsInitConfig - > opModeStr = std : : string ( " " ) ;
2009-07-30 17:27:47 -04:00
2010-04-30 10:34:48 -04:00
# ifdef WINDOWS_SYS
// test for portable version
2012-06-09 20:29:46 -04:00
if ( GetFileAttributes ( L " portable " ) ! = ( DWORD ) - 1 ) {
2010-04-30 10:34:48 -04:00
// use portable version
2014-08-25 17:07:07 -04:00
rsInitConfig - > portable = true ;
2010-04-30 10:34:48 -04:00
}
2010-10-07 07:17:42 -04:00
// test for Windows XP
OSVERSIONINFOEX osvi ;
memset ( & osvi , 0 , sizeof ( osvi ) ) ;
osvi . dwOSVersionInfoSize = sizeof ( OSVERSIONINFOEX ) ;
if ( GetVersionEx ( ( OSVERSIONINFO * ) & osvi ) ) {
if ( osvi . dwMajorVersion = = 5 ) {
if ( osvi . dwMinorVersion = = 1 ) {
/* Windows XP */
2014-08-25 17:07:07 -04:00
rsInitConfig - > isWindowsXP = true ;
2010-10-07 07:17:42 -04:00
} else if ( osvi . dwMinorVersion = = 2 ) {
SYSTEM_INFO si ;
memset ( & si , 0 , sizeof ( si ) ) ;
GetSystemInfo ( & si ) ;
if ( osvi . wProductType = = VER_NT_WORKSTATION & & si . wProcessorArchitecture = = PROCESSOR_ARCHITECTURE_AMD64 ) {
/* Windows XP Professional x64 Edition */
2014-08-25 17:07:07 -04:00
rsInitConfig - > isWindowsXP = true ;
2010-10-07 07:17:42 -04:00
}
}
}
}
2014-08-25 17:07:07 -04:00
if ( rsInitConfig - > isWindowsXP ) {
2010-10-07 07:17:42 -04:00
std : : cerr < < " Running Windows XP " < < std : : endl ;
} else {
std : : cerr < < " Not running Windows XP " < < std : : endl ;
}
2010-04-30 10:34:48 -04:00
# endif
2007-11-14 22:18:48 -05:00
2018-09-19 15:28:26 -04:00
setOutputLevel ( RsLog : : Warning ) ;
2007-11-14 22:18:48 -05:00
}
2012-01-07 06:28:00 -05:00
/********
* LOCALNET_TESTING - allows port restrictions
2012-01-11 05:24:37 -05:00
*
* # define LOCALNET_TESTING 1
*
2012-01-07 06:28:00 -05:00
* * * * * * * */
# ifdef LOCALNET_TESTING
std : : string portRestrictions ;
bool doPortRestrictions = false ;
# endif
2017-07-05 15:36:00 -04:00
# ifdef WINDOWS_SYS
# ifdef PTW32_STATIC_LIB
# include <pthread.h>
# endif
# endif
2008-06-14 09:22:39 -04:00
2017-08-02 04:18:58 -04:00
int RsInit : : InitRetroShare ( int argc , char * * argv , bool /* strictCheck */ )
2007-11-14 22:18:48 -05:00
{
2017-07-09 16:12:01 -04:00
# ifdef DEBUG_RSINIT
2018-09-19 15:28:26 -04:00
for ( int i = 0 ; i < argc ; i + + ) printf ( " %d: %s \n " , i , argv [ i ] ) ;
2017-07-09 16:12:01 -04:00
# endif
2010-09-01 17:08:08 -04:00
2017-07-05 15:36:00 -04:00
# ifdef PTW32_STATIC_LIB
2018-09-19 15:28:26 -04:00
// for static PThreads under windows... we need to init the library...
pthread_win32_process_attach_np ( ) ;
2007-11-14 22:18:48 -05:00
# endif
2018-09-19 15:28:26 -04:00
std : : string prefUserString = " " ;
std : : string opt_base_dir ;
2013-08-06 13:01:38 -04:00
2013-08-27 22:11:52 -04:00
# ifdef __APPLE__
2018-09-19 15:28:26 -04:00
// TODO: is this still needed with argstream?
/* HACK to avoid stupid OSX Finder behaviour
2017-07-05 15:36:00 -04:00
* remove the commandline arguments - if we detect we are launched from Finder ,
2013-08-27 22:11:52 -04:00
* and we have the unparsable " -psn_0_12332 " option .
* this is okay , as you cannot pass commandline arguments via Finder anyway
*/
2018-09-19 15:28:26 -04:00
if ( ( argc > = 2 ) & & ( 0 = = strncmp ( argv [ 1 ] , " -psn " , 4 ) ) ) argc = 1 ;
2013-08-27 22:11:52 -04:00
# endif
2018-09-19 15:28:26 -04:00
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 ) ;
# 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
2013-08-06 13:01:38 -04:00
2018-09-19 15:28:26 -04:00
# ifdef LOCALNET_TESTING
as > > parameter ( ' R ' , " restrict-port " , portRestrictions , " port1-port2 " , " Apply port restriction " , false ) ;
# endif // ifdef LOCALNET_TESTING
2013-08-27 22:11:52 -04:00
2017-07-11 17:39:04 -04:00
# ifdef RS_AUTOLOGIN
2018-09-19 15:28:26 -04:00
as > > option ( ' a ' , " auto-login " , rsInitConfig - > autoLogin , " AutoLogin (Windows Only) + StartMinimised " ) ;
# endif // ifdef RS_AUTOLOGIN
2013-08-06 13:01:38 -04:00
2018-09-19 15:28:26 -04:00
as > > help ( ' h ' , " help " , " Display this Help " ) ;
as . defaultErrorHandling ( true , true ) ;
2013-08-06 13:01:38 -04:00
2017-07-05 15:36:00 -04:00
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 ;
2013-08-06 13:01:38 -04:00
# ifdef LOCALNET_TESTING
2017-07-05 15:36:00 -04:00
if ( ! portRestrictions . empty ( ) ) doPortRestrictions = true ;
2013-08-06 13:01:38 -04:00
# endif
2017-07-05 15:36:00 -04:00
setOutputLevel ( ( RsLog : : logLvl ) rsInitConfig - > debugLevel ) ;
// set the debug file.
if ( rsInitConfig - > haveLogFile )
setDebugFile ( rsInitConfig - > logfname . c_str ( ) ) ;
2007-11-14 22:18:48 -05:00
2017-07-05 15:36:00 -04:00
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
2007-11-14 22:18:48 -05:00
# ifndef WINDOWS_SYS
2017-07-05 15:36:00 -04:00
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
2007-11-14 22:18:48 -05:00
# else
2017-07-05 15:36:00 -04:00
// 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 ;
}
2007-11-14 22:18:48 -05:00
# endif
2017-07-05 15:36:00 -04:00
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
// SWITCH off the SIGPIPE - kills process on Linux.
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
2007-11-14 22:18:48 -05:00
# ifndef WINDOWS_SYS
2017-07-05 15:36:00 -04:00
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 ;
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 ;
}
2007-11-14 22:18:48 -05:00
# endif
2017-07-05 15:36:00 -04:00
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
2007-11-14 22:18:48 -05:00
2017-07-05 15:36:00 -04:00
// Hash the main executable.
2012-09-09 09:59:21 -04:00
2017-07-05 15:36:00 -04:00
uint64_t tmp_size ;
2008-11-09 11:52:14 -05:00
2017-07-05 15:36:00 -04:00
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 ;
/* At this point we want to.
2009-07-30 17:27:47 -04:00
* 1 ) Load up Dase Directory .
* 3 ) Get Prefered Id .
* 2 ) Get List of Available Accounts .
* 4 ) Get List of GPG Accounts .
2008-11-09 11:52:14 -05:00
*/
2017-07-05 15:36:00 -04:00
/* create singletons */
AuthSSL : : AuthSSLInit ( ) ;
AuthSSL : : getAuthSSL ( ) - > InitAuth ( NULL , NULL , NULL , " " ) ;
2009-07-30 17:27:47 -04:00
2018-06-27 02:52:03 -04:00
rsLoginHelper = new RsLoginHelper ;
2014-08-25 17:07:07 -04:00
2018-08-22 10:59:42 -04:00
int error_code ;
2011-12-06 18:00:42 -05:00
2018-07-24 17:47:32 -04:00
if ( ! RsAccounts : : init ( opt_base_dir , error_code ) )
return error_code ;
2010-04-10 18:06:11 -04:00
2017-07-05 15:36:00 -04:00
// choose alternative account.
if ( prefUserString ! = " " )
2007-11-14 22:18:48 -05:00
{
2017-07-11 17:32:22 -04:00
RsPeerId ssl_id ( prefUserString ) ;
if ( ssl_id . isNull ( ) )
2017-07-05 15:36:00 -04:00
{
2017-07-09 16:12:01 -04:00
std : : cerr < < " Invalid User location id: not found in list " ;
2017-07-05 15:36:00 -04:00
std : : cerr < < std : : endl ;
return RS_INIT_AUTH_FAILED ;
}
2017-07-11 17:32:22 -04:00
2018-07-24 17:47:32 -04:00
if ( RsAccounts : : SelectAccount ( ssl_id ) )
2017-07-11 17:32:22 -04:00
{
std : : cerr < < " Auto-selectng account ID " < < ssl_id < < std : : endl ;
return RS_INIT_HAVE_ACCOUNT ;
}
2007-11-14 22:18:48 -05:00
}
2010-04-08 08:02:46 -04:00
2017-07-16 10:01:08 -04:00
# ifdef RS_AUTOLOGIN
/* check that we have selected someone */
RsPeerId preferredId ;
2018-07-24 17:47:32 -04:00
bool existingUser = RsAccounts : : GetPreferredAccountId ( preferredId ) ;
2017-07-05 15:36:00 -04:00
2017-07-16 10:01:08 -04:00
if ( existingUser )
{
if ( RsLoginHandler : : getSSLPassword ( preferredId , false , rsInitConfig - > passwd ) )
2007-11-14 22:18:48 -05:00
{
2017-07-16 10:01:08 -04:00
RsInit : : setAutoLogin ( true ) ;
std : : cerr < < " Autologin has succeeded " < < std : : endl ;
return RS_INIT_HAVE_ACCOUNT ;
2007-11-14 22:18:48 -05:00
}
2017-07-16 10:01:08 -04:00
}
2017-07-11 17:32:22 -04:00
# endif
2017-07-16 10:01:08 -04:00
2018-09-19 15:28:26 -04:00
# ifdef RS_JSONAPI
if ( rsInitConfig - > jsonApiPort )
{
jsonApiServer = new JsonApiServer (
rsInitConfig - > jsonApiPort ,
rsInitConfig - > jsonApiBindAddress ) ;
jsonApiServer - > start ( " JSON API Server " ) ;
}
# endif // ifdef RS_JSONAPI
2017-07-16 10:01:08 -04:00
return RS_INIT_OK ;
2017-07-11 17:32:22 -04:00
}
2007-11-14 22:18:48 -05:00
2008-09-21 16:30:34 -04:00
2010-07-01 16:30:36 -04:00
/*
* To prevent several running instances from using the same directory
* simultaneously we have to use a global lock .
* We use a lock file on Unix systems .
*
* Return value :
* 0 : Success
* 1 : Another instance already has the lock
* 2 : Unexpected error
*/
2018-06-27 02:52:03 -04:00
RsInit : : LoadCertificateStatus RsInit : : LockConfigDirectory (
const std : : string & accountDir , std : : string & lockFilePath )
2010-07-01 16:30:36 -04:00
{
2011-05-15 08:42:55 -04:00
const std : : string lockFile = accountDir + " / " + " lock " ;
2011-08-12 16:02:00 -04:00
lockFilePath = lockFile ;
2010-09-29 20:27:23 -04:00
2018-06-27 02:52:03 -04:00
int rt = RsDirUtil : : createLockFile ( lockFile , rsInitConfig - > lockHandle ) ;
switch ( rt )
{
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 ;
}
2010-07-01 16:30:36 -04:00
}
/*
* Unlock the currently locked profile , if there is one .
* For Unix systems we simply close the handle of the lock file .
*/
void RsInit : : UnlockConfigDirectory ( )
{
2014-08-25 17:07:07 -04:00
RsDirUtil : : releaseLockFile ( rsInitConfig - > lockHandle ) ;
2010-07-01 16:30:36 -04:00
}
2008-02-09 07:47:45 -05:00
2013-09-23 16:55:34 -04:00
bool RsInit : : collectEntropy ( uint32_t n )
{
RAND_seed ( & n , 4 ) ;
return true ;
}
2008-01-25 02:58:29 -05:00
2009-07-30 17:27:47 -04:00
/***************************** FINAL LOADING OF SETUP *************************/
/* Login SSL */
2014-01-17 21:32:55 -05:00
bool RsInit : : LoadPassword ( const std : : string & inPwd )
2009-07-30 17:27:47 -04:00
{
2014-08-25 17:07:07 -04:00
rsInitConfig - > passwd = inPwd ;
2009-07-30 17:27:47 -04:00
return true ;
}
2018-06-27 02:52:03 -04:00
RsInit : : LoadCertificateStatus RsInit : : LockAndLoadCertificates (
bool autoLoginNT , std : : string & lockFilePath )
2010-07-01 16:30:36 -04:00
{
2018-07-24 17:47:32 -04:00
try
2014-01-17 21:32:55 -05:00
{
2018-07-24 17:47:32 -04:00
if ( ! RsAccounts : : lockPreferredAccount ( ) )
2018-08-22 10:59:42 -04:00
throw RsInit : : ERR_UNKOWN ; // invalid PreferredAccount.
2014-01-17 21:32:55 -05:00
2018-07-24 17:47:32 -04:00
// Logic that used to be external to RsInit...
RsPeerId accountId ;
if ( ! RsAccounts : : GetPreferredAccountId ( accountId ) )
2018-08-22 10:59:42 -04:00
throw RsInit : : ERR_UNKOWN ; // invalid PreferredAccount;
2014-11-08 14:31:16 -05:00
2018-07-24 17:47:32 -04:00
RsPgpId pgpId ;
std : : string pgpName , pgpEmail , location ;
2014-03-17 16:56:06 -04:00
2018-07-24 17:47:32 -04:00
if ( ! RsAccounts : : GetAccountDetails ( accountId , pgpId , pgpName , pgpEmail , location ) )
2018-08-22 10:59:42 -04:00
throw RsInit : : ERR_UNKOWN ; // invalid PreferredAccount;
2010-07-01 16:30:36 -04:00
2018-07-24 17:47:32 -04:00
if ( 0 = = AuthGPG : : getAuthGPG ( ) - > GPGInit ( pgpId ) )
2018-08-22 10:59:42 -04:00
throw RsInit : : ERR_UNKOWN ; // PGP Error.
2014-11-08 14:31:16 -05:00
2018-08-22 10:59:42 -04:00
LoadCertificateStatus retVal =
LockConfigDirectory ( RsAccounts : : AccountDirectory ( ) , lockFilePath ) ;
2014-11-08 14:31:16 -05:00
2018-07-24 17:47:32 -04:00
if ( retVal > 0 )
throw retVal ;
2010-07-01 16:30:36 -04:00
2018-07-24 17:47:32 -04:00
if ( LoadCertificates ( autoLoginNT ) ! = 1 )
{
UnlockConfigDirectory ( ) ;
2018-08-22 10:59:42 -04:00
throw RsInit : : ERR_UNKOWN ;
2018-07-24 17:47:32 -04:00
}
2018-08-22 10:59:42 -04:00
return RsInit : : OK ;
2018-07-24 17:47:32 -04:00
}
2018-08-22 10:59:42 -04:00
catch ( LoadCertificateStatus retVal )
2018-07-24 17:47:32 -04:00
{
RsAccounts : : unlockPreferredAccount ( ) ;
return retVal ;
}
2010-07-01 16:30:36 -04:00
}
2009-07-30 17:27:47 -04:00
2010-07-01 16:30:36 -04:00
/** *************************** FINAL LOADING OF SETUP *************************
2009-07-30 17:27:47 -04:00
* Requires :
* PGPid to be selected ( Password not required ) .
* CertId to be selected ( Password Required ) .
2010-07-01 16:30:36 -04:00
*
* Return value :
* 0 : unexpected error
* 1 : success
2009-07-30 17:27:47 -04:00
*/
int RsInit : : LoadCertificates ( bool autoLoginNT )
{
2014-03-17 16:56:06 -04:00
RsPeerId preferredId ;
2018-07-24 17:47:32 -04:00
if ( ! RsAccounts : : GetPreferredAccountId ( preferredId ) )
2014-01-17 21:32:55 -05:00
{
std : : cerr < < " No Account Selected " < < std : : endl ;
return 0 ;
}
2018-07-24 17:47:32 -04:00
if ( RsAccounts : : AccountPathCertFile ( ) = = " " )
2009-07-30 17:27:47 -04:00
{
std : : cerr < < " RetroShare needs a certificate " < < std : : endl ;
return 0 ;
}
2018-07-24 17:47:32 -04:00
if ( RsAccounts : : AccountPathKeyFile ( ) = = " " )
2009-07-30 17:27:47 -04:00
{
std : : cerr < < " RetroShare needs a key " < < std : : endl ;
return 0 ;
}
2009-08-18 08:43:19 -04:00
//check if password is already in memory
2011-02-01 18:27:53 -05:00
2014-08-25 17:07:07 -04:00
if ( rsInitConfig - > passwd = = " " ) {
if ( RsLoginHandler : : getSSLPassword ( preferredId , true , rsInitConfig - > passwd ) = = false ) {
2017-07-11 17:32:22 -04:00
# ifdef DEBUG_RSINIT
2011-08-05 16:45:09 -04:00
std : : cerr < < " RsLoginHandler::getSSLPassword() Failed! " ;
2017-07-11 17:32:22 -04:00
# endif
2011-08-05 16:45:09 -04:00
return 0 ;
}
} else {
2014-08-25 17:07:07 -04:00
if ( RsLoginHandler : : checkAndStoreSSLPasswdIntoGPGFile ( preferredId , rsInitConfig - > passwd ) = = false ) {
2011-08-05 16:45:09 -04:00
std : : cerr < < " RsLoginHandler::checkAndStoreSSLPasswdIntoGPGFile() Failed! " ;
return 0 ;
}
}
2010-04-08 08:02:46 -04:00
2018-07-24 17:47:32 -04:00
std : : cerr < < " rsAccounts->PathKeyFile() : " < < RsAccounts : : AccountPathKeyFile ( ) < < std : : endl ;
2010-04-08 08:02:46 -04:00
2018-07-24 17:47:32 -04:00
if ( 0 = = AuthSSL : : getAuthSSL ( ) - > InitAuth ( RsAccounts : : AccountPathCertFile ( ) . c_str ( ) , RsAccounts : : AccountPathKeyFile ( ) . c_str ( ) , rsInitConfig - > passwd . c_str ( ) ,
RsAccounts : : AccountLocationName ( ) ) )
2009-05-23 11:07:35 -04:00
{
std : : cerr < < " SSL Auth Failed! " ;
2011-02-01 18:27:53 -05:00
return 0 ;
2009-05-23 11:07:35 -04:00
}
2007-11-14 22:18:48 -05:00
2016-12-03 14:04:25 -05:00
# ifdef RS_AUTOLOGIN
2011-02-01 18:27:53 -05:00
if ( autoLoginNT )
2007-11-14 22:18:48 -05:00
{
2016-12-03 14:04:25 -05:00
std : : cerr < < " RetroShare will AutoLogin next time " < < std : : endl ;
2007-11-14 22:18:48 -05:00
2014-08-25 17:07:07 -04:00
RsLoginHandler : : enableAutoLogin ( preferredId , rsInitConfig - > passwd ) ;
rsInitConfig - > autoLogin = true ;
2007-11-14 22:18:48 -05:00
}
2016-12-03 16:22:13 -05:00
# else
( void ) autoLoginNT ;
2016-12-03 14:04:25 -05:00
# endif // RS_AUTOLOGIN
2007-11-14 22:18:48 -05:00
2011-02-01 18:27:53 -05:00
/* wipe out password */
2013-06-20 15:50:25 -04:00
// store pword to allow gxs use it to services' key their databases
// ideally gxs should have its own password
2014-08-25 17:07:07 -04:00
rsInitConfig - > gxs_passwd = rsInitConfig - > passwd ;
rsInitConfig - > passwd = " " ;
2014-01-17 21:32:55 -05:00
2018-07-24 17:47:32 -04:00
RsAccounts : : storeSelectedAccount ( ) ;
2011-02-01 18:27:53 -05:00
return 1 ;
}
2011-08-12 16:02:00 -04:00
2016-12-03 14:04:25 -05:00
# ifdef RS_AUTOLOGIN
2011-02-01 18:27:53 -05:00
bool RsInit : : RsClearAutoLogin ( )
{
2014-03-17 16:56:06 -04:00
RsPeerId preferredId ;
2018-08-01 17:04:20 -04:00
if ( ! RsAccounts : : GetPreferredAccountId ( preferredId ) )
2007-11-14 22:18:48 -05:00
{
2014-01-17 21:32:55 -05:00
std : : cerr < < " RsInit::RsClearAutoLogin() No Account Selected " < < std : : endl ;
return 0 ;
2007-11-14 22:18:48 -05:00
}
2014-01-17 21:32:55 -05:00
return RsLoginHandler : : clearAutoLogin ( preferredId ) ;
2009-07-30 17:27:47 -04:00
}
2016-12-03 14:04:25 -05:00
# endif // RS_AUTOLOGIN
2007-11-14 22:18:48 -05:00
2009-07-30 17:27:47 -04:00
2010-04-30 10:34:48 -04:00
bool RsInit : : isPortable ( )
{
2010-05-02 18:28:33 -04:00
# ifdef WINDOWS_SYS
2014-08-25 17:07:07 -04:00
return rsInitConfig - > portable ;
2010-05-02 18:28:33 -04:00
# else
return false ;
# endif
2010-04-30 10:34:48 -04:00
}
2010-10-07 07:17:42 -04:00
bool RsInit : : isWindowsXP ( )
{
# ifdef WINDOWS_SYS
2014-08-25 17:07:07 -04:00
return rsInitConfig - > isWindowsXP ;
2010-10-07 07:17:42 -04:00
# else
return false ;
# endif
}
2014-01-17 21:32:55 -05:00
2011-04-14 17:59:51 -04:00
bool RsInit : : getStartMinimised ( )
2009-07-30 17:27:47 -04:00
{
2014-08-25 17:07:07 -04:00
return rsInitConfig - > startMinimised ;
2009-07-30 17:27:47 -04:00
}
2010-04-08 08:02:46 -04:00
int RsInit : : getSslPwdLen ( ) {
return SSLPWD_LEN ;
}
bool RsInit : : getAutoLogin ( ) {
2014-08-25 17:07:07 -04:00
return rsInitConfig - > autoLogin ;
2010-04-08 08:02:46 -04:00
}
void RsInit : : setAutoLogin ( bool autoLogin ) {
2014-08-25 17:07:07 -04:00
rsInitConfig - > autoLogin = autoLogin ;
2010-04-08 08:02:46 -04:00
}
2009-07-30 17:27:47 -04:00
2013-09-08 22:10:49 -04:00
/* Setup Hidden Location; */
2016-10-09 08:32:52 -04:00
void RsInit : : SetHiddenLocation ( const std : : string & hiddenaddress , uint16_t port , bool useBob )
2013-09-08 22:10:49 -04:00
{
/* parse the bugger (todo) */
2014-08-25 17:07:07 -04:00
rsInitConfig - > hiddenNodeSet = true ;
rsInitConfig - > hiddenNodeAddress = hiddenaddress ;
rsInitConfig - > hiddenNodePort = port ;
2016-10-09 08:32:52 -04:00
rsInitConfig - > hiddenNodeI2PBOB = useBob ;
2013-09-08 22:10:49 -04:00
}
2009-07-30 17:27:47 -04:00
/*
*
* Init Part of RsServer . . . needs the private
* variables so in the same file .
*
*/
# include <unistd.h>
//#include <getopt.h>
# include "ft/ftserver.h"
# include "ft/ftcontroller.h"
2010-08-06 05:40:23 -04:00
# include "retroshare/rsiface.h"
# include "retroshare/rsturtle.h"
2009-07-30 17:27:47 -04:00
/* global variable now points straight to
* ft / code so variable defined here .
*/
RsFiles * rsFiles = NULL ;
RsTurtle * rsTurtle = NULL ;
2015-10-04 23:14:49 -04:00
RsReputations * rsReputations = NULL ;
2014-03-29 10:18:05 -04:00
# ifdef ENABLE_GROUTER
2013-11-02 10:35:33 -04:00
RsGRouter * rsGRouter = NULL ;
# endif
2009-07-30 17:27:47 -04:00
# include "pqi/pqipersongrp.h"
# include "pqi/pqisslpersongrp.h"
# include "pqi/pqiloopback.h"
# include "pqi/p3cfgmgr.h"
2011-09-29 05:20:09 -04:00
# include "pqi/p3historymgr.h"
2009-07-30 17:27:47 -04:00
# include "util/rsdebug.h"
# include "util/rsdir.h"
2011-07-09 20:41:39 -04:00
# include "util/rsrandom.h"
2011-12-13 11:19:37 -05:00
# ifdef RS_ENABLE_ZEROCONF
# include "zeroconf/p3zeroconf.h"
2012-01-14 11:41:00 -05:00
# endif
# ifdef RS_ENABLE_ZCNATASSIST
# include "zeroconf/p3zcnatassist.h"
2011-12-13 11:19:37 -05:00
# else
2012-10-28 12:51:00 -04:00
# ifdef RS_USE_LIBUPNP
# include "upnp/upnphandler_linux.h"
# else
# include "upnp/upnphandler_miniupnp.h"
# endif
2011-12-13 11:19:37 -05:00
# endif
2016-10-09 08:32:52 -04:00
# include "services/autoproxy/p3i2pbob.h"
# include "services/autoproxy/rsautoproxymonitor.h"
2015-10-04 23:14:49 -04:00
# include "services/p3gxsreputation.h"
2014-03-21 23:53:44 -04:00
# include "services/p3serviceinfo.h"
2013-09-28 04:09:59 -04:00
# include "services/p3heartbeat.h"
# include "services/p3discovery2.h"
2009-07-30 17:27:47 -04:00
# include "services/p3msgservice.h"
2010-04-15 06:47:48 -04:00
# include "services/p3statusservice.h"
2014-11-11 11:10:54 -05:00
2009-07-30 17:27:47 -04:00
# include "turtle/p3turtle.h"
2014-11-11 11:10:54 -05:00
# include "chat/p3chatservice.h"
2010-06-24 14:06:10 -04:00
2012-12-16 10:04:52 -05:00
# ifdef RS_ENABLE_GXS
// NEW GXS SYSTEMS.
2012-08-06 17:00:38 -04:00
# include "gxs/rsdataservice.h"
# include "gxs/rsgxsnetservice.h"
2013-02-28 16:58:38 -05:00
# include "retroshare/rsgxsflags.h"
2012-08-06 17:00:38 -04:00
2014-04-27 09:14:07 -04:00
# include "pgp/pgpauxutils.h"
2012-02-13 13:22:35 -05:00
# include "services/p3idservice.h"
2012-12-16 10:04:52 -05:00
# include "services/p3gxscircles.h"
# include "services/p3wiki.h"
2012-07-01 19:00:54 -04:00
# include "services/p3posted.h"
2012-12-16 10:04:52 -05:00
# include "services/p3photoservice.h"
# include "services/p3gxsforums.h"
2013-03-04 15:26:48 -05:00
# include "services/p3gxschannels.h"
2012-12-16 10:04:52 -05:00
# include "services/p3wire.h"
# endif // RS_ENABLE_GXS
2012-02-04 09:16:39 -05:00
2011-08-03 13:43:26 -04:00
2009-07-30 17:27:47 -04:00
# include <list>
# include <string>
2009-05-23 11:07:35 -04:00
2009-07-30 17:27:47 -04:00
// for blocking signals
# include <signal.h>
2009-05-23 11:07:35 -04:00
2009-07-30 17:27:47 -04:00
/* Implemented Rs Interfaces */
# include "rsserver/p3face.h"
# include "rsserver/p3peers.h"
# include "rsserver/p3msgs.h"
2010-04-15 06:47:48 -04:00
# include "rsserver/p3status.h"
2011-09-29 05:20:09 -04:00
# include "rsserver/p3history.h"
2011-07-11 14:48:56 -04:00
# include "rsserver/p3serverconfig.h"
2009-05-23 11:07:35 -04:00
2009-07-30 17:27:47 -04:00
# include "pqi/p3notify.h" // HACK - moved to pqi for compilation order.
2009-05-23 11:07:35 -04:00
2011-07-09 14:39:34 -04:00
# include "pqi/p3peermgr.h"
# include "pqi/p3linkmgr.h"
# include "pqi/p3netmgr.h"
2010-07-31 14:14:10 -04:00
# include "tcponudp/tou.h"
# include "tcponudp/rsudpstack.h"
2011-07-09 14:39:34 -04:00
2010-07-31 14:14:10 -04:00
# ifdef RS_USE_BITDHT
# include "dht/p3bitdht.h"
2016-06-21 07:55:23 -04:00
# ifdef RS_USE_DHT_STUNNER
2011-07-09 20:41:39 -04:00
# include "dht/stunaddrassist.h"
2016-06-21 07:55:23 -04:00
# endif // RS_USE_DHT_STUNNER
2011-07-09 20:41:39 -04:00
2010-07-31 14:14:10 -04:00
# include "udp/udpstack.h"
2011-06-29 14:02:44 -04:00
# include "tcponudp/udppeer.h"
# include "tcponudp/udprelay.h"
2010-07-31 14:14:10 -04:00
# endif
2009-05-23 11:07:35 -04:00
2009-07-30 17:27:47 -04:00
/****
2011-08-03 13:43:26 -04:00
* # define RS_RELEASE 1
2013-09-29 03:11:02 -04:00
* # define RS_RTT 1
2009-07-30 17:27:47 -04:00
* * * */
2009-05-23 11:07:35 -04:00
2013-09-29 03:11:02 -04:00
# define RS_RELEASE 1
# define RS_RTT 1
# ifdef RS_RTT
# include "services/p3rtt.h"
# endif
2009-05-23 11:07:35 -04:00
2011-11-24 19:58:01 -05:00
# include "services/p3banlist.h"
2012-06-21 19:23:46 -04:00
# include "services/p3bwctrl.h"
2013-12-22 12:10:56 -05:00
# ifdef SERVICES_DSDV
2011-11-24 19:58:01 -05:00
# include "services/p3dsdv.h"
2013-12-22 12:10:56 -05:00
# endif
2011-11-24 19:58:01 -05:00
2014-01-07 17:51:22 -05:00
RsControl * RsControl : : instance ( )
2009-07-30 17:27:47 -04:00
{
2017-02-25 18:46:02 -05:00
static RsServer rsicontrol ;
return & rsicontrol ;
2009-07-30 17:27:47 -04:00
}
2009-07-12 12:11:09 -04:00
2017-02-25 18:46:02 -05:00
2009-07-30 17:27:47 -04:00
/*
* The Real RetroShare Startup Function .
*/
int RsServer : : StartupRetroShare ( )
{
2018-07-25 05:37:40 -04:00
RsPeerId ownId = AuthSSL : : getAuthSSL ( ) - > OwnId ( ) ;
std : : cerr < < " ======================================================================== " < < std : : endl ;
std : : cerr < < " == RsInit:: starting up Retroshare core == " < < std : : endl ;
std : : cerr < < " == == " < < std : : endl ;
std : : cerr < < " == Account/SSL ID : " < < ownId < < " == " < < std : : endl ;
std : : cerr < < " == Node type : " < < ( RsAccounts : : isHiddenNode ( ) ? " Hidden " : " Normal " ) < < " == " < < std : : endl ;
if ( RsAccounts : : isHiddenNode ( ) )
std : : cerr < < " == Tor/I2P configuration : " < < ( RsAccounts : : isTorAuto ( ) ? " Tor Auto " : " Manual " ) < < " == " < < std : : endl ;
std : : cerr < < " ======================================================================== " < < std : : endl ;
2009-07-30 17:27:47 -04:00
/**************************************************************************/
/* STARTUP procedure */
/**************************************************************************/
/**************************************************************************/
/* (1) Load up own certificate (DONE ALREADY) - just CHECK */
/**************************************************************************/
2009-05-23 11:07:35 -04:00
2015-03-25 04:19:45 -04:00
if ( 1 ! = AuthSSL : : getAuthSSL ( ) - > InitAuth ( NULL , NULL , NULL , " " ) )
2007-11-14 22:18:48 -05:00
{
2009-07-30 17:27:47 -04:00
std : : cerr < < " main() - Fatal Error..... " < < std : : endl ;
std : : cerr < < " Invalid Certificate configuration! " < < std : : endl ;
std : : cerr < < std : : endl ;
2011-12-06 18:00:42 -05:00
return false ;
2007-11-14 22:18:48 -05:00
}
2009-07-30 17:27:47 -04:00
/**************************************************************************/
/* Any Initial Configuration (Commandline Options) */
/**************************************************************************/
2007-11-14 22:18:48 -05:00
2009-07-30 17:27:47 -04:00
/* set the debugging to crashMode */
2012-09-09 09:59:21 -04:00
std : : cerr < < " set the debugging to crashMode. " < < std : : endl ;
2014-08-25 17:07:07 -04:00
if ( ( ! rsInitConfig - > haveLogFile ) & & ( ! rsInitConfig - > outStderr ) )
2007-11-14 22:18:48 -05:00
{
2018-07-24 17:47:32 -04:00
std : : string crashfile = RsAccounts : : AccountDirectory ( ) ;
2014-01-17 21:32:55 -05:00
crashfile + = " / " + configLogFileName ;
2009-07-30 17:27:47 -04:00
setDebugCrashMode ( crashfile . c_str ( ) ) ;
2007-11-14 22:18:48 -05:00
}
2009-07-30 17:27:47 -04:00
unsigned long flags = 0 ;
2014-08-25 17:07:07 -04:00
if ( rsInitConfig - > udpListenerOnly )
2009-07-30 17:27:47 -04:00
{
flags | = PQIPERSON_NO_LISTENER ;
}
2007-11-14 22:18:48 -05:00
2015-06-03 19:03:03 -04:00
/* check account directory */
2018-07-24 17:47:32 -04:00
if ( ! RsAccounts : : checkCreateAccountDirectory ( ) )
2015-06-03 19:03:03 -04:00
{
std : : cerr < < " RsServer::StartupRetroShare() - Fatal Error..... " < < std : : endl ;
std : : cerr < < " checkAccount failed! " < < std : : endl ;
std : : cerr < < std : : endl ;
return 0 ;
}
2009-07-30 17:27:47 -04:00
/**************************************************************************/
// Load up Certificates, and Old Configuration (if present)
2012-09-09 09:59:21 -04:00
std : : cerr < < " Load up Certificates, and Old Configuration (if present). " < < std : : endl ;
2008-09-21 16:30:34 -04:00
2018-07-24 17:47:32 -04:00
std : : string emergencySaveDir = RsAccounts : : AccountDirectory ( ) ;
std : : string emergencyPartialsDir = RsAccounts : : AccountDirectory ( ) ;
2010-06-26 08:31:24 -04:00
if ( emergencySaveDir ! = " " )
2007-11-14 22:18:48 -05:00
{
2009-07-30 17:27:47 -04:00
emergencySaveDir + = " / " ;
emergencyPartialsDir + = " / " ;
}
emergencySaveDir + = " Downloads " ;
emergencyPartialsDir + = " Partials " ;
2007-11-14 22:18:48 -05:00
2013-09-08 22:10:49 -04:00
/**************************************************************************/
/* setup Configuration */
/**************************************************************************/
std : : cerr < < " Load Configuration " < < std : : endl ;
2018-07-24 17:47:32 -04:00
mConfigMgr = new p3ConfigMgr ( RsAccounts : : AccountDirectory ( ) ) ;
2013-09-08 22:10:49 -04:00
mGeneralConfig = new p3GeneralConfig ( ) ;
2014-01-17 21:32:55 -05:00
// Get configuration options from rsAccounts.
bool isHiddenNode = false ;
bool isFirstTimeRun = false ;
2018-07-24 17:47:32 -04:00
bool isTorAuto = false ;
RsAccounts : : getCurrentAccountOptions ( isHiddenNode , isTorAuto , isFirstTimeRun ) ;
2013-09-08 22:10:49 -04:00
2009-07-30 17:27:47 -04:00
/**************************************************************************/
/* setup classes / structures */
/**************************************************************************/
2012-09-09 09:59:21 -04:00
std : : cerr < < " setup classes / structures " < < std : : endl ;
2007-11-14 22:18:48 -05:00
2011-09-29 05:20:09 -04:00
/* History Manager */
mHistoryMgr = new p3HistoryMgr ( ) ;
2012-12-26 13:12:19 -05:00
mPeerMgr = new p3PeerMgrIMPL ( AuthSSL : : getAuthSSL ( ) - > OwnId ( ) ,
2013-09-08 22:10:49 -04:00
AuthGPG : : getAuthGPG ( ) - > getGPGOwnId ( ) ,
AuthGPG : : getAuthGPG ( ) - > getGPGOwnName ( ) ,
AuthSSL : : getAuthSSL ( ) - > getOwnLocation ( ) ) ;
2011-07-13 10:22:25 -04:00
mNetMgr = new p3NetMgrIMPL ( ) ;
mLinkMgr = new p3LinkMgrIMPL ( mPeerMgr , mNetMgr ) ;
2011-10-08 13:47:36 -04:00
2012-09-09 09:59:21 -04:00
/* Setup Notify Early - So we can use it. */
rsPeers = new p3Peers ( mLinkMgr , mPeerMgr , mNetMgr ) ;
2011-10-08 13:47:36 -04:00
2012-02-14 17:55:14 -05:00
mPeerMgr - > setManagers ( mLinkMgr , mNetMgr ) ;
2011-07-09 14:39:34 -04:00
mNetMgr - > setManagers ( mPeerMgr , mLinkMgr ) ;
2016-10-09 08:32:52 -04:00
rsAutoProxyMonitor * autoProxy = rsAutoProxyMonitor : : instance ( ) ;
mI2pBob = new p3I2pBob ( mPeerMgr ) ;
autoProxy - > addProxy ( autoProxyType : : I2PBOB , mI2pBob ) ;
2012-09-09 09:59:21 -04:00
//load all the SSL certs as friends
// std::list<std::string> sslIds;
// AuthSSL::getAuthSSL()->getAuthenticatedList(sslIds);
2014-10-24 18:07:26 -04:00
// for (std::list<std::string>::iterator sslIdsIt = sslIds.begin(); sslIdsIt != sslIds.end(); ++sslIdsIt) {
2012-09-09 09:59:21 -04:00
// mConnMgr->addFriend(*sslIdsIt);
// }
2014-08-25 17:07:07 -04:00
//p3DhtMgr *mDhtMgr = new OpenDHTMgr(ownId, mConnMgr, rsInitConfig->configDir);
2012-09-09 09:59:21 -04:00
/**************************** BITDHT ***********************************/
2010-07-31 14:14:10 -04:00
// Make up an address. XXX
struct sockaddr_in tmpladdr ;
sockaddr_clear ( & tmpladdr ) ;
2014-08-25 17:07:07 -04:00
tmpladdr . sin_port = htons ( rsInitConfig - > port ) ;
2012-01-07 06:28:00 -05:00
2018-07-25 05:37:40 -04:00
rsUdpStack * mDhtStack = NULL ;
2012-01-07 06:28:00 -05:00
2018-07-25 05:37:40 -04:00
if ( ! RsAccounts : : isHiddenNode ( ) )
{
2012-01-07 06:28:00 -05:00
# ifdef LOCALNET_TESTING
2018-07-25 05:37:40 -04:00
mDhtStack = new rsUdpStack ( UDP_TEST_RESTRICTED_LAYER , tmpladdr ) ;
2012-01-07 06:28:00 -05:00
2018-07-25 05:37:40 -04:00
/* parse portRestrictions */
unsigned int lport , uport ;
2012-01-07 06:28:00 -05:00
2018-07-25 05:37:40 -04:00
if ( doPortRestrictions )
2012-01-07 06:28:00 -05:00
{
2018-07-25 05:37:40 -04:00
if ( 2 = = sscanf ( portRestrictions . c_str ( ) , " %u-%u " , & lport , & uport ) )
{
std : : cerr < < " Adding Port Restriction ( " < < lport < < " - " < < uport < < " ) " ;
std : : cerr < < std : : endl ;
}
else
{
std : : cerr < < " Failed to parse Port Restrictions ... exiting " ;
std : : cerr < < std : : endl ;
exit ( 1 ) ;
}
2012-01-07 06:28:00 -05:00
2018-07-25 05:37:40 -04:00
RestrictedUdpLayer * url = ( RestrictedUdpLayer * ) mDhtStack - > getUdpLayer ( ) ;
url - > addRestrictedPortRange ( lport , uport ) ;
}
2017-07-28 06:56:42 -04:00
# else //LOCALNET_TESTING
# ifdef RS_USE_BITDHT
2018-07-25 05:37:40 -04:00
mDhtStack = new rsUdpStack ( tmpladdr ) ;
2012-01-07 06:28:00 -05:00
# endif
2017-07-28 06:56:42 -04:00
# endif //LOCALNET_TESTING
2018-07-25 05:37:40 -04:00
}
2010-07-31 14:14:10 -04:00
# ifdef RS_USE_BITDHT
2010-10-28 18:59:46 -04:00
# define BITDHT_BOOTSTRAP_FILENAME "bdboot.txt"
2015-05-25 10:02:45 -04:00
# define BITDHT_FILTERED_IP_FILENAME "bdfilter.txt"
2010-10-28 18:59:46 -04:00
2018-07-24 17:47:32 -04:00
std : : string bootstrapfile = RsAccounts : : AccountDirectory ( ) ;
2010-10-01 15:48:53 -04:00
if ( bootstrapfile ! = " " )
bootstrapfile + = " / " ;
2010-10-28 18:59:46 -04:00
bootstrapfile + = BITDHT_BOOTSTRAP_FILENAME ;
2018-07-24 17:47:32 -04:00
std : : string filteredipfile = RsAccounts : : AccountDirectory ( ) ;
2015-05-25 10:02:45 -04:00
if ( filteredipfile ! = " " )
filteredipfile + = " / " ;
filteredipfile + = BITDHT_FILTERED_IP_FILENAME ;
std : : cerr < < " Checking for DHT bootstrap file: " < < bootstrapfile < < std : : endl ;
2010-10-28 18:59:46 -04:00
/* check if bootstrap file exists...
* if not . . . copy from dataDirectory
*/
2014-03-29 10:18:05 -04:00
uint64_t tmp_size ;
if ( ! RsDirUtil : : checkFile ( bootstrapfile , tmp_size , true ) )
2010-10-28 18:59:46 -04:00
{
2018-01-29 07:26:43 -05:00
std : : cerr < < " DHT bootstrap file not in ConfigDir: " < < bootstrapfile
< < std : : endl ;
# ifdef __ANDROID__
QFile bdbootRF ( " assets:/values/bdboot.txt " ) ;
if ( ! bdbootRF . open ( QIODevice : : ReadOnly | QIODevice : : Text ) )
std : : cerr < < __PRETTY_FUNCTION__
< < " bdbootRF(assets:/values/bdboot.txt).open(...) fail: "
< < bdbootRF . errorString ( ) . toStdString ( ) < < std : : endl ;
else
{
QFile bdbootCF ( QString : : fromStdString ( bootstrapfile ) ) ;
if ( ! bdbootCF . open ( QIODevice : : WriteOnly | QIODevice : : Text ) )
std : : cerr < < __PRETTY_FUNCTION__ < < " bdbootCF( "
< < bootstrapfile < < " ).open(...) fail: "
< < bdbootRF . errorString ( ) . toStdString ( ) < < std : : endl ;
else
{
bdbootCF . write ( bdbootRF . readAll ( ) ) ;
bdbootCF . close ( ) ;
std : : cerr < < " Installed DHT bootstrap file not in ConfigDir: "
< < bootstrapfile < < std : : endl ;
}
bdbootRF . close ( ) ;
}
# else
2018-07-24 17:47:32 -04:00
std : : string installfile = RsAccounts : : systemDataDirectory ( ) ;
2011-05-15 08:42:55 -04:00
installfile + = " / " ;
2010-10-28 18:59:46 -04:00
installfile + = BITDHT_BOOTSTRAP_FILENAME ;
std : : cerr < < " Checking for Installation DHT bootstrap file " < < installfile < < std : : endl ;
2014-03-29 10:18:05 -04:00
if ( ( installfile ! = " " ) & & ( RsDirUtil : : checkFile ( installfile , tmp_size ) ) )
2010-10-28 18:59:46 -04:00
{
std : : cerr < < " Copying Installation DHT bootstrap file... " < < std : : endl ;
if ( RsDirUtil : : copyFile ( installfile , bootstrapfile ) )
{
std : : cerr < < " Installed DHT bootstrap file in configDir " < < std : : endl ;
}
else
{
std : : cerr < < " Failed Installation DHT bootstrap file... " < < std : : endl ;
}
}
else
{
std : : cerr < < " No Installation DHT bootstrap file to copy " < < std : : endl ;
}
2018-01-29 07:26:43 -05:00
# endif // def __ANDROID__
2010-10-28 18:59:46 -04:00
}
2010-07-31 14:14:10 -04:00
2011-06-29 14:02:44 -04:00
/* construct the rest of the stack, important to build them in the correct order! */
/* MOST OF THIS IS COMMENTED OUT UNTIL THE REST OF libretroshare IS READY FOR IT! */
2018-07-25 05:37:40 -04:00
p3BitDht * mBitDht = NULL ;
rsDht = NULL ;
rsFixedUdpStack * mProxyStack = NULL ;
if ( ! RsAccounts : : isHiddenNode ( ) )
{
UdpSubReceiver * udpReceivers [ RSUDP_NUM_TOU_RECVERS ] ;
int udpTypes [ RSUDP_NUM_TOU_RECVERS ] ;
2011-06-29 14:02:44 -04:00
2016-06-21 07:55:23 -04:00
# ifdef RS_USE_DHT_STUNNER
2018-07-25 05:37:40 -04:00
// FIRST DHT STUNNER.
UdpStunner * mDhtStunner = new UdpStunner ( mDhtStack ) ;
mDhtStunner - > setTargetStunPeriod ( 300 ) ; /* slow (5mins) */
mDhtStack - > addReceiver ( mDhtStunner ) ;
2011-06-29 14:02:44 -04:00
2012-01-07 06:28:00 -05:00
# ifdef LOCALNET_TESTING
2018-07-25 05:37:40 -04:00
mDhtStunner - > SetAcceptLocalNet ( ) ;
2012-01-07 06:28:00 -05:00
# endif
2016-06-21 07:55:23 -04:00
# endif // RS_USE_DHT_STUNNER
2012-01-07 06:28:00 -05:00
2018-07-25 05:37:40 -04:00
// NEXT BITDHT.
2015-05-27 17:30:40 -04:00
2018-07-25 05:37:40 -04:00
mBitDht = new p3BitDht ( ownId , mLinkMgr , mNetMgr , mDhtStack , bootstrapfile , filteredipfile ) ;
2012-09-09 09:59:21 -04:00
2018-07-25 05:37:40 -04:00
// NEXT THE RELAY (NEED to keep a reference for installing RELAYS)
UdpRelayReceiver * mRelay = new UdpRelayReceiver ( mDhtStack ) ;
udpReceivers [ RSUDP_TOU_RECVER_RELAY_IDX ] = mRelay ; /* RELAY Connections (DHT Port) */
udpTypes [ RSUDP_TOU_RECVER_RELAY_IDX ] = TOU_RECEIVER_TYPE_UDPRELAY ;
mDhtStack - > addReceiver ( udpReceivers [ RSUDP_TOU_RECVER_RELAY_IDX ] ) ;
2012-09-09 09:59:21 -04:00
2018-07-25 05:37:40 -04:00
// LAST ON THIS STACK IS STANDARD DIRECT TOU
udpReceivers [ RSUDP_TOU_RECVER_DIRECT_IDX ] = new UdpPeerReceiver ( mDhtStack ) ; /* standard DIRECT Connections (DHT Port) */
udpTypes [ RSUDP_TOU_RECVER_DIRECT_IDX ] = TOU_RECEIVER_TYPE_UDPPEER ;
mDhtStack - > addReceiver ( udpReceivers [ RSUDP_TOU_RECVER_DIRECT_IDX ] ) ;
2011-06-29 14:02:44 -04:00
2018-07-25 05:37:40 -04:00
/* install external Pointer for Interface */
rsDht = mBitDht ;
2012-09-09 09:59:21 -04:00
2018-07-25 05:37:40 -04:00
// NOW WE BUILD THE SECOND STACK.
// Create the Second UdpStack... Port should be random (but openable!).
// We do this by binding to xx.xx.xx.xx:0 which which gives us a random port.
struct sockaddr_in sndladdr ;
sockaddr_clear ( & sndladdr ) ;
2012-01-11 05:24:37 -05:00
2013-09-24 01:30:01 -04:00
# ifdef LOCALNET_TESTING
2018-07-25 05:37:40 -04:00
// // HACK Proxy Port near Dht Port - For Relay Testing.
// uint16_t rndport = rsInitConfig->port + 3;
// sndladdr.sin_port = htons(rndport);
2012-01-07 06:28:00 -05:00
2018-07-25 05:37:40 -04:00
mProxyStack = new rsFixedUdpStack ( UDP_TEST_RESTRICTED_LAYER , sndladdr ) ;
2012-01-07 06:28:00 -05:00
2018-07-25 05:37:40 -04:00
/* portRestrictions already parsed */
if ( doPortRestrictions )
{
RestrictedUdpLayer * url = ( RestrictedUdpLayer * ) mProxyStack - > getUdpLayer ( ) ;
url - > addRestrictedPortRange ( lport , uport ) ;
}
2012-01-07 06:28:00 -05:00
# else
2018-07-25 05:37:40 -04:00
mProxyStack = new rsFixedUdpStack ( sndladdr ) ;
2012-01-07 06:28:00 -05:00
# endif
2011-06-29 14:02:44 -04:00
2016-06-21 07:55:23 -04:00
# ifdef RS_USE_DHT_STUNNER
2018-07-25 05:37:40 -04:00
// FIRSTLY THE PROXY STUNNER.
UdpStunner * mProxyStunner = new UdpStunner ( mProxyStack ) ;
mProxyStunner - > setTargetStunPeriod ( 300 ) ; /* slow (5mins) */
mProxyStack - > addReceiver ( mProxyStunner ) ;
2012-01-07 06:28:00 -05:00
# ifdef LOCALNET_TESTING
2018-07-25 05:37:40 -04:00
mProxyStunner - > SetAcceptLocalNet ( ) ;
2012-01-07 06:28:00 -05:00
# endif
2016-06-21 07:55:23 -04:00
# endif // RS_USE_DHT_STUNNER
2012-01-07 06:28:00 -05:00
2012-09-09 09:59:21 -04:00
2018-07-25 05:37:40 -04:00
// FINALLY THE PROXY UDP CONNECTIONS
udpReceivers [ RSUDP_TOU_RECVER_PROXY_IDX ] = new UdpPeerReceiver ( mProxyStack ) ; /* PROXY Connections (Alt UDP Port) */
udpTypes [ RSUDP_TOU_RECVER_PROXY_IDX ] = TOU_RECEIVER_TYPE_UDPPEER ;
mProxyStack - > addReceiver ( udpReceivers [ RSUDP_TOU_RECVER_PROXY_IDX ] ) ;
2012-09-09 09:59:21 -04:00
2018-07-25 05:37:40 -04:00
// REAL INITIALISATION - WITH THREE MODES
tou_init ( ( void * * ) udpReceivers , udpTypes , RSUDP_NUM_TOU_RECVERS ) ;
2010-07-31 14:14:10 -04:00
2016-06-21 07:55:23 -04:00
# ifdef RS_USE_DHT_STUNNER
2018-07-25 05:37:40 -04:00
mBitDht - > setupConnectBits ( mDhtStunner , mProxyStunner , mRelay ) ;
2016-06-21 07:55:23 -04:00
# else // RS_USE_DHT_STUNNER
2018-07-25 05:37:40 -04:00
mBitDht - > setupConnectBits ( mRelay ) ;
2016-06-21 07:55:23 -04:00
# endif // RS_USE_DHT_STUNNER
2012-09-09 09:59:21 -04:00
2016-06-21 07:55:23 -04:00
# ifdef RS_USE_DHT_STUNNER
2018-07-25 05:37:40 -04:00
mNetMgr - > setAddrAssist ( new stunAddrAssist ( mDhtStunner ) , new stunAddrAssist ( mProxyStunner ) ) ;
2016-06-21 07:55:23 -04:00
# endif // RS_USE_DHT_STUNNER
2018-07-25 05:37:40 -04:00
// #else //RS_USE_BITDHT
// /* install NULL Pointer for rsDht Interface */
// rsDht = NULL;
2017-07-28 06:56:42 -04:00
# endif //RS_USE_BITDHT
2018-07-25 05:37:40 -04:00
}
2010-07-31 14:14:10 -04:00
2012-09-09 09:59:21 -04:00
/**************************** BITDHT ***********************************/
2010-07-31 14:14:10 -04:00
2014-03-28 23:57:44 -04:00
p3ServiceControl * serviceCtrl = new p3ServiceControl ( mLinkMgr ) ;
2014-03-22 02:28:59 -04:00
rsServiceControl = serviceCtrl ;
2007-11-14 22:18:48 -05:00
2015-06-17 04:49:43 -04:00
pqih = new pqisslpersongrp ( serviceCtrl , flags , mPeerMgr ) ;
2009-07-30 17:27:47 -04:00
//pqih = new pqipersongrpDummy(none, flags);
2007-11-14 22:18:48 -05:00
2017-04-20 14:54:51 -04:00
serviceCtrl - > setServiceServer ( pqih ) ;
2009-07-30 17:27:47 -04:00
/****** New Ft Server **** !!! */
2016-09-18 12:34:39 -04:00
ftServer * ftserver = new ftServer ( mPeerMgr , serviceCtrl ) ;
2018-07-24 17:47:32 -04:00
ftserver - > setConfigDirectory ( RsAccounts : : AccountDirectory ( ) ) ;
2007-11-14 22:18:48 -05:00
2014-01-07 17:51:22 -05:00
ftserver - > SetupFtServer ( ) ;
2009-07-30 17:27:47 -04:00
2011-07-09 14:39:34 -04:00
/* setup any extra bits (Default Paths) */
ftserver - > setPartialsDirectory ( emergencyPartialsDir ) ;
ftserver - > setDownloadDirectory ( emergencySaveDir ) ;
2009-07-30 17:27:47 -04:00
/* This should be set by config ... there is no default */
2011-07-09 14:39:34 -04:00
//ftserver->setSharedDirectories(fileList);
2012-09-09 09:59:21 -04:00
2009-07-30 17:27:47 -04:00
rsFiles = ftserver ;
2008-09-21 16:30:34 -04:00
2011-06-16 17:59:26 -04:00
std : : vector < std : : string > plugins_directories ;
2011-06-17 15:59:01 -04:00
2016-03-19 13:58:00 -04:00
# ifdef __APPLE__
2018-07-27 09:15:04 -04:00
plugins_directories . push_back ( RsAccounts : : systemDataDirectory ( ) ) ;
2016-03-19 13:58:00 -04:00
# endif
2017-08-17 19:37:39 -04:00
# if !defined(WINDOWS_SYS) && defined(PLUGIN_DIR)
2015-09-06 08:19:21 -04:00
plugins_directories . push_back ( std : : string ( PLUGIN_DIR ) ) ;
2011-06-17 15:59:01 -04:00
# endif
2018-07-24 17:47:32 -04:00
std : : string extensions_dir = RsAccounts : : ConfigDirectory ( ) + " /extensions6/ " ;
2013-09-06 18:04:47 -04:00
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 ;
2011-06-23 14:55:15 -04:00
# ifdef DEBUG_PLUGIN_SYSTEM
2011-06-16 17:59:26 -04:00
plugins_directories . push_back ( " . " ) ; // this list should be saved/set to some correct value.
2012-09-09 09:59:21 -04:00
// possible entries include: /usr/lib/retroshare, ~/.retroshare/extensions/, etc.
2011-06-23 14:55:15 -04:00
# endif
2011-06-16 17:59:26 -04:00
2014-08-25 17:07:07 -04:00
mPluginsManager = new RsPluginManager ( rsInitConfig - > main_executable_hash ) ;
2011-06-16 17:59:26 -04:00
rsPlugins = mPluginsManager ;
2011-07-05 16:29:07 -04:00
mConfigMgr - > addConfiguration ( " plugins.cfg " , mPluginsManager ) ;
mPluginsManager - > loadConfiguration ( ) ;
2011-06-16 17:59:26 -04:00
// These are needed to load plugins: plugin devs might want to know the place of
// cache directories, get pointers to cache strapper, or access ownId()
//
2014-04-20 10:20:13 -04:00
mPluginsManager - > setServiceControl ( serviceCtrl ) ;
2011-06-16 17:59:26 -04:00
// Now load the plugins. This parses the available SO/DLL files for known symbols.
//
mPluginsManager - > loadPlugins ( plugins_directories ) ;
2011-12-22 15:17:59 -05:00
// Also load some plugins explicitly. This is helpful for
// - developping plugins
//
std : : vector < RsPlugin * > programatically_inserted_plugins ;
2012-09-09 09:59:21 -04:00
2011-12-22 15:17:59 -05:00
// Push your own plugins into this list, before the call:
//
// programatically_inserted_plugins.push_back(myCoolPlugin) ;
//
mPluginsManager - > loadPlugins ( programatically_inserted_plugins ) ;
2018-09-19 15:28:26 -04:00
# ifdef RS_JSONAPI
2018-09-20 19:40:26 -04:00
if ( jsonApiServer ) // JsonApiServer may be disabled at runtime
2018-09-19 15:28:26 -04:00
{
mConfigMgr - > addConfiguration ( " jsonApi.cfg " , jsonApiServer ) ;
RsFileHash dummyHash ;
jsonApiServer - > loadConfiguration ( dummyHash ) ;
}
# endif
2017-01-05 17:07:59 -05:00
/**** Reputation system ****/
p3GxsReputation * mReputations = new p3GxsReputation ( mLinkMgr ) ;
rsReputations = mReputations ;
2012-12-16 10:04:52 -05:00
# ifdef RS_ENABLE_GXS
2012-08-06 17:00:38 -04:00
2018-07-24 17:47:32 -04:00
std : : string currGxsDir = RsAccounts : : AccountDirectory ( ) + " /gxs " ;
2012-11-24 14:49:23 -05:00
RsDirUtil : : checkCreateDirectory ( currGxsDir ) ;
2012-10-21 15:45:35 -04:00
2014-03-28 23:57:44 -04:00
RsNxsNetMgr * nxsMgr = new RsNxsNetMgrImpl ( serviceCtrl ) ;
2012-10-21 15:45:35 -04:00
2018-05-03 17:21:59 -04:00
/**** GXS Dist sync service ****/
# ifdef RS_USE_GXS_DISTANT_SYNC
RsGxsNetTunnelService * mGxsNetTunnel = new RsGxsNetTunnelService ;
2018-07-15 05:14:58 -04:00
rsGxsDistSync = mGxsNetTunnel ;
2018-05-03 17:21:59 -04:00
# else
RsGxsNetTunnelService * mGxsNetTunnel = NULL ;
# endif
2012-10-28 19:13:15 -04:00
/**** Identity service ****/
2012-11-24 14:49:23 -05:00
RsGeneralDataService * gxsid_ds = new RsDataService ( currGxsDir + " / " , " gxsid_db " ,
2014-08-25 17:07:07 -04:00
RS_SERVICE_GXS_TYPE_GXSID , NULL , rsInitConfig - > gxs_passwd ) ;
2012-10-28 19:13:15 -04:00
// init gxs services
2014-04-27 09:14:07 -04:00
PgpAuxUtils * pgpAuxUtils = new PgpAuxUtilsImpl ( ) ;
2014-12-21 15:52:34 -05:00
p3IdService * mGxsIdService = new p3IdService ( gxsid_ds , NULL , pgpAuxUtils ) ;
2012-10-28 19:13:15 -04:00
2014-04-27 09:14:07 -04:00
// circles created here, as needed by Ids.
2013-06-04 17:00:43 -04:00
RsGeneralDataService * gxscircles_ds = new RsDataService ( currGxsDir + " / " , " gxscircles_db " ,
2014-08-25 17:07:07 -04:00
RS_SERVICE_GXS_TYPE_GXSCIRCLE , NULL , rsInitConfig - > gxs_passwd ) ;
2013-06-04 17:00:43 -04:00
2014-04-21 06:13:35 -04:00
// create GxsCircles - early, as IDs need it.
2014-12-21 15:52:34 -05:00
p3GxsCircles * mGxsCircles = new p3GxsCircles ( gxscircles_ds , NULL , mGxsIdService , pgpAuxUtils ) ;
2013-06-04 17:00:43 -04:00
2014-02-01 09:16:15 -05:00
// create GXS ID service
2012-10-28 19:13:15 -04:00
RsGxsNetService * gxsid_ns = new RsGxsNetService (
2014-03-29 11:34:37 -04:00
RS_SERVICE_GXS_TYPE_GXSID , gxsid_ds , nxsMgr ,
2017-01-10 15:44:37 -05:00
mGxsIdService , mGxsIdService - > getServiceInfo ( ) ,
mReputations , mGxsCircles , mGxsIdService ,
2018-05-03 17:21:59 -04:00
pgpAuxUtils , mGxsNetTunnel ,
false , false , true ) ; // don't synchronise group automatic (need explicit group request)
2015-06-30 04:12:51 -04:00
// don't sync messages at all.
2018-05-03 17:21:59 -04:00
// allow distsync, so that we can grab GXS id requests for other services
2012-10-28 19:13:15 -04:00
2016-02-02 12:34:10 -05:00
// Normally we wouldn't need this (we do in other service):
// mGxsIdService->setNetworkExchangeService(gxsid_ns) ;
// ...since GxsIds are propagated manually. But that requires the gen exchange of GXSids to
// constantly test that mNetService is not null. The call below is to make the service aware of the
// netService so that it can request the missing ids. We'll need to fix this.
2013-11-04 09:09:32 -05:00
mGxsIdService - > setNes ( gxsid_ns ) ;
2016-02-02 12:34:10 -05:00
2012-11-30 19:16:24 -05:00
/**** GxsCircle service ****/
// create GXS Circle service
RsGxsNetService * gxscircles_ns = new RsGxsNetService (
2014-03-29 11:34:37 -04:00
RS_SERVICE_GXS_TYPE_GXSCIRCLE , gxscircles_ds , nxsMgr ,
2014-03-21 23:53:44 -04:00
mGxsCircles , mGxsCircles - > getServiceInfo ( ) ,
2017-01-10 15:44:37 -05:00
mReputations , mGxsCircles , mGxsIdService ,
2018-04-02 11:07:32 -04:00
pgpAuxUtils ) ;
2012-10-28 19:13:15 -04:00
2017-06-28 17:12:33 -04:00
mGxsCircles - > setNetworkExchangeService ( gxscircles_ns ) ;
2016-03-13 11:29:21 -04:00
2012-10-21 15:45:35 -04:00
/**** Posted GXS service ****/
2012-08-06 17:00:38 -04:00
2012-11-24 14:49:23 -05:00
RsGeneralDataService * posted_ds = new RsDataService ( currGxsDir + " / " , " posted_db " ,
2014-03-29 11:34:37 -04:00
RS_SERVICE_GXS_TYPE_POSTED ,
2014-08-25 17:07:07 -04:00
NULL , rsInitConfig - > gxs_passwd ) ;
2012-08-06 17:00:38 -04:00
2014-12-21 15:52:34 -05:00
p3Posted * mPosted = new p3Posted ( posted_ds , NULL , mGxsIdService ) ;
2012-08-06 17:00:38 -04:00
2012-10-21 15:45:35 -04:00
// create GXS photo service
RsGxsNetService * posted_ns = new RsGxsNetService (
2014-03-29 11:34:37 -04:00
RS_SERVICE_GXS_TYPE_POSTED , posted_ds , nxsMgr ,
2014-03-21 23:53:44 -04:00
mPosted , mPosted - > getServiceInfo ( ) ,
2017-01-10 15:44:37 -05:00
mReputations , mGxsCircles , mGxsIdService ,
2014-04-27 09:14:07 -04:00
pgpAuxUtils ) ;
2012-08-06 17:00:38 -04:00
2017-06-28 17:12:33 -04:00
mPosted - > setNetworkExchangeService ( posted_ns ) ;
2017-01-05 17:07:59 -05:00
2012-10-31 18:43:23 -04:00
/**** Wiki GXS service ****/
2016-01-01 06:01:49 -05:00
# ifdef RS_USE_WIKI
2012-11-24 14:49:23 -05:00
RsGeneralDataService * wiki_ds = new RsDataService ( currGxsDir + " / " , " wiki_db " ,
2014-03-29 11:34:37 -04:00
RS_SERVICE_GXS_TYPE_WIKI ,
2014-08-25 17:07:07 -04:00
NULL , rsInitConfig - > gxs_passwd ) ;
2012-10-31 18:43:23 -04:00
2014-12-21 15:52:34 -05:00
p3Wiki * mWiki = new p3Wiki ( wiki_ds , NULL , mGxsIdService ) ;
2015-09-04 11:52:25 -04:00
// create GXS wiki service
2018-05-21 08:26:46 -04:00
RsGxsNetService * wiki_ns = new RsGxsNetService (
RS_SERVICE_GXS_TYPE_WIKI , wiki_ds , nxsMgr ,
mWiki , mWiki - > getServiceInfo ( ) ,
mReputations , mGxsCircles , mGxsIdService ,
pgpAuxUtils ) ;
2012-11-08 19:56:07 -05:00
2014-10-07 17:42:44 -04:00
mWiki - > setNetworkExchangeService ( wiki_ns ) ;
2015-09-04 11:52:25 -04:00
# endif
2012-11-26 17:53:44 -05:00
2012-11-08 19:56:07 -05:00
/**** Forum GXS service ****/
2012-11-24 14:49:23 -05:00
RsGeneralDataService * gxsforums_ds = new RsDataService ( currGxsDir + " / " , " gxsforums_db " ,
2014-08-25 17:07:07 -04:00
RS_SERVICE_GXS_TYPE_FORUMS , NULL , rsInitConfig - > gxs_passwd ) ;
2012-11-08 19:56:07 -05:00
2014-12-21 15:52:34 -05:00
p3GxsForums * mGxsForums = new p3GxsForums ( gxsforums_ds , NULL , mGxsIdService ) ;
2012-11-08 19:56:07 -05:00
// create GXS photo service
RsGxsNetService * gxsforums_ns = new RsGxsNetService (
2014-03-29 11:34:37 -04:00
RS_SERVICE_GXS_TYPE_FORUMS , gxsforums_ds , nxsMgr ,
2014-03-21 23:53:44 -04:00
mGxsForums , mGxsForums - > getServiceInfo ( ) ,
2017-01-10 15:44:37 -05:00
mReputations , mGxsCircles , mGxsIdService ,
2018-05-01 14:10:56 -04:00
pgpAuxUtils ) ; //,mGxsNetTunnel,true,true,true);
2012-09-25 17:04:04 -04:00
2014-10-07 17:42:44 -04:00
mGxsForums - > setNetworkExchangeService ( gxsforums_ns ) ;
2012-10-15 14:52:47 -04:00
2013-03-04 15:26:48 -05:00
/**** Channel GXS service ****/
RsGeneralDataService * gxschannels_ds = new RsDataService ( currGxsDir + " / " , " gxschannels_db " ,
2014-08-25 17:07:07 -04:00
RS_SERVICE_GXS_TYPE_CHANNELS , NULL , rsInitConfig - > gxs_passwd ) ;
2013-03-04 15:26:48 -05:00
2014-12-21 15:52:34 -05:00
p3GxsChannels * mGxsChannels = new p3GxsChannels ( gxschannels_ds , NULL , mGxsIdService ) ;
2013-03-04 15:26:48 -05:00
// create GXS photo service
RsGxsNetService * gxschannels_ns = new RsGxsNetService (
2018-04-01 16:04:16 -04:00
RS_SERVICE_GXS_TYPE_CHANNELS , gxschannels_ds , nxsMgr ,
mGxsChannels , mGxsChannels - > getServiceInfo ( ) ,
mReputations , mGxsCircles , mGxsIdService ,
2018-05-01 14:10:56 -04:00
pgpAuxUtils , mGxsNetTunnel , true , true , true ) ;
2012-10-21 15:45:35 -04:00
2014-10-05 15:14:05 -04:00
mGxsChannels - > setNetworkExchangeService ( gxschannels_ns ) ;
2014-03-29 11:34:37 -04:00
#if 0 // PHOTO IS DISABLED FOR THE MOMENT
/**** Photo service ****/
RsGeneralDataService * photo_ds = new RsDataService ( currGxsDir + " / " , " photoV2_db " ,
2014-08-25 17:07:07 -04:00
RS_SERVICE_GXS_TYPE_PHOTO , NULL , rsInitConfig - > gxs_passwd ) ;
2014-03-29 11:34:37 -04:00
// init gxs services
mPhoto = new p3PhotoService ( photo_ds , NULL , mGxsIdService ) ;
// create GXS photo service
RsGxsNetService * photo_ns = new RsGxsNetService (
RS_SERVICE_GXS_TYPE_PHOTO , photo_ds , nxsMgr ,
mPhoto , mPhoto - > getServiceInfo ( ) ,
2016-01-01 21:37:27 -05:00
mGxsIdService , mGxsCircles , mGxsIdService ,
2014-04-27 09:14:07 -04:00
pgpAuxUtils ) ;
2014-03-29 11:34:37 -04:00
# endif
#if 0 // WIRE IS DISABLED FOR THE MOMENT
/**** Wire GXS service ****/
RsGeneralDataService * wire_ds = new RsDataService ( currGxsDir + " / " , " wire_db " ,
RS_SERVICE_GXS_TYPE_WIRE ,
2014-08-25 17:07:07 -04:00
NULL , rsInitConfig - > gxs_passwd ) ;
2014-03-29 11:34:37 -04:00
mWire = new p3Wire ( wire_ds , NULL , mGxsIdService ) ;
// create GXS photo service
RsGxsNetService * wire_ns = new RsGxsNetService (
RS_SERVICE_GXS_TYPE_WIRE , wire_ds , nxsMgr ,
mWire , mWire - > getServiceInfo ( ) ,
2016-01-01 21:37:27 -05:00
mGxsIdService , mGxsCircles , mGxsIdService ,
2014-04-27 09:14:07 -04:00
pgpAuxUtils ) ;
2014-03-29 11:34:37 -04:00
# endif
2012-10-21 15:45:35 -04:00
// now add to p3service
2014-03-21 23:53:44 -04:00
pqih - > addService ( gxsid_ns , true ) ;
pqih - > addService ( gxscircles_ns , true ) ;
pqih - > addService ( posted_ns , true ) ;
2015-09-04 11:52:25 -04:00
# ifdef RS_USE_WIKI
2014-03-21 23:53:44 -04:00
pqih - > addService ( wiki_ns , true ) ;
2015-09-04 11:52:25 -04:00
# endif
2014-03-21 23:53:44 -04:00
pqih - > addService ( gxsforums_ns , true ) ;
pqih - > addService ( gxschannels_ns , true ) ;
2014-03-29 11:34:37 -04:00
//pqih->addService(photo_ns, true);
2012-10-21 15:45:35 -04:00
2017-03-01 20:37:53 -05:00
# ifdef RS_GXS_TRANS
RsGeneralDataService * gxstrans_ds = new RsDataService (
currGxsDir + " / " , " gxstrans_db " , RS_SERVICE_TYPE_GXS_TRANS ,
2017-01-15 15:45:03 -05:00
NULL , rsInitConfig - > gxs_passwd ) ;
2017-03-01 20:37:53 -05:00
mGxsTrans = new p3GxsTrans ( gxstrans_ds , NULL , * mGxsIdService ) ;
2017-06-28 17:12:33 -04:00
2017-03-01 20:37:53 -05:00
RsGxsNetService * gxstrans_ns = new RsGxsNetService (
RS_SERVICE_TYPE_GXS_TRANS , gxstrans_ds , nxsMgr , mGxsTrans ,
mGxsTrans - > getServiceInfo ( ) , mReputations , mGxsCircles ,
2018-05-01 14:10:56 -04:00
mGxsIdService , pgpAuxUtils , NULL , true , true , false , p3GxsTrans : : GXS_STORAGE_PERIOD , p3GxsTrans : : GXS_SYNC_PERIOD ) ;
2017-06-28 17:12:33 -04:00
2017-03-01 20:37:53 -05:00
mGxsTrans - > setNetworkExchangeService ( gxstrans_ns ) ;
pqih - > addService ( gxstrans_ns , true ) ;
# endif // RS_GXS_TRANS
2017-01-15 15:45:03 -05:00
// remove pword from memory
rsInitConfig - > gxs_passwd = " " ;
2013-06-20 15:50:25 -04:00
2012-12-16 10:04:52 -05:00
# endif // RS_ENABLE_GXS.
2012-06-13 20:27:28 -04:00
2014-03-29 10:18:05 -04:00
/* create Services */
p3ServiceInfo * serviceInfo = new p3ServiceInfo ( serviceCtrl ) ;
2018-09-06 15:15:25 -04:00
mDisc = new p3discovery2 ( mPeerMgr , mLinkMgr , mNetMgr , serviceCtrl , mGxsIdService ) ;
2014-03-29 10:18:05 -04:00
mHeart = new p3heartbeat ( serviceCtrl , pqih ) ;
2017-03-01 20:37:53 -05:00
msgSrv = new p3MsgService ( serviceCtrl , mGxsIdService , * mGxsTrans ) ;
2017-02-27 16:18:37 -05:00
chatSrv = new p3ChatService ( serviceCtrl , mGxsIdService , mLinkMgr ,
2017-03-01 20:37:53 -05:00
mHistoryMgr , * mGxsTrans ) ;
2014-03-29 10:18:05 -04:00
mStatusSrv = new p3StatusService ( serviceCtrl ) ;
# ifdef ENABLE_GROUTER
2015-01-11 17:18:28 -05:00
p3GRouter * gr = new p3GRouter ( serviceCtrl , mGxsIdService ) ;
2014-03-29 10:18:05 -04:00
rsGRouter = gr ;
pqih - > addService ( gr , true ) ;
# endif
2016-08-13 04:15:02 -04:00
p3FileDatabase * fdb = new p3FileDatabase ( serviceCtrl ) ;
p3turtle * tr = new p3turtle ( serviceCtrl , mLinkMgr ) ;
2014-03-29 10:18:05 -04:00
rsTurtle = tr ;
pqih - > addService ( tr , true ) ;
2016-08-13 04:15:02 -04:00
pqih - > addService ( fdb , true ) ;
pqih - > addService ( ftserver , true ) ;
2014-03-29 10:18:05 -04:00
2018-05-01 14:10:56 -04:00
mGxsTunnels = new p3GxsTunnelService ( mGxsIdService ) ;
mGxsTunnels - > connectToTurtleRouter ( tr ) ;
rsGxsTunnel = mGxsTunnels ;
mGxsNetTunnel - > connectToTurtleRouter ( tr ) ;
2016-08-13 04:15:02 -04:00
2014-03-29 10:18:05 -04:00
rsDisc = mDisc ;
rsMsgs = new p3Msgs ( msgSrv , chatSrv ) ;
// connect components to turtle router.
ftserver - > connectToTurtleRouter ( tr ) ;
2016-08-13 04:15:02 -04:00
ftserver - > connectToFileDatabase ( fdb ) ;
chatSrv - > connectToGxsTunnelService ( mGxsTunnels ) ;
2015-01-11 17:18:28 -05:00
gr - > connectToTurtleRouter ( tr ) ;
2014-03-29 10:18:05 -04:00
# ifdef ENABLE_GROUTER
msgSrv - > connectToGlobalRouter ( gr ) ;
# endif
pqih - > addService ( serviceInfo , true ) ;
pqih - > addService ( mHeart , true ) ;
pqih - > addService ( mDisc , true ) ;
pqih - > addService ( msgSrv , true ) ;
pqih - > addService ( chatSrv , true ) ;
2015-11-26 20:40:06 -05:00
pqih - > addService ( mStatusSrv , true ) ;
2015-11-28 18:02:57 -05:00
pqih - > addService ( mGxsTunnels , true ) ;
2015-10-04 23:14:49 -04:00
pqih - > addService ( mReputations , true ) ;
2014-03-29 10:18:05 -04:00
// set interfaces for plugins
//
RsPlugInInterfaces interfaces ;
interfaces . mFiles = rsFiles ;
interfaces . mPeers = rsPeers ;
interfaces . mMsgs = rsMsgs ;
interfaces . mTurtle = rsTurtle ;
interfaces . mDisc = rsDisc ;
2017-12-31 11:27:21 -05:00
# ifdef RS_USE_BITDHT
2014-03-29 10:18:05 -04:00
interfaces . mDht = rsDht ;
2017-12-31 11:27:21 -05:00
# else
interfaces . mDht = NULL ;
# endif
2014-03-29 10:18:05 -04:00
interfaces . mNotify = mNotify ;
2015-12-15 13:56:49 -05:00
interfaces . mServiceControl = serviceCtrl ;
interfaces . mPluginHandler = mPluginsManager ;
2014-08-25 17:07:07 -04:00
// gxs
interfaces . mGxsDir = currGxsDir ;
interfaces . mIdentity = mGxsIdService ;
interfaces . mRsNxsNetMgr = nxsMgr ;
interfaces . mGxsIdService = mGxsIdService ;
interfaces . mGxsCirlces = mGxsCircles ;
interfaces . mPgpAuxUtils = pgpAuxUtils ;
2014-11-23 18:24:41 -05:00
interfaces . mGxsForums = mGxsForums ;
interfaces . mGxsChannels = mGxsChannels ;
2015-11-28 18:02:57 -05:00
interfaces . mGxsTunnels = mGxsTunnels ;
2015-10-04 23:14:49 -04:00
interfaces . mReputations = mReputations ;
2015-11-28 18:02:57 -05:00
2014-03-29 10:18:05 -04:00
mPluginsManager - > setInterfaces ( interfaces ) ;
// now add plugin objects inside the loop:
// - client services provided by plugins.
// - cache services provided by plugins.
//
mPluginsManager - > registerClientServices ( pqih ) ;
mPluginsManager - > registerCacheServices ( ) ;
2012-07-27 11:03:16 -04:00
2013-09-29 03:11:02 -04:00
# ifdef RS_RTT
2014-03-28 23:57:44 -04:00
p3rtt * mRtt = new p3rtt ( serviceCtrl ) ;
2014-03-21 23:53:44 -04:00
pqih - > addService ( mRtt , true ) ;
2013-09-29 03:11:02 -04:00
rsRtt = mRtt ;
2011-08-03 13:43:26 -04:00
# endif
2011-11-24 19:58:01 -05:00
// new services to test.
2018-01-01 09:49:49 -05:00
2018-07-25 05:37:40 -04:00
p3BanList * mBanList = NULL ;
if ( ! RsAccounts : : isHiddenNode ( ) )
{
mBanList = new p3BanList ( serviceCtrl , mNetMgr ) ;
rsBanList = mBanList ;
pqih - > addService ( mBanList , true ) ;
}
else
rsBanList = NULL ;
2011-11-24 19:58:01 -05:00
2012-06-21 19:23:46 -04:00
p3BandwidthControl * mBwCtrl = new p3BandwidthControl ( pqih ) ;
2014-03-21 23:53:44 -04:00
pqih - > addService ( mBwCtrl , true ) ;
2012-06-21 19:23:46 -04:00
2013-12-22 12:10:56 -05:00
# ifdef SERVICES_DSDV
2014-03-28 23:57:44 -04:00
p3Dsdv * mDsdv = new p3Dsdv ( serviceCtrl ) ;
2014-03-21 23:53:44 -04:00
pqih - > addService ( mDsdv , true ) ;
2011-11-24 19:58:01 -05:00
rsDsdv = mDsdv ;
mDsdv - > addTestService ( ) ;
2011-12-01 12:21:52 -05:00
# endif
2011-11-24 19:58:01 -05:00
2009-07-30 17:27:47 -04:00
/**************************************************************************/
2007-11-14 22:18:48 -05:00
2018-07-25 05:37:40 -04:00
if ( ! RsAccounts : : isHiddenNode ( ) )
{
2010-07-31 14:14:10 -04:00
# ifdef RS_USE_BITDHT
2018-07-25 09:31:18 -04:00
mBitDht - > setupPeerSharer ( mBanList ) ;
2011-07-09 20:41:39 -04:00
2018-07-25 05:37:40 -04:00
mNetMgr - > addNetAssistConnect ( 1 , mBitDht ) ;
mNetMgr - > addNetListener ( mDhtStack ) ;
mNetMgr - > addNetListener ( mProxyStack ) ;
2010-07-31 14:14:10 -04:00
# endif
2011-12-13 11:19:37 -05:00
# ifdef RS_ENABLE_ZEROCONF
2018-07-25 05:37:40 -04:00
p3ZeroConf * mZeroConf = new p3ZeroConf (
AuthGPG : : getAuthGPG ( ) - > getGPGOwnId ( ) , ownId ,
mLinkMgr , mNetMgr , mPeerMgr ) ;
mNetMgr - > addNetAssistConnect ( 2 , mZeroConf ) ;
mNetMgr - > addNetListener ( mZeroConf ) ;
2012-01-14 11:41:00 -05:00
# endif
2011-12-13 11:19:37 -05:00
2012-01-14 11:41:00 -05:00
# ifdef RS_ENABLE_ZCNATASSIST
2018-07-25 05:37:40 -04:00
// Apple's UPnP & NAT-PMP assistance.
p3zcNatAssist * mZcNatAssist = new p3zcNatAssist ( ) ;
mNetMgr - > addNetAssistFirewall ( 1 , mZcNatAssist ) ;
2011-12-13 11:19:37 -05:00
# else
2018-07-25 05:37:40 -04:00
// Original UPnP Interface.
pqiNetAssistFirewall * mUpnpMgr = new upnphandler ( ) ;
mNetMgr - > addNetAssistFirewall ( 1 , mUpnpMgr ) ;
2011-12-13 11:19:37 -05:00
# endif
2018-07-25 05:37:40 -04:00
}
2007-11-14 22:18:48 -05:00
2009-07-30 17:27:47 -04:00
/**************************************************************************/
/* need to Monitor too! */
2011-07-09 14:39:34 -04:00
mLinkMgr - > addMonitor ( pqih ) ;
2014-03-22 23:30:59 -04:00
mLinkMgr - > addMonitor ( serviceCtrl ) ;
mLinkMgr - > addMonitor ( serviceInfo ) ;
// Services that have been changed to pqiServiceMonitor
2014-03-28 23:57:44 -04:00
serviceCtrl - > registerServiceMonitor ( msgSrv , msgSrv - > getServiceInfo ( ) . mServiceType ) ;
2014-03-22 23:30:59 -04:00
serviceCtrl - > registerServiceMonitor ( mDisc , mDisc - > getServiceInfo ( ) . mServiceType ) ;
2014-04-19 12:02:11 -04:00
serviceCtrl - > registerServiceMonitor ( mStatusSrv , mStatusSrv - > getServiceInfo ( ) . mServiceType ) ;
serviceCtrl - > registerServiceMonitor ( chatSrv , chatSrv - > getServiceInfo ( ) . mServiceType ) ;
2017-07-18 13:24:32 -04:00
serviceCtrl - > registerServiceMonitor ( mBwCtrl , mBwCtrl - > getServiceInfo ( ) . mServiceType ) ;
2007-11-14 22:18:48 -05:00
2009-07-30 17:27:47 -04:00
/**************************************************************************/
2018-06-16 16:39:35 -04:00
// Turtle search for GXS services
mGxsNetTunnel - > registerSearchableService ( gxschannels_ns ) ;
/**************************************************************************/
2009-05-07 17:36:17 -04:00
2009-07-30 17:27:47 -04:00
//mConfigMgr->addConfiguration("ftserver.cfg", ftserver);
//
2018-07-18 15:20:51 -04:00
mConfigMgr - > addConfiguration ( " gpg_prefs.cfg " , AuthGPG : : getAuthGPG ( ) ) ;
2018-05-01 14:10:56 -04:00
mConfigMgr - > addConfiguration ( " gxsnettunnel.cfg " , mGxsNetTunnel ) ;
2018-07-18 15:20:51 -04:00
mConfigMgr - > addConfiguration ( " peers.cfg " , mPeerMgr ) ;
mConfigMgr - > addConfiguration ( " general.cfg " , mGeneralConfig ) ;
mConfigMgr - > addConfiguration ( " msgs.cfg " , msgSrv ) ;
mConfigMgr - > addConfiguration ( " chat.cfg " , chatSrv ) ;
mConfigMgr - > addConfiguration ( " p3History.cfg " , mHistoryMgr ) ;
mConfigMgr - > addConfiguration ( " p3Status.cfg " , mStatusSrv ) ;
mConfigMgr - > addConfiguration ( " turtle.cfg " , tr ) ;
2018-07-25 05:37:40 -04:00
2018-07-25 09:31:18 -04:00
if ( mBanList ! = NULL )
2018-07-25 05:37:40 -04:00
mConfigMgr - > addConfiguration ( " banlist.cfg " , mBanList ) ;
2015-10-04 23:14:49 -04:00
mConfigMgr - > addConfiguration ( " servicecontrol.cfg " , serviceCtrl ) ;
2018-07-18 15:20:51 -04:00
mConfigMgr - > addConfiguration ( " reputations.cfg " , mReputations ) ;
2014-03-29 10:18:05 -04:00
# ifdef ENABLE_GROUTER
2018-07-18 15:20:51 -04:00
mConfigMgr - > addConfiguration ( " grouter.cfg " , gr ) ;
2013-12-28 16:47:15 -05:00
# endif
2011-06-16 17:59:26 -04:00
2011-12-19 21:07:00 -05:00
# ifdef RS_USE_BITDHT
2018-07-25 09:31:18 -04:00
if ( mBitDht ! = NULL )
mConfigMgr - > addConfiguration ( " bitdht.cfg " , mBitDht ) ;
2011-12-19 21:07:00 -05:00
# endif
2013-12-20 09:48:32 -05:00
# ifdef RS_ENABLE_GXS
2017-02-25 18:46:02 -05:00
2017-03-01 20:37:53 -05:00
# ifdef RS_GXS_TRANS
mConfigMgr - > addConfiguration ( " gxs_trans_ns.cfg " , gxstrans_ns ) ;
2018-07-18 15:20:51 -04:00
mConfigMgr - > addConfiguration ( " gxs_trans.cfg " , mGxsTrans ) ;
2017-03-01 20:37:53 -05:00
# endif // RS_GXS_TRANS
2017-02-25 18:46:02 -05:00
2018-07-18 15:20:51 -04:00
mConfigMgr - > addConfiguration ( " p3identity.cfg " , mGxsIdService ) ;
mConfigMgr - > addConfiguration ( " identity.cfg " , gxsid_ns ) ;
mConfigMgr - > addConfiguration ( " gxsforums.cfg " , gxsforums_ns ) ;
2018-02-16 17:24:01 -05:00
mConfigMgr - > addConfiguration ( " gxsforums_srv.cfg " , mGxsForums ) ;
2018-07-18 15:20:51 -04:00
mConfigMgr - > addConfiguration ( " gxschannels.cfg " , gxschannels_ns ) ;
2018-02-16 17:51:43 -05:00
mConfigMgr - > addConfiguration ( " gxschannels_srv.cfg " , mGxsChannels ) ;
2018-07-18 15:20:51 -04:00
mConfigMgr - > addConfiguration ( " gxscircles.cfg " , gxscircles_ns ) ;
mConfigMgr - > addConfiguration ( " posted.cfg " , posted_ns ) ;
2015-09-04 11:52:25 -04:00
# ifdef RS_USE_WIKI
2013-12-20 09:48:32 -05:00
mConfigMgr - > addConfiguration ( " wiki.cfg " , wiki_ns ) ;
2015-09-04 11:52:25 -04:00
# endif
2014-03-29 11:34:37 -04:00
//mConfigMgr->addConfiguration("photo.cfg", photo_ns);
//mConfigMgr->addConfiguration("wire.cfg", wire_ns);
2017-07-28 06:56:42 -04:00
# endif //RS_ENABLE_GXS
2016-10-09 08:32:52 -04:00
mConfigMgr - > addConfiguration ( " I2PBOB.cfg " , mI2pBob ) ;
2013-12-20 09:48:32 -05:00
2011-06-16 17:59:26 -04:00
mPluginsManager - > addConfigurations ( mConfigMgr ) ;
2009-05-07 17:36:17 -04:00
2009-07-30 17:27:47 -04:00
ftserver - > addConfiguration ( mConfigMgr ) ;
2007-11-14 22:18:48 -05:00
2009-07-30 17:27:47 -04:00
/**************************************************************************/
/* (2) Load configuration files */
/**************************************************************************/
2012-09-09 09:59:21 -04:00
std : : cerr < < " (2) Load configuration files " < < std : : endl ;
2007-11-14 22:18:48 -05:00
2014-03-29 01:20:57 -04:00
mConfigMgr - > loadConfiguration ( ) ;
2009-07-30 17:27:47 -04:00
/**************************************************************************/
/* trigger generalConfig loading for classes that require it */
/**************************************************************************/
2012-11-25 15:25:34 -05:00
p3ServerConfig * serverConfig = new p3ServerConfig ( mPeerMgr , mLinkMgr , mNetMgr , pqih , mGeneralConfig ) ;
serverConfig - > load_config ( ) ;
2007-11-14 22:18:48 -05:00
2009-07-30 17:27:47 -04:00
/**************************************************************************/
/* Force Any Configuration before Startup (After Load) */
/**************************************************************************/
2012-09-09 09:59:21 -04:00
std : : cerr < < " Force Any Configuration before Startup (After Load) " < < std : : endl ;
2007-11-14 22:18:48 -05:00
2014-08-25 17:07:07 -04:00
if ( rsInitConfig - > forceLocalAddr )
2009-07-30 17:27:47 -04:00
{
2013-09-13 10:35:19 -04:00
struct sockaddr_storage laddr ;
2007-11-14 22:18:48 -05:00
2009-07-30 17:27:47 -04:00
/* clean sockaddr before setting values (MaxOSX) */
2013-09-13 10:35:19 -04:00
sockaddr_storage_clear ( laddr ) ;
2012-09-09 09:59:21 -04:00
2013-09-13 10:35:19 -04:00
struct sockaddr_in * lap = ( struct sockaddr_in * ) & laddr ;
lap - > sin_family = AF_INET ;
2014-08-25 17:07:07 -04:00
lap - > sin_port = htons ( rsInitConfig - > port ) ;
2007-11-14 22:18:48 -05:00
2009-07-30 17:27:47 -04:00
// universal
2014-08-25 17:07:07 -04:00
lap - > sin_addr . s_addr = inet_addr ( rsInitConfig - > inet . c_str ( ) ) ;
2007-11-14 22:18:48 -05:00
2011-07-09 20:41:39 -04:00
mPeerMgr - > setLocalAddress ( ownId , laddr ) ;
2009-07-30 17:27:47 -04:00
}
2008-09-21 16:30:34 -04:00
2014-08-25 17:07:07 -04:00
if ( rsInitConfig - > forceExtPort )
2009-07-30 17:27:47 -04:00
{
2011-07-09 20:41:39 -04:00
mPeerMgr - > setOwnNetworkMode ( RS_NET_MODE_EXT ) ;
2013-09-28 04:09:59 -04:00
mPeerMgr - > setOwnVisState ( RS_VS_DISC_FULL , RS_VS_DHT_FULL ) ;
2007-11-14 22:18:48 -05:00
}
2009-07-30 17:27:47 -04:00
2014-08-25 17:07:07 -04:00
if ( rsInitConfig - > hiddenNodeSet )
2007-11-14 22:18:48 -05:00
{
2016-10-09 08:32:52 -04:00
std : : cout < < " RsServer::StartupRetroShare setting up hidden locations " < < std : : endl ;
if ( rsInitConfig - > hiddenNodeI2PBOB ) {
std : : cout < < " RsServer::StartupRetroShare setting up BOB " < < std : : endl ;
// we need a local port!
mNetMgr - > checkNetAddress ( ) ;
// add i2p proxy
// bob will use this address
sockaddr_storage i2pInstance ;
sockaddr_storage_ipv4_aton ( i2pInstance , rsInitConfig - > hiddenNodeAddress . c_str ( ) ) ;
mPeerMgr - > setProxyServerAddress ( RS_HIDDEN_TYPE_I2P , i2pInstance ) ;
std : : string addr ; // will be set by auto proxy service
uint16_t port = rsInitConfig - > hiddenNodePort ; // unused by bob
bool r = autoProxy - > initialSetup ( autoProxyType : : I2PBOB , addr , port ) ;
if ( r & & ! addr . empty ( ) ) {
mPeerMgr - > setupHiddenNode ( addr , port ) ;
// now enable bob
bobSettings bs ;
autoProxy - > taskSync ( autoProxyType : : I2PBOB , autoProxyTask : : getSettings , & bs ) ;
bs . enableBob = true ;
autoProxy - > taskSync ( autoProxyType : : I2PBOB , autoProxyTask : : setSettings , & bs ) ;
} else {
std : : cerr < < " RsServer::StartupRetroShare failed to receive keys " < < std : : endl ;
/// TODO add notify for failed bob setup
}
} else {
mPeerMgr - > setupHiddenNode ( rsInitConfig - > hiddenNodeAddress , rsInitConfig - > hiddenNodePort ) ;
}
std : : cout < < " RsServer::StartupRetroShare hidden location set up " < < std : : endl ;
2013-09-08 22:10:49 -04:00
}
2014-01-17 21:32:55 -05:00
else if ( isHiddenNode )
2007-11-14 22:18:48 -05:00
{
2014-01-17 21:32:55 -05:00
mPeerMgr - > forceHiddenNode ( ) ;
2007-11-14 22:18:48 -05:00
}
2016-08-13 08:34:31 -04:00
if ( ! rsInitConfig - > opModeStr . empty ( ) )
{
rsConfig - > setOperatingMode ( rsInitConfig - > opModeStr ) ;
}
2011-07-09 20:41:39 -04:00
mNetMgr - > checkNetAddress ( ) ;
2007-11-14 22:18:48 -05:00
2016-10-09 08:32:52 -04:00
if ( rsInitConfig - > hiddenNodeSet ) {
// newly created location
// mNetMgr->checkNetAddress() will setup ports for us
// trigger updates for auto proxy services
std : : vector < autoProxyType : : autoProxyType_enum > types ;
// i2p bob need to rebuild its command map
types . push_back ( autoProxyType : : I2PBOB ) ;
rsAutoProxyMonitor : : taskSync ( types , autoProxyTask : : reloadConfig ) ;
}
2009-07-30 17:27:47 -04:00
/**************************************************************************/
/* startup (stuff dependent on Ids/peers is after this point) */
/**************************************************************************/
2007-11-14 22:18:48 -05:00
2016-10-09 08:32:52 -04:00
autoProxy - > startAll ( ) ;
2009-07-30 17:27:47 -04:00
pqih - > init_listener ( ) ;
2011-07-09 20:41:39 -04:00
mNetMgr - > addNetListener ( pqih ) ; /* add listener so we can reset all sockets later */
2007-11-14 22:18:48 -05:00
2009-07-30 17:27:47 -04:00
/**************************************************************************/
/* load caches and secondary data */
/**************************************************************************/
2007-11-14 22:18:48 -05:00
2010-05-23 12:35:42 -04:00
// Clear the News Feeds that are generated by Initial Cache Loading.
/* Peer stuff is up to date */
//getPqiNotify()->ClearFeedItems(RS_FEED_ITEM_CHAT_NEW);
2014-01-07 17:51:22 -05:00
mNotify - > ClearFeedItems ( RS_FEED_ITEM_MESSAGE ) ;
2010-05-23 12:35:42 -04:00
//getPqiNotify()->ClearFeedItems(RS_FEED_ITEM_FILES_NEW);
2010-10-13 12:15:26 -04:00
/**************************************************************************/
/* Add AuthGPG services */
/**************************************************************************/
2013-09-28 04:09:59 -04:00
AuthGPG : : getAuthGPG ( ) - > addService ( mDisc ) ;
2010-10-13 12:15:26 -04:00
2009-07-30 17:27:47 -04:00
/**************************************************************************/
/* Force Any Last Configuration Options */
/**************************************************************************/
2007-11-14 22:18:48 -05:00
2009-07-30 17:27:47 -04:00
/**************************************************************************/
/* Start up Threads */
/**************************************************************************/
2007-11-14 22:18:48 -05:00
2016-10-09 08:32:52 -04:00
// auto proxy threads
startServiceThread ( mI2pBob , " I2P-BOB " ) ;
2013-03-04 15:26:48 -05:00
2016-10-09 08:32:52 -04:00
# ifdef RS_ENABLE_GXS
2013-03-04 15:26:48 -05:00
// Must Set the GXS pointers before starting threads.
2014-12-21 15:52:34 -05:00
rsIdentity = mGxsIdService ;
rsGxsCircles = mGxsCircles ;
2015-09-04 11:52:25 -04:00
# if RS_USE_WIKI
2014-12-21 15:52:34 -05:00
rsWiki = mWiki ;
2015-09-04 11:52:25 -04:00
# endif
2014-12-21 15:52:34 -05:00
rsPosted = mPosted ;
rsGxsForums = mGxsForums ;
rsGxsChannels = mGxsChannels ;
2017-05-22 17:54:55 -04:00
rsGxsTrans = mGxsTrans ;
2014-12-21 15:52:34 -05:00
//rsPhoto = mPhoto;
//rsWire = mWire;
2013-03-04 15:26:48 -05:00
/*** start up GXS core runner ***/
2018-04-02 11:07:32 -04:00
2018-05-01 14:10:56 -04:00
startServiceThread ( mGxsNetTunnel , " gxs net tunnel " ) ;
2016-06-01 10:47:21 -04:00
startServiceThread ( mGxsIdService , " gxs id " ) ;
startServiceThread ( mGxsCircles , " gxs circle " ) ;
startServiceThread ( mPosted , " gxs posted " ) ;
2015-09-04 11:52:25 -04:00
# if RS_USE_WIKI
2016-06-01 10:47:21 -04:00
startServiceThread ( mWiki , " gxs wiki " ) ;
2015-09-04 11:52:25 -04:00
# endif
2016-06-01 10:47:21 -04:00
startServiceThread ( mGxsForums , " gxs forums " ) ;
startServiceThread ( mGxsChannels , " gxs channels " ) ;
2013-03-04 15:26:48 -05:00
2014-03-29 11:34:37 -04:00
//createThread(*mPhoto);
//createThread(*mWire);
2013-03-04 15:26:48 -05:00
// cores ready start up GXS net servers
2016-06-01 10:47:21 -04:00
startServiceThread ( gxsid_ns , " gxs id ns " ) ;
startServiceThread ( gxscircles_ns , " gxs circle ns " ) ;
startServiceThread ( posted_ns , " gxs posted ns " ) ;
2015-09-04 11:52:25 -04:00
# if RS_USE_WIKI
2016-06-01 10:47:21 -04:00
startServiceThread ( wiki_ns , " gxs wiki ns " ) ;
2015-09-04 11:52:25 -04:00
# endif
2016-06-01 10:47:21 -04:00
startServiceThread ( gxsforums_ns , " gxs forums ns " ) ;
startServiceThread ( gxschannels_ns , " gxs channels ns " ) ;
2013-03-04 15:26:48 -05:00
2014-03-29 11:34:37 -04:00
//createThread(*photo_ns);
//createThread(*wire_ns);
2017-03-01 20:37:53 -05:00
# ifdef RS_GXS_TRANS
startServiceThread ( mGxsTrans , " gxs trans " ) ;
startServiceThread ( gxstrans_ns , " gxs trans ns " ) ;
# endif // RS_GXS_TRANS
2017-01-15 15:45:03 -05:00
2013-03-04 15:26:48 -05:00
# endif // RS_ENABLE_GXS
2011-03-08 18:29:21 -05:00
ftserver - > StartupThreads ( ) ;
2009-07-30 17:27:47 -04:00
ftserver - > ResumeTransfers ( ) ;
2007-11-14 22:18:48 -05:00
2012-09-09 09:59:21 -04:00
//mDhtMgr->start();
2010-07-31 14:14:10 -04:00
# ifdef RS_USE_BITDHT
2018-07-25 09:31:18 -04:00
if ( mBitDht ! = NULL )
mBitDht - > start ( ) ;
2010-07-31 14:14:10 -04:00
# endif
2007-11-14 22:18:48 -05:00
2011-01-29 20:37:59 -05:00
/**************************************************************************/
2009-07-30 17:27:47 -04:00
// create loopback device, and add to pqisslgrp.
2007-11-14 22:18:48 -05:00
2009-07-30 17:27:47 -04:00
SearchModule * mod = new SearchModule ( ) ;
pqiloopback * ploop = new pqiloopback ( ownId ) ;
2007-11-14 22:18:48 -05:00
2009-07-30 17:27:47 -04:00
mod - > peerid = ownId ;
mod - > pqi = ploop ;
2007-11-14 22:18:48 -05:00
2009-07-30 17:27:47 -04:00
pqih - > AddSearchModule ( mod ) ;
2007-11-14 22:18:48 -05:00
2009-07-30 17:27:47 -04:00
/* Setup GUI Interfaces. */
2007-11-14 22:18:48 -05:00
2014-02-01 09:16:15 -05:00
// rsDisc & RsMsgs done already.
2012-06-21 19:23:46 -04:00
rsBandwidthControl = mBwCtrl ;
2012-11-25 15:25:34 -05:00
rsConfig = serverConfig ;
2007-11-14 22:18:48 -05:00
2013-09-03 10:51:23 -04:00
2010-04-20 13:10:45 -04:00
rsStatus = new p3Status ( mStatusSrv ) ;
2011-09-29 05:20:09 -04:00
rsHistory = new p3History ( mHistoryMgr ) ;
2007-11-14 22:18:48 -05:00
2009-07-30 17:27:47 -04:00
/* put a welcome message in! */
2014-01-17 21:32:55 -05:00
if ( isFirstTimeRun )
2007-11-14 22:18:48 -05:00
{
2009-07-30 17:27:47 -04:00
msgSrv - > loadWelcomeMsg ( ) ;
2011-03-08 18:29:21 -05:00
ftserver - > shareDownloadDirectory ( true ) ;
2013-09-08 22:10:49 -04:00
mGeneralConfig - > saveConfiguration ( ) ;
2007-11-14 22:18:48 -05:00
}
2009-07-30 17:27:47 -04:00
/* Startup this thread! */
2016-06-01 10:47:21 -04:00
start ( " rs main " ) ;
2007-11-14 22:18:48 -05:00
2018-07-25 05:37:40 -04:00
std : : cerr < < " ======================================================================== " < < std : : endl ;
std : : cerr < < " == RsInit:: Retroshare core started == " < < std : : endl ;
std : : cerr < < " ======================================================================== " < < std : : endl ;
2018-08-30 13:06:20 -04:00
coreReady = true ;
2009-07-30 17:27:47 -04:00
return 1 ;
2007-11-14 22:18:48 -05:00
}
2014-03-17 16:56:06 -04:00
2018-06-27 02:52:03 -04:00
RsInit : : LoadCertificateStatus RsLoginHelper : : attemptLogin (
const RsPeerId & account , const std : : string & password )
{
2018-09-19 15:28:26 -04:00
if ( isLoggedIn ( ) ) return RsInit : : ERR_ALREADY_RUNNING ;
2018-06-27 02:52:03 -04:00
if ( ! rsNotify - > cachePgpPassphrase ( password ) ) return RsInit : : ERR_UNKOWN ;
if ( ! rsNotify - > setDisableAskPassword ( true ) ) return RsInit : : ERR_UNKOWN ;
if ( ! RsAccounts : : SelectAccount ( account ) ) return RsInit : : ERR_UNKOWN ;
2018-08-28 08:35:29 -04:00
std : : string _ignore_lockFilePath ;
2018-06-27 02:52:03 -04:00
RsInit : : LoadCertificateStatus ret =
2018-08-28 08:35:29 -04:00
RsInit : : LockAndLoadCertificates ( false , _ignore_lockFilePath ) ;
if ( ! rsNotify - > setDisableAskPassword ( false ) ) return RsInit : : ERR_UNKOWN ;
if ( ! rsNotify - > clearPgpPassphrase ( ) ) return RsInit : : ERR_UNKOWN ;
2018-06-27 02:52:03 -04:00
if ( ret ! = RsInit : : OK ) return ret ;
if ( RsControl : : instance ( ) - > StartupRetroShare ( ) = = 1 ) return RsInit : : OK ;
return RsInit : : ERR_UNKOWN ;
}
2018-11-22 15:56:55 -05:00
/*static*/ bool RsLoginHelper : : collectEntropy ( uint32_t bytes )
{ return RsInit : : collectEntropy ( bytes ) ; }
2018-06-27 02:52:03 -04:00
void RsLoginHelper : : getLocations ( std : : vector < RsLoginHelper : : Location > & store )
{
std : : list < RsPeerId > locIds ;
RsAccounts : : GetAccountIds ( locIds ) ;
store . clear ( ) ;
for ( const RsPeerId & locId : locIds )
{
Location l ; l . mLocationId = locId ;
std : : string discardPgpMail ;
RsAccounts : : GetAccountDetails ( locId , l . mPgpId , l . mPpgName ,
discardPgpMail , l . mLocationName ) ;
store . push_back ( l ) ;
}
}
2018-06-28 06:06:43 -04:00
bool RsLoginHelper : : createLocation (
RsLoginHelper : : Location & l , const std : : string & password ,
2018-10-19 09:10:15 -04:00
std : : string & errorMessage , bool makeHidden , bool makeAutoTor )
2018-06-28 06:06:43 -04:00
{
2018-09-19 15:28:26 -04:00
if ( isLoggedIn ( ) ) return ( errorMessage = " Already Running " , false ) ;
2018-06-28 06:06:43 -04:00
if ( l . mLocationName . empty ( ) )
{
errorMessage = " Location name is needed " ;
return false ;
}
if ( l . mPgpId . isNull ( ) & & l . mPpgName . 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 ) )
{
errorMessage = " Failure creating PGP key: " + errorMessage ;
return false ;
}
2018-08-24 18:19:26 -04:00
std : : string sslPassword =
RSRandom : : random_alphaNumericString ( RsInit : : getSslPwdLen ( ) ) ;
2018-06-28 06:06:43 -04:00
if ( ! rsNotify - > cachePgpPassphrase ( password ) ) return false ;
if ( ! rsNotify - > setDisableAskPassword ( true ) ) return false ;
2018-08-22 10:59:42 -04:00
bool ret = RsAccounts : : createNewAccount (
2018-08-22 11:22:27 -04:00
l . mPgpId , " " , l . mLocationName , " " , makeHidden , makeAutoTor ,
2018-08-24 18:19:26 -04:00
sslPassword , l . mLocationId , errorMessage ) ;
ret = ret & & RsInit : : LoadPassword ( sslPassword ) ;
ret = ret & & RsInit : : OK = = attemptLogin ( l . mLocationId , password ) ;
2018-06-28 06:06:43 -04:00
rsNotify - > setDisableAskPassword ( false ) ;
return ret ;
}
2018-08-30 13:06:20 -04:00
bool RsLoginHelper : : isLoggedIn ( )
{
return RsControl : : instance ( ) - > isReady ( ) ;
}
2018-06-27 02:52:03 -04:00
void RsLoginHelper : : Location : : serial_process (
RsGenericSerializer : : SerializeJob j ,
RsGenericSerializer : : SerializeContext & ctx )
{
RS_SERIAL_PROCESS ( mLocationId ) ;
RS_SERIAL_PROCESS ( mPgpId ) ;
RS_SERIAL_PROCESS ( mLocationName ) ;
RS_SERIAL_PROCESS ( mPpgName ) ;
}
2018-08-30 13:06:20 -04:00
2018-09-05 20:04:48 -04:00
/*static*/ bool RsAccounts : : getCurrentAccountId ( RsPeerId & id )
2018-08-30 13:06:20 -04:00
{
return rsAccountsDetails - > getCurrentAccountId ( id ) ;
}