mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-14 17:07:17 -05:00
fixed certificate creation in TorAuto mode
This commit is contained in:
parent
22bc40e3cc
commit
cc1a05ddc9
@ -467,6 +467,8 @@ void RsControlModule::handleCreateLocation(Request &req, Response &resp)
|
|||||||
req.mStream << makeKeyValueReference("hidden_adress", hidden_address)
|
req.mStream << makeKeyValueReference("hidden_adress", hidden_address)
|
||||||
<< makeKeyValueReference("hidden_port", hidden_port_str);
|
<< makeKeyValueReference("hidden_port", hidden_port_str);
|
||||||
uint16_t hidden_port = 0;
|
uint16_t hidden_port = 0;
|
||||||
|
bool auto_tor = false ; // to be set by API, so disabled until then.
|
||||||
|
|
||||||
if(hidden_address.empty() != hidden_port_str.empty())
|
if(hidden_address.empty() != hidden_port_str.empty())
|
||||||
{
|
{
|
||||||
resp.setFail("you must both specify string hidden_adress and string hidden_port to create a hidden node.");
|
resp.setFail("you must both specify string hidden_adress and string hidden_port to create a hidden node.");
|
||||||
@ -539,7 +541,7 @@ void RsControlModule::handleCreateLocation(Request &req, Response &resp)
|
|||||||
mPassword = pgp_password;
|
mPassword = pgp_password;
|
||||||
mFixedPassword = pgp_password;
|
mFixedPassword = pgp_password;
|
||||||
}
|
}
|
||||||
bool ssl_ok = RsAccounts::createNewAccount(pgp_id, "", ssl_name, "", hidden_port!=0, ssl_password, ssl_id, err_string);
|
bool ssl_ok = RsAccounts::createNewAccount(pgp_id, "", ssl_name, "", hidden_port!=0, auto_tor!=0, ssl_password, ssl_id, err_string);
|
||||||
|
|
||||||
// clear fixed password to restore normal password operation
|
// clear fixed password to restore normal password operation
|
||||||
// {
|
// {
|
||||||
|
@ -170,7 +170,7 @@ public:
|
|||||||
|
|
||||||
static bool GetAccountDetails(const RsPeerId &id, RsPgpId &gpgId, std::string &gpgName, std::string &gpgEmail, std::string &location);
|
static bool GetAccountDetails(const RsPeerId &id, RsPgpId &gpgId, std::string &gpgName, std::string &gpgEmail, std::string &location);
|
||||||
|
|
||||||
static bool createNewAccount(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString);
|
static bool createNewAccount(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, bool ishiddenloc,bool is_auto_tor, const std::string& passwd, RsPeerId &sslId, std::string &errString);
|
||||||
|
|
||||||
static void storeSelectedAccount() ;
|
static void storeSelectedAccount() ;
|
||||||
|
|
||||||
|
@ -988,7 +988,7 @@ bool RsAccountsDetail::copyGnuPGKeyrings()
|
|||||||
|
|
||||||
|
|
||||||
/* Create SSL Certificates */
|
/* Create SSL Certificates */
|
||||||
bool RsAccountsDetail::GenerateSSLCertificate(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString)
|
bool RsAccountsDetail::GenerateSSLCertificate(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, bool ishiddenloc,bool isautotor, const std::string& passwd, RsPeerId &sslId, std::string &errString)
|
||||||
{
|
{
|
||||||
/* select the PGP Identity first */
|
/* select the PGP Identity first */
|
||||||
if (!SelectPGPAccount(pgp_id))
|
if (!SelectPGPAccount(pgp_id))
|
||||||
@ -1141,6 +1141,7 @@ bool RsAccountsDetail::GenerateSSLCertificate(const RsPgpId& pgp_id, const s
|
|||||||
|
|
||||||
newAccount.mLocation = loc;
|
newAccount.mLocation = loc;
|
||||||
newAccount.mIsHiddenLoc = ishiddenloc;
|
newAccount.mIsHiddenLoc = ishiddenloc;
|
||||||
|
newAccount.mIsAutoTor = isautotor;
|
||||||
|
|
||||||
newAccount.mFirstRun = true;
|
newAccount.mFirstRun = true;
|
||||||
|
|
||||||
@ -1409,9 +1410,9 @@ bool RsAccounts::GetAccountDetails(const RsPeerId &id,
|
|||||||
return rsAccounts->getCurrentAccountDetails(id, pgpId, pgpName, pgpEmail, location);
|
return rsAccounts->getCurrentAccountDetails(id, pgpId, pgpName, pgpEmail, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsAccounts::createNewAccount(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString)
|
bool RsAccounts::createNewAccount(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, bool ishiddenloc, bool isautotor, const std::string& passwd, RsPeerId &sslId, std::string &errString)
|
||||||
{
|
{
|
||||||
return rsAccounts->GenerateSSLCertificate(pgp_id, org, loc, country, ishiddenloc, passwd, sslId, errString);
|
return rsAccounts->GenerateSSLCertificate(pgp_id, org, loc, country, ishiddenloc, isautotor, passwd, sslId, errString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
|
@ -87,7 +87,7 @@ class RsAccountsDetail
|
|||||||
|
|
||||||
// Generate a new account based on a given PGP key returns its SSL id and sets it to be the preferred account.
|
// Generate a new account based on a given PGP key returns its SSL id and sets it to be the preferred account.
|
||||||
|
|
||||||
bool GenerateSSLCertificate(const RsPgpId& gpg_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString);
|
bool GenerateSSLCertificate(const RsPgpId& gpg_id, const std::string& org, const std::string& loc, const std::string& country, bool ishiddenloc, bool is_auto_tor,const std::string& passwd, RsPeerId &sslId, std::string &errString);
|
||||||
|
|
||||||
// PGP Accounts.
|
// PGP Accounts.
|
||||||
|
|
||||||
|
@ -67,17 +67,17 @@ public:
|
|||||||
enum Status
|
enum Status
|
||||||
{
|
{
|
||||||
Error = -1,
|
Error = -1,
|
||||||
NotConnected,
|
NotConnected = 0x00,
|
||||||
Connecting,
|
Connecting = 0x01,
|
||||||
Authenticating,
|
Authenticating = 0x02,
|
||||||
Connected
|
Connected = 0x03
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TorStatus
|
enum TorStatus
|
||||||
{
|
{
|
||||||
TorUnknown,
|
TorUnknown = 0x00,
|
||||||
TorOffline,
|
TorOffline = 0x01,
|
||||||
TorReady
|
TorReady = 0x02
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,12 +118,17 @@ TorProcess *TorManager::process()
|
|||||||
return d->process;
|
return d->process;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TorManager::dataDirectory() const
|
bool TorManager::isTorAvailable()
|
||||||
|
{
|
||||||
|
return !instance()->d->torExecutablePath().isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TorManager::torDataDirectory() const
|
||||||
{
|
{
|
||||||
return d->dataDir;
|
return d->dataDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorManager::setDataDirectory(const QString &path)
|
void TorManager::setTorDataDirectory(const QString &path)
|
||||||
{
|
{
|
||||||
d->dataDir = QDir::fromNativeSeparators(path);
|
d->dataDir = QDir::fromNativeSeparators(path);
|
||||||
|
|
||||||
|
@ -58,18 +58,18 @@ class TorManager : public QObject
|
|||||||
Q_PROPERTY(Tor::TorControl* control READ control CONSTANT)
|
Q_PROPERTY(Tor::TorControl* control READ control CONSTANT)
|
||||||
Q_PROPERTY(bool hasError READ hasError NOTIFY errorChanged)
|
Q_PROPERTY(bool hasError READ hasError NOTIFY errorChanged)
|
||||||
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorChanged)
|
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorChanged)
|
||||||
Q_PROPERTY(QString dataDirectory READ dataDirectory WRITE setDataDirectory)
|
Q_PROPERTY(QString torDataDirectory READ torDataDirectory WRITE setTorDataDirectory)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static bool isTorAvailable() ;
|
||||||
explicit TorManager(QObject *parent = 0);
|
|
||||||
static TorManager *instance();
|
static TorManager *instance();
|
||||||
|
|
||||||
TorProcess *process();
|
TorProcess *process();
|
||||||
TorControl *control();
|
TorControl *control();
|
||||||
|
|
||||||
QString dataDirectory() const;
|
|
||||||
void setDataDirectory(const QString &path);
|
QString torDataDirectory() const;
|
||||||
|
void setTorDataDirectory(const QString &path);
|
||||||
|
|
||||||
QString hiddenServiceDirectory() const;
|
QString hiddenServiceDirectory() const;
|
||||||
void setHiddenServiceDirectory(const QString &path);
|
void setHiddenServiceDirectory(const QString &path);
|
||||||
@ -100,6 +100,7 @@ signals:
|
|||||||
void errorChanged();
|
void errorChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
explicit TorManager(QObject *parent = 0);
|
||||||
TorManagerPrivate *d;
|
TorManagerPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include <rshare.h>
|
#include <rshare.h>
|
||||||
#include "gui/settings/rsharesettings.h"
|
#include "gui/settings/rsharesettings.h"
|
||||||
|
#include "TorControl/TorManager.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
|
|
||||||
#include <retroshare/rsidentity.h>
|
#include <retroshare/rsidentity.h>
|
||||||
@ -479,7 +480,6 @@ void GenCertDialog::genPerson()
|
|||||||
/* Check the data from the GUI. */
|
/* Check the data from the GUI. */
|
||||||
std::string genLoc = ui.node_input->text().toUtf8().constData();
|
std::string genLoc = ui.node_input->text().toUtf8().constData();
|
||||||
RsPgpId PGPId;
|
RsPgpId PGPId;
|
||||||
bool isHiddenLoc = false;
|
|
||||||
|
|
||||||
if(ui.nickname_input->isVisible())
|
if(ui.nickname_input->isVisible())
|
||||||
{
|
{
|
||||||
@ -512,18 +512,26 @@ void GenCertDialog::genPerson()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ui.nodeType_CB->currentIndex()==1)
|
bool isHiddenLoc = (ui.nodeType_CB->currentIndex()>0);
|
||||||
|
bool isAutoTor = (ui.nodeType_CB->currentIndex()==1);
|
||||||
|
|
||||||
|
if(isAutoTor && !Tor::TorManager::isTorAvailable())
|
||||||
|
{
|
||||||
|
QMessageBox::critical(this,tr("Tor is not available"),tr("No Tor executable has been found on your system. You need to install Tor before creating a hidden identity.")) ;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isHiddenLoc)
|
||||||
{
|
{
|
||||||
std::string hl = ui.hiddenaddr_input->text().toStdString();
|
std::string hl = ui.hiddenaddr_input->text().toStdString();
|
||||||
uint16_t port = ui.hiddenport_spinBox->value();
|
uint16_t port = ui.hiddenport_spinBox->value();
|
||||||
|
|
||||||
bool useBob = ui.cbUseBob->isChecked();
|
bool useBob = ui.cbUseBob->isChecked();
|
||||||
|
|
||||||
if (useBob && hl.empty())
|
if (useBob && hl.empty())
|
||||||
hl = "127.0.0.1";
|
hl = "127.0.0.1";
|
||||||
|
|
||||||
RsInit::SetHiddenLocation(hl, port, useBob); /* parses it */
|
RsInit::SetHiddenLocation(hl, port, useBob); /* parses it */
|
||||||
|
|
||||||
isHiddenLoc = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -629,7 +637,7 @@ void GenCertDialog::genPerson()
|
|||||||
std::string err;
|
std::string err;
|
||||||
this->hide();//To show dialog asking password PGP Key.
|
this->hide();//To show dialog asking password PGP Key.
|
||||||
std::cout << "RsAccounts::GenerateSSLCertificate" << std::endl;
|
std::cout << "RsAccounts::GenerateSSLCertificate" << std::endl;
|
||||||
bool okGen = RsAccounts::createNewAccount(PGPId, "", genLoc, "", isHiddenLoc, sslPasswd, sslId, err);
|
bool okGen = RsAccounts::createNewAccount(PGPId, "", genLoc, "", isHiddenLoc, isAutoTor, sslPasswd, sslId, err);
|
||||||
|
|
||||||
if (okGen)
|
if (okGen)
|
||||||
{
|
{
|
||||||
|
@ -360,7 +360,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
|
|||||||
QString tor_hidden_service_dir = QString::fromStdString(RsAccounts::AccountDirectory()) + QString("/hidden_service/") ;
|
QString tor_hidden_service_dir = QString::fromStdString(RsAccounts::AccountDirectory()) + QString("/hidden_service/") ;
|
||||||
|
|
||||||
Tor::TorManager *torManager = Tor::TorManager::instance();
|
Tor::TorManager *torManager = Tor::TorManager::instance();
|
||||||
torManager->setDataDirectory(Rshare::dataDirectory() + QString("/tor/"));
|
torManager->setTorDataDirectory(Rshare::dataDirectory() + QString("/tor/"));
|
||||||
torManager->setHiddenServiceDirectory(tor_hidden_service_dir); // re-set it, because now it's changed to the specific location that is run
|
torManager->setHiddenServiceDirectory(tor_hidden_service_dir); // re-set it, because now it's changed to the specific location that is run
|
||||||
|
|
||||||
RsDirUtil::checkCreateDirectory(std::string(tor_hidden_service_dir.toUtf8())) ;
|
RsDirUtil::checkCreateDirectory(std::string(tor_hidden_service_dir.toUtf8())) ;
|
||||||
|
Loading…
Reference in New Issue
Block a user