removed RETROTOR #ifdef and started using RsAccounts::isTorAuto() instead. Unfinished yet.

This commit is contained in:
csoler 2018-07-25 11:37:40 +02:00
parent 0f758902cd
commit d1a375cbd0
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
13 changed files with 294 additions and 270 deletions

View File

@ -23,13 +23,9 @@ TEMPLATE = subdirs
SUBDIRS += openpgpsdk SUBDIRS += openpgpsdk
openpgpsdk.file = openpgpsdk/src/openpgpsdk.pro openpgpsdk.file = openpgpsdk/src/openpgpsdk.pro
retrotor { SUBDIRS += libbitdht
libretroshare.depends = openpgpsdk libbitdht.file = libbitdht/src/libbitdht.pro
} else { libretroshare.depends = openpgpsdk libbitdht
SUBDIRS += libbitdht
libbitdht.file = libbitdht/src/libbitdht.pro
libretroshare.depends = openpgpsdk libbitdht
}
SUBDIRS += libretroshare SUBDIRS += libretroshare
libretroshare.file = libretroshare/src/libretroshare.pro libretroshare.file = libretroshare/src/libretroshare.pro
@ -45,15 +41,12 @@ retroshare_gui {
retroshare_gui.target = retroshare_gui retroshare_gui.target = retroshare_gui
} }
retrotor {
} else {
retroshare_nogui { retroshare_nogui {
SUBDIRS += retroshare_nogui SUBDIRS += retroshare_nogui
retroshare_nogui.file = retroshare-nogui/src/retroshare-nogui.pro retroshare_nogui.file = retroshare-nogui/src/retroshare-nogui.pro
retroshare_nogui.depends = libretroshare libresapi retroshare_nogui.depends = libretroshare libresapi
retroshare_nogui.target = retroshare_nogui retroshare_nogui.target = retroshare_nogui
} }
}
retroshare_android_service { retroshare_android_service {
SUBDIRS += retroshare_android_service SUBDIRS += retroshare_android_service

View File

@ -32,9 +32,6 @@ static struct RsLog::logInfo pqipersongrpzoneInfo = {RsLog::Default, "pqipersong
/**** /****
* #define PQI_DISABLE_UDP 1 * #define PQI_DISABLE_UDP 1
***/ ***/
#ifdef RETROTOR
#define PQI_DISABLE_UDP 1
#endif
/********************************** SSL Specific features ***************************/ /********************************** SSL Specific features ***************************/

View File

@ -181,6 +181,8 @@ public:
static bool getCurrentAccountOptions(bool& is_hidden,bool& is_tor_auto,bool& is_first_time) ; static bool getCurrentAccountOptions(bool& is_hidden,bool& is_tor_auto,bool& is_first_time) ;
static bool checkCreateAccountDirectory(); // Generate the hierarchy of directories below ~/.retroshare/[SSL dir]/ static bool checkCreateAccountDirectory(); // Generate the hierarchy of directories below ~/.retroshare/[SSL dir]/
static bool isHiddenNode() ; // true if the running node is a hidden node. Used to choose which services to start.
static bool isTorAuto() ; // true if the running node is a hidden node using automated Tor management
static std::string AccountDirectory(); // linux: ~/.retroshare/[SSL dir]/ static std::string AccountDirectory(); // linux: ~/.retroshare/[SSL dir]/
static std::string AccountKeysDirectory(); // linux: ~/.retroshare/[SSL dir]/keys/ static std::string AccountKeysDirectory(); // linux: ~/.retroshare/[SSL dir]/keys/

View File

@ -67,11 +67,8 @@ RsAccountsDetail::RsAccountsDetail() : mAccountsLocked(false), mPreferredId("")
bool RsAccountsDetail::loadAccounts() bool RsAccountsDetail::loadAccounts()
{ {
int failing_accounts ; int failing_accounts ;
#ifdef RETROTOR #warning we might need some switch here for hidden nodes only
getAvailableAccounts(mAccounts,failing_accounts,mUnsupportedKeys,true);
#else
getAvailableAccounts(mAccounts,failing_accounts,mUnsupportedKeys,false); getAvailableAccounts(mAccounts,failing_accounts,mUnsupportedKeys,false);
#endif
loadPreferredAccount(); loadPreferredAccount();
checkPreferredId(); checkPreferredId();
@ -612,7 +609,7 @@ bool RsAccountsDetail::getAvailableAccounts(std::map<RsPeerId, AccountDetails> &
valid_prefix = true; valid_prefix = true;
hidden_location = true; hidden_location = true;
auto_tor = RsDirUtil::checkDirectory(PathDataDirectory()+"/hidden_service"); auto_tor = RsDirUtil::checkDirectory(mBaseDirectory+"/"+*it+"/hidden_service");
} }
else else
{ {
@ -1371,6 +1368,34 @@ bool RsAccounts::getCurrentAccountOptions(bool& is_hidden,bool& is_tor_auto,bool
{ {
return rsAccounts->getCurrentAccountOptions(is_hidden,is_tor_auto,is_first_time); return rsAccounts->getCurrentAccountOptions(is_hidden,is_tor_auto,is_first_time);
} }
bool RsAccounts::isHiddenNode()
{
bool hidden = false ;
bool is_tor_only = false ;
bool is_first_time = false ;
if(!getCurrentAccountOptions(hidden,is_tor_only,is_first_time))
{
std::cerr << "(EE) Critical problem: RsAccounts::getCurrentAccountOptions() called but no account chosen!" << std::endl;
throw std::runtime_error("inconsistent configuration") ;
}
return hidden ;
}
bool RsAccounts::isTorAuto()
{
bool hidden = false ;
bool is_tor_only = false ;
bool is_first_time = false ;
if(!getCurrentAccountOptions(hidden,is_tor_only,is_first_time))
{
std::cerr << "(EE) Critical problem: RsAccounts::getCurrentAccountOptions() called but no account chosen!" << std::endl;
throw std::runtime_error("inconsistent configuration") ;
}
return is_tor_only ;
}
bool RsAccounts::GetAccountIds(std::list<RsPeerId> &ids) bool RsAccounts::GetAccountIds(std::list<RsPeerId> &ids)
{ {

View File

@ -657,7 +657,7 @@ int RsInit::LoadCertificates(bool autoLoginNT)
bool RsInit::RsClearAutoLogin() bool RsInit::RsClearAutoLogin()
{ {
RsPeerId preferredId; RsPeerId preferredId;
if (!rsAccounts->getPreferredAccountId(preferredId)) if (!RsAccounts::getSelectedAccountId(preferredId))
{ {
std::cerr << "RsInit::RsClearAutoLogin() No Account Selected" << std::endl; std::cerr << "RsInit::RsClearAutoLogin() No Account Selected" << std::endl;
return 0; return 0;
@ -817,11 +817,8 @@ RsGRouter *rsGRouter = NULL ;
#include "pqi/p3linkmgr.h" #include "pqi/p3linkmgr.h"
#include "pqi/p3netmgr.h" #include "pqi/p3netmgr.h"
#ifndef RETROTOR
#include "tcponudp/tou.h" #include "tcponudp/tou.h"
#include "tcponudp/rsudpstack.h" #include "tcponudp/rsudpstack.h"
#endif
#ifdef RS_USE_BITDHT #ifdef RS_USE_BITDHT
#include "dht/p3bitdht.h" #include "dht/p3bitdht.h"
@ -868,6 +865,17 @@ RsControl *RsControl::instance()
int RsServer::StartupRetroShare() int RsServer::StartupRetroShare()
{ {
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;
/**************************************************************************/ /**************************************************************************/
/* STARTUP procedure */ /* STARTUP procedure */
/**************************************************************************/ /**************************************************************************/
@ -883,8 +891,6 @@ int RsServer::StartupRetroShare()
return false ; return false ;
} }
RsPeerId ownId = AuthSSL::getAuthSSL()->OwnId();
/**************************************************************************/ /**************************************************************************/
/* Any Initial Configuration (Commandline Options) */ /* Any Initial Configuration (Commandline Options) */
/**************************************************************************/ /**************************************************************************/
@ -981,36 +987,40 @@ int RsServer::StartupRetroShare()
sockaddr_clear(&tmpladdr); sockaddr_clear(&tmpladdr);
tmpladdr.sin_port = htons(rsInitConfig->port); tmpladdr.sin_port = htons(rsInitConfig->port);
rsUdpStack *mDhtStack = NULL ;
if(!RsAccounts::isHiddenNode())
{
#ifdef LOCALNET_TESTING #ifdef LOCALNET_TESTING
rsUdpStack *mDhtStack = new rsUdpStack(UDP_TEST_RESTRICTED_LAYER, tmpladdr); mDhtStack = new rsUdpStack(UDP_TEST_RESTRICTED_LAYER, tmpladdr);
/* parse portRestrictions */ /* parse portRestrictions */
unsigned int lport, uport; unsigned int lport, uport;
if (doPortRestrictions) if (doPortRestrictions)
{
if (2 == sscanf(portRestrictions.c_str(), "%u-%u", &lport, &uport))
{ {
std::cerr << "Adding Port Restriction (" << lport << "-" << uport << ")"; if (2 == sscanf(portRestrictions.c_str(), "%u-%u", &lport, &uport))
std::cerr << std::endl; {
} std::cerr << "Adding Port Restriction (" << lport << "-" << uport << ")";
else std::cerr << std::endl;
{ }
std::cerr << "Failed to parse Port Restrictions ... exiting"; else
std::cerr << std::endl; {
exit(1); std::cerr << "Failed to parse Port Restrictions ... exiting";
} std::cerr << std::endl;
exit(1);
}
RestrictedUdpLayer *url = (RestrictedUdpLayer *) mDhtStack->getUdpLayer(); RestrictedUdpLayer *url = (RestrictedUdpLayer *) mDhtStack->getUdpLayer();
url->addRestrictedPortRange(lport, uport); url->addRestrictedPortRange(lport, uport);
} }
#else //LOCALNET_TESTING #else //LOCALNET_TESTING
#ifdef RS_USE_BITDHT #ifdef RS_USE_BITDHT
rsUdpStack *mDhtStack = new rsUdpStack(tmpladdr); mDhtStack = new rsUdpStack(tmpladdr);
#endif #endif
#endif //LOCALNET_TESTING #endif //LOCALNET_TESTING
}
#ifdef RS_USE_BITDHT #ifdef RS_USE_BITDHT
@ -1090,96 +1100,105 @@ int RsServer::StartupRetroShare()
/* construct the rest of the stack, important to build them in the correct order! */ /* 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! */ /* MOST OF THIS IS COMMENTED OUT UNTIL THE REST OF libretroshare IS READY FOR IT! */
UdpSubReceiver *udpReceivers[RSUDP_NUM_TOU_RECVERS]; p3BitDht *mBitDht = NULL ;
int udpTypes[RSUDP_NUM_TOU_RECVERS]; rsDht = NULL ;
rsFixedUdpStack *mProxyStack = NULL ;
#ifdef RS_USE_DHT_STUNNER if(!RsAccounts::isHiddenNode())
// FIRST DHT STUNNER.
UdpStunner *mDhtStunner = new UdpStunner(mDhtStack);
mDhtStunner->setTargetStunPeriod(300); /* slow (5mins) */
mDhtStack->addReceiver(mDhtStunner);
#ifdef LOCALNET_TESTING
mDhtStunner->SetAcceptLocalNet();
#endif
#endif // RS_USE_DHT_STUNNER
// NEXT BITDHT.
p3BitDht *mBitDht = new p3BitDht(ownId, mLinkMgr, mNetMgr, mDhtStack, bootstrapfile, filteredipfile);
/* install external Pointer for Interface */
rsDht = mBitDht;
// 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]);
// 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]);
// 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);
#ifdef LOCALNET_TESTING
// // HACK Proxy Port near Dht Port - For Relay Testing.
// uint16_t rndport = rsInitConfig->port + 3;
// sndladdr.sin_port = htons(rndport);
rsFixedUdpStack *mProxyStack = new rsFixedUdpStack(UDP_TEST_RESTRICTED_LAYER, sndladdr);
/* portRestrictions already parsed */
if (doPortRestrictions)
{ {
RestrictedUdpLayer *url = (RestrictedUdpLayer *) mProxyStack->getUdpLayer(); UdpSubReceiver *udpReceivers[RSUDP_NUM_TOU_RECVERS];
url->addRestrictedPortRange(lport, uport); int udpTypes[RSUDP_NUM_TOU_RECVERS];
}
#else
rsFixedUdpStack *mProxyStack = new rsFixedUdpStack(sndladdr);
#endif
#ifdef RS_USE_DHT_STUNNER #ifdef RS_USE_DHT_STUNNER
// FIRSTLY THE PROXY STUNNER. // FIRST DHT STUNNER.
UdpStunner *mProxyStunner = new UdpStunner(mProxyStack); UdpStunner *mDhtStunner = new UdpStunner(mDhtStack);
mProxyStunner->setTargetStunPeriod(300); /* slow (5mins) */ mDhtStunner->setTargetStunPeriod(300); /* slow (5mins) */
mProxyStack->addReceiver(mProxyStunner); mDhtStack->addReceiver(mDhtStunner);
#ifdef LOCALNET_TESTING #ifdef LOCALNET_TESTING
mProxyStunner->SetAcceptLocalNet(); mDhtStunner->SetAcceptLocalNet();
#endif #endif
#endif // RS_USE_DHT_STUNNER #endif // RS_USE_DHT_STUNNER
// FINALLY THE PROXY UDP CONNECTIONS // NEXT BITDHT.
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]);
// REAL INITIALISATION - WITH THREE MODES
tou_init((void **) udpReceivers, udpTypes, RSUDP_NUM_TOU_RECVERS); mBitDht = new p3BitDht(ownId, mLinkMgr, mNetMgr, mDhtStack, bootstrapfile, filteredipfile);
// 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]);
// 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]);
/* install external Pointer for Interface */
rsDht = mBitDht;
// 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);
#ifdef LOCALNET_TESTING
// // HACK Proxy Port near Dht Port - For Relay Testing.
// uint16_t rndport = rsInitConfig->port + 3;
// sndladdr.sin_port = htons(rndport);
mProxyStack = new rsFixedUdpStack(UDP_TEST_RESTRICTED_LAYER, sndladdr);
/* portRestrictions already parsed */
if (doPortRestrictions)
{
RestrictedUdpLayer *url = (RestrictedUdpLayer *) mProxyStack->getUdpLayer();
url->addRestrictedPortRange(lport, uport);
}
#else
mProxyStack = new rsFixedUdpStack(sndladdr);
#endif
#ifdef RS_USE_DHT_STUNNER #ifdef RS_USE_DHT_STUNNER
mBitDht->setupConnectBits(mDhtStunner, mProxyStunner, mRelay); // FIRSTLY THE PROXY STUNNER.
UdpStunner *mProxyStunner = new UdpStunner(mProxyStack);
mProxyStunner->setTargetStunPeriod(300); /* slow (5mins) */
mProxyStack->addReceiver(mProxyStunner);
#ifdef LOCALNET_TESTING
mProxyStunner->SetAcceptLocalNet();
#endif
#endif // RS_USE_DHT_STUNNER
// 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]);
// REAL INITIALISATION - WITH THREE MODES
tou_init((void **) udpReceivers, udpTypes, RSUDP_NUM_TOU_RECVERS);
#ifdef RS_USE_DHT_STUNNER
mBitDht->setupConnectBits(mDhtStunner, mProxyStunner, mRelay);
#else // RS_USE_DHT_STUNNER #else // RS_USE_DHT_STUNNER
mBitDht->setupConnectBits(mRelay); mBitDht->setupConnectBits(mRelay);
#endif // RS_USE_DHT_STUNNER #endif // RS_USE_DHT_STUNNER
#ifdef RS_USE_DHT_STUNNER #ifdef RS_USE_DHT_STUNNER
mNetMgr->setAddrAssist(new stunAddrAssist(mDhtStunner), new stunAddrAssist(mProxyStunner)); mNetMgr->setAddrAssist(new stunAddrAssist(mDhtStunner), new stunAddrAssist(mProxyStunner));
#endif // RS_USE_DHT_STUNNER #endif // RS_USE_DHT_STUNNER
// #else //RS_USE_BITDHT // #else //RS_USE_BITDHT
// /* install NULL Pointer for rsDht Interface */ // /* install NULL Pointer for rsDht Interface */
// rsDht = NULL; // rsDht = NULL;
#endif //RS_USE_BITDHT #endif //RS_USE_BITDHT
}
/**************************** BITDHT ***********************************/ /**************************** BITDHT ***********************************/
@ -1210,7 +1229,7 @@ int RsServer::StartupRetroShare()
std::vector<std::string> plugins_directories ; std::vector<std::string> plugins_directories ;
#ifdef __APPLE__ #ifdef __APPLE__
plugins_directories.push_back(rsAccounts->PathDataDirectory()) ; plugins_directories.push_back(RsAccounts::systemPathDataDirectory()) ;
#endif #endif
#if !defined(WINDOWS_SYS) && defined(PLUGIN_DIR) #if !defined(WINDOWS_SYS) && defined(PLUGIN_DIR)
plugins_directories.push_back(std::string(PLUGIN_DIR)) ; plugins_directories.push_back(std::string(PLUGIN_DIR)) ;
@ -1543,13 +1562,17 @@ int RsServer::StartupRetroShare()
#endif #endif
// new services to test. // new services to test.
#ifndef RETROTOR
p3BanList *mBanList = new p3BanList(serviceCtrl, mNetMgr); p3BanList *mBanList = NULL;
rsBanList = mBanList ;
pqih -> addService(mBanList, true); if(!RsAccounts::isHiddenNode())
#else {
rsBanList = NULL ; mBanList = new p3BanList(serviceCtrl, mNetMgr);
#endif rsBanList = mBanList ;
pqih -> addService(mBanList, true);
}
else
rsBanList = NULL ;
#ifdef RS_USE_BITDHT #ifdef RS_USE_BITDHT
mBitDht->setupPeerSharer(mBanList); mBitDht->setupPeerSharer(mBanList);
@ -1567,30 +1590,32 @@ int RsServer::StartupRetroShare()
/**************************************************************************/ /**************************************************************************/
if(!RsAccounts::isHiddenNode())
{
#ifdef RS_USE_BITDHT #ifdef RS_USE_BITDHT
mNetMgr->addNetAssistConnect(1, mBitDht); mNetMgr->addNetAssistConnect(1, mBitDht);
mNetMgr->addNetListener(mDhtStack); mNetMgr->addNetListener(mDhtStack);
mNetMgr->addNetListener(mProxyStack); mNetMgr->addNetListener(mProxyStack);
#endif #endif
#ifdef RS_ENABLE_ZEROCONF #ifdef RS_ENABLE_ZEROCONF
p3ZeroConf *mZeroConf = new p3ZeroConf( p3ZeroConf *mZeroConf = new p3ZeroConf(
AuthGPG::getAuthGPG()->getGPGOwnId(), ownId, AuthGPG::getAuthGPG()->getGPGOwnId(), ownId,
mLinkMgr, mNetMgr, mPeerMgr); mLinkMgr, mNetMgr, mPeerMgr);
mNetMgr->addNetAssistConnect(2, mZeroConf); mNetMgr->addNetAssistConnect(2, mZeroConf);
mNetMgr->addNetListener(mZeroConf); mNetMgr->addNetListener(mZeroConf);
#endif #endif
#ifdef RS_ENABLE_ZCNATASSIST #ifdef RS_ENABLE_ZCNATASSIST
// Apple's UPnP & NAT-PMP assistance. // Apple's UPnP & NAT-PMP assistance.
p3zcNatAssist *mZcNatAssist = new p3zcNatAssist(); p3zcNatAssist *mZcNatAssist = new p3zcNatAssist();
mNetMgr->addNetAssistFirewall(1, mZcNatAssist); mNetMgr->addNetAssistFirewall(1, mZcNatAssist);
#else #else
// Original UPnP Interface. // Original UPnP Interface.
pqiNetAssistFirewall *mUpnpMgr = new upnphandler(); pqiNetAssistFirewall *mUpnpMgr = new upnphandler();
mNetMgr->addNetAssistFirewall(1, mUpnpMgr); mNetMgr->addNetAssistFirewall(1, mUpnpMgr);
#endif #endif
}
/**************************************************************************/ /**************************************************************************/
/* need to Monitor too! */ /* need to Monitor too! */
@ -1623,9 +1648,10 @@ int RsServer::StartupRetroShare()
mConfigMgr->addConfiguration("p3History.cfg" , mHistoryMgr); mConfigMgr->addConfiguration("p3History.cfg" , mHistoryMgr);
mConfigMgr->addConfiguration("p3Status.cfg" , mStatusSrv); mConfigMgr->addConfiguration("p3Status.cfg" , mStatusSrv);
mConfigMgr->addConfiguration("turtle.cfg" , tr); mConfigMgr->addConfiguration("turtle.cfg" , tr);
#ifndef RETROTOR
mConfigMgr->addConfiguration("banlist.cfg" , mBanList); if(!RsAccounts::isHiddenNode())
#endif mConfigMgr->addConfiguration("banlist.cfg" , mBanList);
mConfigMgr->addConfiguration("servicecontrol.cfg", serviceCtrl); mConfigMgr->addConfiguration("servicecontrol.cfg", serviceCtrl);
mConfigMgr->addConfiguration("reputations.cfg" , mReputations); mConfigMgr->addConfiguration("reputations.cfg" , mReputations);
#ifdef ENABLE_GROUTER #ifdef ENABLE_GROUTER
@ -1896,6 +1922,10 @@ int RsServer::StartupRetroShare()
/* Startup this thread! */ /* Startup this thread! */
start("rs main") ; start("rs main") ;
std::cerr << "========================================================================" << std::endl;
std::cerr << "== RsInit:: Retroshare core started ==" << std::endl;
std::cerr << "========================================================================" << std::endl;
return 1; return 1;
} }

View File

@ -195,10 +195,10 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent)
ui.nodeType_CB->setCurrentIndex(1); ui.nodeType_CB->setCurrentIndex(1);
ui.nodeType_CB->setEnabled(false); ui.nodeType_CB->setEnabled(false);
#endif #endif
#ifdef RETROTOR //#ifdef RETROTOR
ui.adv_checkbox->setChecked(false); // ui.adv_checkbox->setChecked(false);
ui.adv_checkbox->setVisible(true); // ui.adv_checkbox->setVisible(true);
#endif //#endif
initKeyList(); initKeyList();
setupState(); setupState();
@ -258,12 +258,7 @@ void GenCertDialog::mouseMoveEvent(QMouseEvent *e)
void GenCertDialog::setupState() void GenCertDialog::setupState()
{ {
bool adv_state = ui.adv_checkbox->isChecked(); bool adv_state = ui.adv_checkbox->isChecked();
#ifdef RETROTOR
bool retrotor = true ;
#else
bool retrotor = false ; bool retrotor = false ;
#endif
if(!adv_state) if(!adv_state)
{ {

View File

@ -84,12 +84,13 @@
#include "statusbar/ToasterDisable.h" #include "statusbar/ToasterDisable.h"
#include "statusbar/SysTrayStatus.h" #include "statusbar/SysTrayStatus.h"
#include "statusbar/torstatus.h" #include "statusbar/torstatus.h"
#include <retroshare/rsstatus.h>
#include <retroshare/rsiface.h> #include "retroshare/rsstatus.h"
#include <retroshare/rspeers.h> #include "retroshare/rsiface.h"
#include <retroshare/rsfiles.h> #include "retroshare/rspeers.h"
#include <retroshare/rsnotify.h> #include "retroshare/rsfiles.h"
#include "retroshare/rsnotify.h"
#include "retroshare/rsinit.h"
#include "gui/gxschannels/GxsChannelDialog.h" #include "gui/gxschannels/GxsChannelDialog.h"
#include "gui/gxsforums/GxsForumsDialog.h" #include "gui/gxsforums/GxsForumsDialog.h"
@ -250,14 +251,15 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags)
if(hiddenmode) if(hiddenmode)
{ {
#ifdef RETROTOR if(RsAccounts::isHiddenNode())
torstatus = new TorStatus(); {
torstatus->setVisible(Settings->valueFromGroup("StatusBar", "ShowTor", QVariant(true)).toBool()); torstatus = new TorStatus();
statusBar()->addWidget(torstatus); torstatus->setVisible(Settings->valueFromGroup("StatusBar", "ShowTor", QVariant(true)).toBool());
torstatus->getTorStatus(); statusBar()->addWidget(torstatus);
#else torstatus->getTorStatus();
torstatus = NULL ; }
#endif else
torstatus = NULL ;
natstatus = NULL ; natstatus = NULL ;
dhtstatus = NULL ; dhtstatus = NULL ;

View File

@ -29,11 +29,12 @@
#include <iostream> #include <iostream>
#include <retroshare/rsbanlist.h> #include "retroshare/rsbanlist.h"
#include <retroshare/rsconfig.h> #include "retroshare/rsconfig.h"
#include <retroshare/rsdht.h> #include "retroshare/rsdht.h"
#include <retroshare/rspeers.h> #include "retroshare/rspeers.h"
#include <retroshare/rsturtle.h> #include "retroshare/rsturtle.h"
#include "retroshare/rsinit.h"
#include <QCheckBox> #include <QCheckBox>
#include <QMovie> #include <QMovie>
@ -62,15 +63,6 @@
/// ///
// Tabs numbers *after* non relevant tabs are removed. So do not use them to add/remove tabs!! // Tabs numbers *after* non relevant tabs are removed. So do not use them to add/remove tabs!!
#ifdef RETROTOR
static const uint32_t TAB_HIDDEN_SERVICE_OUTGOING = 0;
static const uint32_t TAB_HIDDEN_SERVICE_INCOMING = 1;
static const uint32_t TAB_NETWORK = 0;
static const uint32_t TAB_HIDDEN_SERVICE = 1;
static const uint32_t TAB_IP_FILTERS = 99; // This is a trick: these tabs do not exist, so enabling/disabling them has no effect
static const uint32_t TAB_RELAYS = 99;
#else
const static uint32_t TAB_HIDDEN_SERVICE_OUTGOING = 0; const static uint32_t TAB_HIDDEN_SERVICE_OUTGOING = 0;
const static uint32_t TAB_HIDDEN_SERVICE_INCOMING = 2; const static uint32_t TAB_HIDDEN_SERVICE_INCOMING = 2;
@ -78,7 +70,6 @@ const static uint32_t TAB_NETWORK = 0;
const static uint32_t TAB_IP_FILTERS = 1; const static uint32_t TAB_IP_FILTERS = 1;
const static uint32_t TAB_HIDDEN_SERVICE = 2; const static uint32_t TAB_HIDDEN_SERVICE = 2;
const static uint32_t TAB_RELAYS = 3; const static uint32_t TAB_RELAYS = 3;
#endif
//#define SERVER_DEBUG 1 //#define SERVER_DEBUG 1
@ -90,7 +81,8 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
manager = NULL ; manager = NULL ;
#ifdef RETROTOR if(RsAccounts::isTorAuto())
{
// Here we use absolute numbers instead of consts defined above, because the consts correspond to the tab number *after* this tab removal. // Here we use absolute numbers instead of consts defined above, because the consts correspond to the tab number *after* this tab removal.
ui.tabWidget->removeTab(3) ; // remove relays. Not useful in Tor mode. ui.tabWidget->removeTab(3) ; // remove relays. Not useful in Tor mode.
@ -109,7 +101,8 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
ui.hiddenpage_outHeader->setText(tr("Tor has been automatically configured by Retroshare. You shouldn't need to change anything here.")) ; ui.hiddenpage_outHeader->setText(tr("Tor has been automatically configured by Retroshare. You shouldn't need to change anything here.")) ;
ui.hiddenpage_inHeader->setText(tr("Tor has been automatically configured by Retroshare. You shouldn't need to change anything here.")) ; ui.hiddenpage_inHeader->setText(tr("Tor has been automatically configured by Retroshare. You shouldn't need to change anything here.")) ;
#endif }
ui.filteredIpsTable->setHorizontalHeaderItem(COLUMN_RANGE,new QTableWidgetItem(tr("IP Range"))) ; ui.filteredIpsTable->setHorizontalHeaderItem(COLUMN_RANGE,new QTableWidgetItem(tr("IP Range"))) ;
ui.filteredIpsTable->setHorizontalHeaderItem(COLUMN_STATUS,new QTableWidgetItem(tr("Status"))) ; ui.filteredIpsTable->setHorizontalHeaderItem(COLUMN_STATUS,new QTableWidgetItem(tr("Status"))) ;
ui.filteredIpsTable->setHorizontalHeaderItem(COLUMN_ORIGIN,new QTableWidgetItem(tr("Origin"))) ; ui.filteredIpsTable->setHorizontalHeaderItem(COLUMN_ORIGIN,new QTableWidgetItem(tr("Origin"))) ;

View File

@ -187,9 +187,7 @@ public:
/** Sets whether the bandwidth graph is always on top. */ /** Sets whether the bandwidth graph is always on top. */
void setBWGraphAlwaysOnTop(bool alwaysOnTop); void setBWGraphAlwaysOnTop(bool alwaysOnTop);
#ifdef RETROTOR
void setHiddenServiceKey() ; void setHiddenServiceKey() ;
#endif
uint getNewsFeedFlags(); uint getNewsFeedFlags();
void setNewsFeedFlags(uint flags); void setNewsFeedFlags(uint flags);

View File

@ -26,12 +26,11 @@
#include <QPixmap> #include <QPixmap>
#include "retroshare/rsconfig.h" #include "retroshare/rsconfig.h"
#include "retroshare/rsinit.h"
#include "util/misc.h" #include "util/misc.h"
#ifdef RETROTOR
#include "TorControl/TorManager.h" #include "TorControl/TorManager.h"
#include "TorControl/TorControl.h" #include "TorControl/TorControl.h"
#endif
#include <iomanip> #include <iomanip>
@ -86,53 +85,56 @@ void TorStatus::getTorStatus()
int S = QFontMetricsF(torstatusLabel->font()).height(); int S = QFontMetricsF(torstatusLabel->font()).height();
#ifdef RETROTOR if(RsAccounts::isTorAuto())
// get Tor status
int tor_control_status = Tor::TorManager::instance()->control()->status();
int torstatus = Tor::TorManager::instance()->control()->torStatus();
QString tor_control_status_str,torstatus_str ;
bool tor_control_ok ;
switch(tor_control_status)
{ {
default: // get Tor status
case Tor::TorControl::Error : tor_control_ok = false ; tor_control_status_str = "Error" ; break ; int tor_control_status = Tor::TorManager::instance()->control()->status();
case Tor::TorControl::NotConnected: tor_control_ok = false ; tor_control_status_str = "Not connected" ; break ; int torstatus = Tor::TorManager::instance()->control()->torStatus();
case Tor::TorControl::Connecting: tor_control_ok = false ; tor_control_status_str = "Connecting" ; break ;
case Tor::TorControl::Authenticating: tor_control_ok = false ; tor_control_status_str = "Authenticating" ; break ;
case Tor::TorControl::Connected: tor_control_ok = true ; tor_control_status_str = "Connected" ; break ;
}
switch(torstatus) QString tor_control_status_str,torstatus_str ;
{ bool tor_control_ok ;
default:
case Tor::TorControl::TorUnknown: torstatus_str = "Unknown" ; break ; switch(tor_control_status)
case Tor::TorControl::TorOffline: torstatus_str = "Tor offline" ; break ; {
case Tor::TorControl::TorReady: torstatus_str = "Tor ready" ; break ; default:
} case Tor::TorControl::Error : tor_control_ok = false ; tor_control_status_str = "Error" ; break ;
case Tor::TorControl::NotConnected: tor_control_ok = false ; tor_control_status_str = "Not connected" ; break ;
case Tor::TorControl::Connecting: tor_control_ok = false ; tor_control_status_str = "Connecting" ; break ;
case Tor::TorControl::Authenticating: tor_control_ok = false ; tor_control_status_str = "Authenticating" ; break ;
case Tor::TorControl::Connected: tor_control_ok = true ; tor_control_status_str = "Connected" ; break ;
}
switch(torstatus)
{
default:
case Tor::TorControl::TorUnknown: torstatus_str = "Unknown" ; break ;
case Tor::TorControl::TorOffline: torstatus_str = "Tor offline" ; break ;
case Tor::TorControl::TorReady: torstatus_str = "Tor ready" ; break ;
}
#define MIN_RS_NET_SIZE 10 #define MIN_RS_NET_SIZE 10
if(torstatus == Tor::TorControl::TorOffline || !online || !tor_control_ok) if(torstatus == Tor::TorControl::TorOffline || !online || !tor_control_ok)
{
// RED - some issue.
torstatusLabel->setPixmap(QPixmap(":/icons/tor-stopping.png").scaledToHeight(1.5*S,Qt::SmoothTransformation));
torstatusLabel->setToolTip( text + tr("Tor is currently offline"));
}
else if(torstatus == Tor::TorControl::TorReady && online && tor_control_ok)
{
torstatusLabel->setPixmap(QPixmap(":/icons/tor-on.png").scaledToHeight(1.5*S,Qt::SmoothTransformation));
torstatusLabel->setToolTip( text + tr("Tor is OK"));
}
else // torstatus == Tor::TorControl::TorUnknown
{
// GRAY.
torstatusLabel->setPixmap(QPixmap(":/icons/no-tor.png").scaledToHeight(1.5*S,Qt::SmoothTransformation));
torstatusLabel->setToolTip( text + tr("No tor configuration"));
}
}
else
{ {
// RED - some issue. torstatusLabel->setPixmap(QPixmap(":/icons/tor-stopping.png").scaledToHeight(S,Qt::SmoothTransformation));
torstatusLabel->setPixmap(QPixmap(":/icons/tor-stopping.png").scaledToHeight(1.5*S,Qt::SmoothTransformation));
torstatusLabel->setToolTip( text + tr("Tor is currently offline")); torstatusLabel->setToolTip( text + tr("Tor is currently offline"));
} }
else if(torstatus == Tor::TorControl::TorReady && online && tor_control_ok)
{
torstatusLabel->setPixmap(QPixmap(":/icons/tor-on.png").scaledToHeight(1.5*S,Qt::SmoothTransformation));
torstatusLabel->setToolTip( text + tr("Tor is OK"));
}
else // torstatus == Tor::TorControl::TorUnknown
{
// GRAY.
torstatusLabel->setPixmap(QPixmap(":/icons/no-tor.png").scaledToHeight(1.5*S,Qt::SmoothTransformation));
torstatusLabel->setToolTip( text + tr("No tor configuration"));
}
#else
torstatusLabel->setPixmap(QPixmap(":/icons/tor-stopping.png").scaledToHeight(S,Qt::SmoothTransformation));
torstatusLabel->setToolTip( text + tr("Tor is currently offline"));
#endif
} }

View File

@ -51,10 +51,8 @@
# include "gui/settings/WebuiPage.h" # include "gui/settings/WebuiPage.h"
#endif #endif
#ifdef RETROTOR #include "TorControl/TorManager.h"
# include "TorControl/TorManager.h" #include "TorControl/TorControlWindow.h"
# include "TorControl/TorControlWindow.h"
#endif
#include "retroshare/rsidentity.h" #include "retroshare/rsidentity.h"
#include "retroshare/rspeers.h" #include "retroshare/rspeers.h"
@ -355,8 +353,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
RsAccounts::getCurrentAccountOptions(is_hidden_node,is_auto_tor,is_first_time); RsAccounts::getCurrentAccountOptions(is_hidden_node,is_auto_tor,is_first_time);
#ifdef UNFINISHED if(is_auto_tor)
if(RsAccounts::AccountType() == RS_ACCOUNT_TYPE_HIDDEN_TOR_AUTO)
{ {
// Now that we know the Tor service running, and we know the SSL id, we can make sure it provides a viable hidden service // Now that we know the Tor service running, and we know the SSL id, we can make sure it provides a viable hidden service
@ -402,7 +399,6 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
} }
} }
} }
#endif
QSplashScreen splashScreen(QPixmap(":/images/logo/logo_splash.png")/* , Qt::WindowStaysOnTopHint*/); QSplashScreen splashScreen(QPixmap(":/images/logo/logo_splash.png")/* , Qt::WindowStaysOnTopHint*/);
@ -418,33 +414,35 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
return 1; return 1;
} }
#ifdef RETROTOR if(is_auto_tor)
// Tor works with viable hidden service. Let's use it! {
// Tor works with viable hidden service. Let's use it!
QString service_id ; QString service_id ;
QString onion_address ; QString onion_address ;
uint16_t service_port ; uint16_t service_port ;
uint16_t service_target_port ; uint16_t service_target_port ;
uint16_t proxy_server_port ; uint16_t proxy_server_port ;
QHostAddress service_target_address ; QHostAddress service_target_address ;
QHostAddress proxy_server_address ; QHostAddress proxy_server_address ;
torManager->getHiddenServiceInfo(service_id,onion_address,service_port,service_target_address,service_target_port); Tor::TorManager *torManager = Tor::TorManager::instance();
torManager->getProxyServerInfo(proxy_server_address,proxy_server_port) ; torManager->getHiddenServiceInfo(service_id,onion_address,service_port,service_target_address,service_target_port);
torManager->getProxyServerInfo(proxy_server_address,proxy_server_port) ;
std::cerr << "Got hidden service info: " << std::endl; std::cerr << "Got hidden service info: " << std::endl;
std::cerr << " onion address : " << onion_address.toStdString() << std::endl; std::cerr << " onion address : " << onion_address.toStdString() << std::endl;
std::cerr << " service_id : " << service_id.toStdString() << std::endl; std::cerr << " service_id : " << service_id.toStdString() << std::endl;
std::cerr << " service port : " << service_port << std::endl; std::cerr << " service port : " << service_port << std::endl;
std::cerr << " target port : " << service_target_port << std::endl; std::cerr << " target port : " << service_target_port << std::endl;
std::cerr << " target address : " << service_target_address.toString().toStdString() << std::endl; std::cerr << " target address : " << service_target_address.toString().toStdString() << std::endl;
std::cerr << "Setting proxy server to " << service_target_address.toString().toStdString() << ":" << service_target_port << std::endl; std::cerr << "Setting proxy server to " << service_target_address.toString().toStdString() << ":" << service_target_port << std::endl;
rsPeers->setLocalAddress(rsPeers->getOwnId(), service_target_address.toString().toStdString(), service_target_port); rsPeers->setLocalAddress(rsPeers->getOwnId(), service_target_address.toString().toStdString(), service_target_port);
rsPeers->setHiddenNode(rsPeers->getOwnId(), onion_address.toStdString(), service_port); rsPeers->setHiddenNode(rsPeers->getOwnId(), onion_address.toStdString(), service_port);
rsPeers->setProxyServer(RS_HIDDEN_TYPE_TOR, proxy_server_address.toString().toStdString(),proxy_server_port) ; rsPeers->setProxyServer(RS_HIDDEN_TYPE_TOR, proxy_server_address.toString().toStdString(),proxy_server_port) ;
#endif }
Rshare::initPlugins(); Rshare::initPlugins();

View File

@ -19,11 +19,9 @@ libresapihttpserver {
!include("../../libretroshare/src/use_libretroshare.pri"):error("Including") !include("../../libretroshare/src/use_libretroshare.pri"):error("Including")
retrotor { FORMS += TorControl/TorControlWindow.ui
FORMS += TorControl/TorControlWindow.ui SOURCES += TorControl/TorControlWindow.cpp
SOURCES += TorControl/TorControlWindow.cpp HEADERS += TorControl/TorControlWindow.h
HEADERS += TorControl/TorControlWindow.h
}
#QMAKE_CFLAGS += -fmudflap #QMAKE_CFLAGS += -fmudflap
#LIBS *= /usr/lib/gcc/x86_64-linux-gnu/4.4/libmudflap.a /usr/lib/gcc/x86_64-linux-gnu/4.4/libmudflapth.a #LIBS *= /usr/lib/gcc/x86_64-linux-gnu/4.4/libmudflap.a /usr/lib/gcc/x86_64-linux-gnu/4.4/libmudflapth.a
@ -285,7 +283,8 @@ wikipoos {
LIBS *= $$OUT_PWD/../../supportlibs/pegmarkdown/lib/libpegmarkdown.a LIBS *= $$OUT_PWD/../../supportlibs/pegmarkdown/lib/libpegmarkdown.a
} }
retrotor { # Tor controller
HEADERS += TorControl/AddOnionCommand.h \ HEADERS += TorControl/AddOnionCommand.h \
TorControl/AuthenticateCommand.h \ TorControl/AuthenticateCommand.h \
TorControl/GetConfCommand.h \ TorControl/GetConfCommand.h \
@ -324,7 +323,6 @@ SOURCES += TorControl/AddOnionCommand.cpp \
TorControl/SecureRNG.cpp \ TorControl/SecureRNG.cpp \
TorControl/Settings.cpp \ TorControl/Settings.cpp \
TorControl/StrUtil.cpp TorControl/StrUtil.cpp
}
# Input # Input
HEADERS += rshare.h \ HEADERS += rshare.h \

View File

@ -91,15 +91,6 @@ no_sqlcipher:CONFIG -= sqlcipher
CONFIG *= no_rs_autologin CONFIG *= no_rs_autologin
rs_autologin:CONFIG -= no_rs_autologin rs_autologin:CONFIG -= no_rs_autologin
# To build RetroShare Tor only version with automatic hidden node setup append
# the following assignation to qmake command line "CONFIG+=retrotor"
CONFIG *= no_retrotor
retrotor {
CONFIG -= no_retrotor
CONFIG *= rs_onlyhiddennode
DEFINES *= RETROTOR
}
# To have only hidden node generation append the following assignation # To have only hidden node generation append the following assignation
# to qmake command line "CONFIG+=rs_onlyhiddennode" # to qmake command line "CONFIG+=rs_onlyhiddennode"
CONFIG *= no_rs_onlyhiddennode CONFIG *= no_rs_onlyhiddennode
@ -144,7 +135,7 @@ rs_macos10.10:CONFIG -= rs_macos10.11
rs_macos10.12:CONFIG -= rs_macos10.11 rs_macos10.12:CONFIG -= rs_macos10.11
# To disable deep search append the following assignation to qmake command line # To disable deep search append the following assignation to qmake command line
# "CONFIG+=no_rs_deep_search" CONFIG+=no_rs_deep_search
CONFIG *= rs_deep_search CONFIG *= rs_deep_search
no_rs_deep_search:CONFIG -= rs_deep_search no_rs_deep_search:CONFIG -= rs_deep_search