mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04: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)
|
||||
<< makeKeyValueReference("hidden_port", hidden_port_str);
|
||||
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())
|
||||
{
|
||||
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;
|
||||
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
|
||||
// {
|
||||
|
@ -170,7 +170,7 @@ public:
|
||||
|
||||
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() ;
|
||||
|
||||
|
@ -988,7 +988,7 @@ bool RsAccountsDetail::copyGnuPGKeyrings()
|
||||
|
||||
|
||||
/* 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 */
|
||||
if (!SelectPGPAccount(pgp_id))
|
||||
@ -1141,6 +1141,7 @@ bool RsAccountsDetail::GenerateSSLCertificate(const RsPgpId& pgp_id, const s
|
||||
|
||||
newAccount.mLocation = loc;
|
||||
newAccount.mIsHiddenLoc = ishiddenloc;
|
||||
newAccount.mIsAutoTor = isautotor;
|
||||
|
||||
newAccount.mFirstRun = true;
|
||||
|
||||
@ -1409,9 +1410,9 @@ bool RsAccounts::GetAccountDetails(const RsPeerId &id,
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
|
@ -67,17 +67,17 @@ public:
|
||||
enum Status
|
||||
{
|
||||
Error = -1,
|
||||
NotConnected,
|
||||
Connecting,
|
||||
Authenticating,
|
||||
Connected
|
||||
NotConnected = 0x00,
|
||||
Connecting = 0x01,
|
||||
Authenticating = 0x02,
|
||||
Connected = 0x03
|
||||
};
|
||||
|
||||
enum TorStatus
|
||||
{
|
||||
TorUnknown,
|
||||
TorOffline,
|
||||
TorReady
|
||||
TorUnknown = 0x00,
|
||||
TorOffline = 0x01,
|
||||
TorReady = 0x02
|
||||
};
|
||||
|
||||
|
||||
|
@ -118,12 +118,17 @@ TorProcess *TorManager::process()
|
||||
return d->process;
|
||||
}
|
||||
|
||||
QString TorManager::dataDirectory() const
|
||||
bool TorManager::isTorAvailable()
|
||||
{
|
||||
return !instance()->d->torExecutablePath().isNull();
|
||||
}
|
||||
|
||||
QString TorManager::torDataDirectory() const
|
||||
{
|
||||
return d->dataDir;
|
||||
}
|
||||
|
||||
void TorManager::setDataDirectory(const QString &path)
|
||||
void TorManager::setTorDataDirectory(const QString &path)
|
||||
{
|
||||
d->dataDir = QDir::fromNativeSeparators(path);
|
||||
|
||||
|
@ -58,18 +58,18 @@ class TorManager : public QObject
|
||||
Q_PROPERTY(Tor::TorControl* control READ control CONSTANT)
|
||||
Q_PROPERTY(bool hasError READ hasError 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:
|
||||
|
||||
explicit TorManager(QObject *parent = 0);
|
||||
static bool isTorAvailable() ;
|
||||
static TorManager *instance();
|
||||
|
||||
TorProcess *process();
|
||||
TorControl *control();
|
||||
|
||||
QString dataDirectory() const;
|
||||
void setDataDirectory(const QString &path);
|
||||
|
||||
QString torDataDirectory() const;
|
||||
void setTorDataDirectory(const QString &path);
|
||||
|
||||
QString hiddenServiceDirectory() const;
|
||||
void setHiddenServiceDirectory(const QString &path);
|
||||
@ -100,6 +100,7 @@ signals:
|
||||
void errorChanged();
|
||||
|
||||
private:
|
||||
explicit TorManager(QObject *parent = 0);
|
||||
TorManagerPrivate *d;
|
||||
};
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#include <rshare.h>
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "TorControl/TorManager.h"
|
||||
#include "util/misc.h"
|
||||
|
||||
#include <retroshare/rsidentity.h>
|
||||
@ -479,7 +480,6 @@ void GenCertDialog::genPerson()
|
||||
/* Check the data from the GUI. */
|
||||
std::string genLoc = ui.node_input->text().toUtf8().constData();
|
||||
RsPgpId PGPId;
|
||||
bool isHiddenLoc = false;
|
||||
|
||||
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();
|
||||
uint16_t port = ui.hiddenport_spinBox->value();
|
||||
|
||||
bool useBob = ui.cbUseBob->isChecked();
|
||||
|
||||
if (useBob && hl.empty())
|
||||
hl = "127.0.0.1";
|
||||
|
||||
RsInit::SetHiddenLocation(hl, port, useBob); /* parses it */
|
||||
|
||||
isHiddenLoc = true;
|
||||
}
|
||||
|
||||
|
||||
@ -629,7 +637,7 @@ void GenCertDialog::genPerson()
|
||||
std::string err;
|
||||
this->hide();//To show dialog asking password PGP Key.
|
||||
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)
|
||||
{
|
||||
|
@ -360,7 +360,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
|
||||
QString tor_hidden_service_dir = QString::fromStdString(RsAccounts::AccountDirectory()) + QString("/hidden_service/") ;
|
||||
|
||||
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
|
||||
|
||||
RsDirUtil::checkCreateDirectory(std::string(tor_hidden_service_dir.toUtf8())) ;
|
||||
|
Loading…
Reference in New Issue
Block a user