mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 16:39:29 -05:00
attempt to improve the tor statusbar widget
This commit is contained in:
parent
6179d22ad5
commit
15decacc0d
@ -161,18 +161,6 @@ bool TorManager::setupHiddenService()
|
|||||||
std::cerr << "legacy dir not set! Cannot proceed." << std::endl;
|
std::cerr << "legacy dir not set! Cannot proceed." << std::endl;
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
// if (!keyData.isEmpty())
|
|
||||||
// {
|
|
||||||
// CryptoKey key;
|
|
||||||
// if (!key.loadFromData(QByteArray::fromBase64(keyData.toLatin1()), CryptoKey::PrivateKey, CryptoKey::DER))
|
|
||||||
// {
|
|
||||||
// qWarning() << "Cannot load service key from configuration";
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// mHiddenService = new Tor::HiddenService(key, legacyDir, this);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
|
|
||||||
std::cerr << "Using legacy dir: " << legacyDir.toStdString() << std::endl;
|
std::cerr << "Using legacy dir: " << legacyDir.toStdString() << std::endl;
|
||||||
|
|
||||||
@ -193,11 +181,6 @@ bool TorManager::setupHiddenService()
|
|||||||
std::cerr << "Got key from legacy dir: " << std::endl;
|
std::cerr << "Got key from legacy dir: " << std::endl;
|
||||||
std::cerr << keyData.toStdString() << std::endl;
|
std::cerr << keyData.toStdString() << std::endl;
|
||||||
}
|
}
|
||||||
// else if (!m_settings->read("initializing").toBool())
|
|
||||||
// {
|
|
||||||
// qWarning() << "Missing private key for initialized identity";
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
d->hiddenService = new Tor::HiddenService(legacyDir, this);
|
d->hiddenService = new Tor::HiddenService(legacyDir, this);
|
||||||
@ -235,7 +218,7 @@ bool TorManager::setupHiddenService()
|
|||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hiddenServiceStatusChanged(int old_status,int new_status)
|
void TorManager::hiddenServiceStatusChanged(int old_status,int new_status)
|
||||||
{
|
{
|
||||||
std::cerr << "Hidden service status changed from " << old_status << " to " << new_status << std::endl;
|
std::cerr << "Hidden service status changed from " << old_status << " to " << new_status << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,7 @@ public slots:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void hiddenServicePrivateKeyChanged();
|
void hiddenServicePrivateKeyChanged();
|
||||||
|
void hiddenServiceStatusChanged(int old_status,int new_status);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void configurationNeededChanged();
|
void configurationNeededChanged();
|
||||||
|
@ -60,6 +60,28 @@ void TorStatus::getTorStatus()
|
|||||||
statusTor->setVisible(!_compactMode);
|
statusTor->setVisible(!_compactMode);
|
||||||
QString text = _compactMode?statusTor->text():"";
|
QString text = _compactMode?statusTor->text():"";
|
||||||
|
|
||||||
|
/* check local network state. We cannot make sure that Tor is running yet. */
|
||||||
|
uint32_t netState = rsConfig -> getNetState();
|
||||||
|
bool online ;
|
||||||
|
|
||||||
|
switch(netState)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case RSNET_NETSTATE_BAD_UNKNOWN:
|
||||||
|
case RSNET_NETSTATE_BAD_OFFLINE: online = false ;
|
||||||
|
break ;
|
||||||
|
|
||||||
|
case RSNET_NETSTATE_WARNING_RESTART:
|
||||||
|
|
||||||
|
case RSNET_NETSTATE_BAD_NATSYM:
|
||||||
|
case RSNET_NETSTATE_BAD_NODHT_NAT:
|
||||||
|
case RSNET_NETSTATE_WARNING_NATTED:
|
||||||
|
case RSNET_NETSTATE_WARNING_NODHT:
|
||||||
|
case RSNET_NETSTATE_GOOD:
|
||||||
|
case RSNET_NETSTATE_ADV_FORWARD: online = true ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
|
||||||
/* now the extra bit .... switch on check boxes */
|
/* now the extra bit .... switch on check boxes */
|
||||||
|
|
||||||
int S = QFontMetricsF(torstatusLabel->font()).height();
|
int S = QFontMetricsF(torstatusLabel->font()).height();
|
||||||
@ -70,15 +92,16 @@ void TorStatus::getTorStatus()
|
|||||||
int torstatus = Tor::TorManager::instance()->control()->torStatus();
|
int torstatus = Tor::TorManager::instance()->control()->torStatus();
|
||||||
|
|
||||||
QString tor_control_status_str,torstatus_str ;
|
QString tor_control_status_str,torstatus_str ;
|
||||||
|
bool tor_control_ok ;
|
||||||
|
|
||||||
switch(tor_control_status)
|
switch(tor_control_status)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case Tor::TorControl::Error : tor_control_status_str = "Error" ; break ;
|
case Tor::TorControl::Error : tor_control_ok = false ; tor_control_status_str = "Error" ; break ;
|
||||||
case Tor::TorControl::NotConnected: tor_control_status_str = "Not connected" ; break ;
|
case Tor::TorControl::NotConnected: tor_control_ok = false ; tor_control_status_str = "Not connected" ; break ;
|
||||||
case Tor::TorControl::Connecting: tor_control_status_str = "Connecting" ; break ;
|
case Tor::TorControl::Connecting: tor_control_ok = false ; tor_control_status_str = "Connecting" ; break ;
|
||||||
case Tor::TorControl::Authenticating: tor_control_status_str = "Authenticating" ; break ;
|
case Tor::TorControl::Authenticating: tor_control_ok = false ; tor_control_status_str = "Authenticating" ; break ;
|
||||||
case Tor::TorControl::Connected: tor_control_status_str = "Connected" ; break ;
|
case Tor::TorControl::Connected: tor_control_ok = true ; tor_control_status_str = "Connected" ; break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(torstatus)
|
switch(torstatus)
|
||||||
@ -91,13 +114,15 @@ void TorStatus::getTorStatus()
|
|||||||
|
|
||||||
#define MIN_RS_NET_SIZE 10
|
#define MIN_RS_NET_SIZE 10
|
||||||
|
|
||||||
if(torstatus == Tor::TorControl::TorOffline)
|
std::cerr << "(II) tor status: net=" << netState << " tor_control= " << tor_control_status << " tor_status=" << torstatus << std::endl;
|
||||||
|
|
||||||
|
if(torstatus == Tor::TorControl::TorOffline || !online || !tor_control_ok)
|
||||||
{
|
{
|
||||||
// RED - some issue.
|
// RED - some issue.
|
||||||
torstatusLabel->setPixmap(QPixmap(":/icons/tor-stopping.png").scaledToHeight(1.5*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)
|
else if(torstatus == Tor::TorControl::TorReady && online && tor_control_ok)
|
||||||
{
|
{
|
||||||
torstatusLabel->setPixmap(QPixmap(":/icons/tor-on.png").scaledToHeight(1.5*S,Qt::SmoothTransformation));
|
torstatusLabel->setPixmap(QPixmap(":/icons/tor-on.png").scaledToHeight(1.5*S,Qt::SmoothTransformation));
|
||||||
torstatusLabel->setToolTip( text + tr("Tor is OK"));
|
torstatusLabel->setToolTip( text + tr("Tor is OK"));
|
||||||
|
Loading…
Reference in New Issue
Block a user