mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
proper error handlign when Tor is not available
This commit is contained in:
parent
8f7582588a
commit
faf45174c7
@ -24,6 +24,7 @@ TorControlDialog::TorControlDialog(Tor::TorManager *tm,QWidget *parent)
|
||||
QObject::connect(tm->control(),SIGNAL(disconnected()),this,SLOT(statusChanged()));
|
||||
QObject::connect(tm->control(),SIGNAL(bootstrapStatusChanged()),this,SLOT(statusChanged()));
|
||||
QObject::connect(tm->control(),SIGNAL(connectivityChanged()),this,SLOT(statusChanged()));
|
||||
QObject::connect(tm ,SIGNAL(errorChanged()),this,SLOT(statusChanged()));
|
||||
|
||||
//QTimer::singleShot(2000,this,SLOT(checkForHiddenService())) ;
|
||||
|
||||
@ -58,6 +59,9 @@ void TorControlDialog::statusChanged()
|
||||
|
||||
QString tor_control_status_str,torstatus_str ;
|
||||
|
||||
if(mTorManager->hasError())
|
||||
mErrorMsg = mTorManager->errorMessage() ;
|
||||
|
||||
switch(tor_control_status)
|
||||
{
|
||||
default:
|
||||
@ -149,8 +153,14 @@ void TorControlDialog::showLog()
|
||||
std::cerr << "Connexion Proxy: " << mTorManager->control()->socksAddress().toString().toStdString() << ":" << mTorManager->control()->socksPort() << std::endl;
|
||||
}
|
||||
|
||||
TorControlDialog::TorStatus TorControlDialog::checkForTor()
|
||||
TorControlDialog::TorStatus TorControlDialog::checkForTor(QString& error_msg)
|
||||
{
|
||||
if(!mErrorMsg.isNull())
|
||||
{
|
||||
error_msg = mErrorMsg ;
|
||||
return TorControlDialog::TOR_STATUS_FAIL ;
|
||||
}
|
||||
|
||||
switch(mTorManager->control()->torStatus())
|
||||
{
|
||||
case Tor::TorControl::TorReady: rstime::rs_usleep(1*1000*1000);return TOR_STATUS_OK ;
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
|
||||
// Should be called multiple times in a loop until it returns something else than *_UNKNOWN
|
||||
|
||||
TorStatus checkForTor() ;
|
||||
TorStatus checkForTor(QString& error_msg) ;
|
||||
HiddenServiceStatus checkForHiddenService() ;
|
||||
|
||||
protected slots:
|
||||
@ -38,6 +38,7 @@ protected slots:
|
||||
void onIncomingConnection();
|
||||
|
||||
private:
|
||||
QString mErrorMsg ;
|
||||
HiddenServiceStatus mHiddenServiceStatus ;
|
||||
|
||||
Tor::TorManager *mTorManager ;
|
||||
|
@ -367,12 +367,19 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
|
||||
|
||||
{
|
||||
TorControlDialog tcd(torManager) ;
|
||||
QString error_msg ;
|
||||
tcd.show();
|
||||
|
||||
while(tcd.checkForTor() != TorControlDialog::TOR_STATUS_OK || tcd.checkForHiddenService() != TorControlDialog::HIDDEN_SERVICE_STATUS_OK) // runs until some status is reached: either tor works, or it fails.
|
||||
while(tcd.checkForTor(error_msg) != TorControlDialog::TOR_STATUS_OK || tcd.checkForHiddenService() != TorControlDialog::HIDDEN_SERVICE_STATUS_OK) // runs until some status is reached: either tor works, or it fails.
|
||||
{
|
||||
QCoreApplication::processEvents();
|
||||
rstime::rs_usleep(0.2*1000*1000) ;
|
||||
|
||||
if(!error_msg.isNull())
|
||||
{
|
||||
QMessageBox::critical(NULL,QObject::tr("Cannot start Tor"),QObject::tr("Sorry but Tor cannot be started on your system!\n\nThe error reported is:\"")+error_msg+"\"") ;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
tcd.hide();
|
||||
|
Loading…
Reference in New Issue
Block a user