mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed display of tor bootstrap status
This commit is contained in:
parent
f352235ccd
commit
7e6156566a
@ -191,7 +191,6 @@ void TorControl::setTorStatus(TorControl::TorStatus n)
|
|||||||
if (n == mTorStatus)
|
if (n == mTorStatus)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TorControl::TorStatus old = mTorStatus;
|
|
||||||
mTorStatus = n;
|
mTorStatus = n;
|
||||||
|
|
||||||
if(rsEvents)
|
if(rsEvents)
|
||||||
@ -316,10 +315,7 @@ void TorControl::authenticateReply(TorControlCommand *sender)
|
|||||||
setTorStatus(TorControl::TorUnknown);
|
setTorStatus(TorControl::TorUnknown);
|
||||||
|
|
||||||
TorControlCommand *clientEvents = new TorControlCommand;
|
TorControlCommand *clientEvents = new TorControlCommand;
|
||||||
clientEvents->set_replyLine_callback([this](int code, const ByteArray &data)
|
clientEvents->set_replyLine_callback([this](int code, const ByteArray &data) { statusEvent(code,data);});
|
||||||
{
|
|
||||||
statusEvent(code,data); // no async needed here.
|
|
||||||
});
|
|
||||||
|
|
||||||
mSocket->registerEvent(ByteArray("STATUS_CLIENT"), clientEvents);
|
mSocket->registerEvent(ByteArray("STATUS_CLIENT"), clientEvents);
|
||||||
|
|
||||||
@ -343,6 +339,7 @@ void TorControl::authenticate()
|
|||||||
ProtocolInfoCommand *command = new ProtocolInfoCommand(this);
|
ProtocolInfoCommand *command = new ProtocolInfoCommand(this);
|
||||||
|
|
||||||
command->set_finished_callback( [this](TorControlCommand *sender) { protocolInfoReply(sender); });
|
command->set_finished_callback( [this](TorControlCommand *sender) { protocolInfoReply(sender); });
|
||||||
|
command->set_replyLine_callback([this](int code, const ByteArray &data) { statusEvent(code,data); });
|
||||||
//connect(command, &TorControlCommand::finished, this, &protocolInfoReply);
|
//connect(command, &TorControlCommand::finished, this, &protocolInfoReply);
|
||||||
mSocket->sendCommand(command, command->build());
|
mSocket->sendCommand(command, command->build());
|
||||||
}
|
}
|
||||||
@ -455,6 +452,7 @@ void TorControl::getTorInfo()
|
|||||||
GetConfCommand *command = new GetConfCommand(GetConfCommand::GetInfo);
|
GetConfCommand *command = new GetConfCommand(GetConfCommand::GetInfo);
|
||||||
//connect(command, &TorControlCommand::finished, this, &TorControl::getTorInfoReply);
|
//connect(command, &TorControlCommand::finished, this, &TorControl::getTorInfoReply);
|
||||||
command->set_finished_callback( [this](TorControlCommand *sender) { getTorInfoReply(sender); });
|
command->set_finished_callback( [this](TorControlCommand *sender) { getTorInfoReply(sender); });
|
||||||
|
command->set_replyLine_callback([this](int code, const ByteArray &data) { statusEvent(code,data); });
|
||||||
|
|
||||||
std::list<std::string> keys{ "status/circuit-established","status/bootstrap-phase" };
|
std::list<std::string> keys{ "status/circuit-established","status/bootstrap-phase" };
|
||||||
|
|
||||||
@ -680,6 +678,7 @@ void TorControl::statusEvent(int /* code */, const ByteArray &data)
|
|||||||
|
|
||||||
void TorControl::updateBootstrap(const std::list<ByteArray> &data)
|
void TorControl::updateBootstrap(const std::list<ByteArray> &data)
|
||||||
{
|
{
|
||||||
|
std::cerr << "********** Updating bootstrap status ************" << std::endl;
|
||||||
mBootstrapStatus.clear();
|
mBootstrapStatus.clear();
|
||||||
// WARN or NOTICE
|
// WARN or NOTICE
|
||||||
mBootstrapStatus["severity"] = (*data.begin()).toString();
|
mBootstrapStatus["severity"] = (*data.begin()).toString();
|
||||||
@ -714,6 +713,7 @@ void TorControl::updateBootstrap(const std::list<ByteArray> &data)
|
|||||||
TorControlCommand *TorControl::getConfiguration(const std::string& options)
|
TorControlCommand *TorControl::getConfiguration(const std::string& options)
|
||||||
{
|
{
|
||||||
GetConfCommand *command = new GetConfCommand(GetConfCommand::GetConf);
|
GetConfCommand *command = new GetConfCommand(GetConfCommand::GetConf);
|
||||||
|
command->set_replyLine_callback([this](int code, const ByteArray &data) { statusEvent(code,data); });
|
||||||
mSocket->sendCommand(command, command->build(options));
|
mSocket->sendCommand(command, command->build(options));
|
||||||
|
|
||||||
//QQmlEngine::setObjectOwnership(command, QQmlEngine::CppOwnership);
|
//QQmlEngine::setObjectOwnership(command, QQmlEngine::CppOwnership);
|
||||||
@ -862,7 +862,6 @@ bool TorControl::torVersionAsNewAs(const std::string& match) const
|
|||||||
auto matchSplit = ByteArray(match).split(ByteArray(".-"));
|
auto matchSplit = ByteArray(match).split(ByteArray(".-"));
|
||||||
|
|
||||||
int split_size = split.size();
|
int split_size = split.size();
|
||||||
int i=0;
|
|
||||||
auto b_split(split.begin());
|
auto b_split(split.begin());
|
||||||
auto b_matchsplit(matchSplit.begin());
|
auto b_matchsplit(matchSplit.begin());
|
||||||
|
|
||||||
|
@ -577,7 +577,10 @@ void TorManagerPrivate::processLogMessage(const std::string &message)
|
|||||||
std::cerr << "tor:" << message << std::endl;
|
std::cerr << "tor:" << message << std::endl;
|
||||||
if (logMessages.size() >= 50)
|
if (logMessages.size() >= 50)
|
||||||
logMessages.pop_front();
|
logMessages.pop_front();
|
||||||
logMessages.push_back(message);
|
|
||||||
|
auto p = message.find_first_of('\n');
|
||||||
|
|
||||||
|
logMessages.push_back((p==std::string::npos)?message:message.substr(0,p));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorManagerPrivate::controlStatusChanged(int status)
|
void TorManagerPrivate::controlStatusChanged(int status)
|
||||||
|
@ -42,7 +42,7 @@ TorControlDialog::TorControlDialog(QWidget *)
|
|||||||
QTimer *timer = new QTimer ;
|
QTimer *timer = new QTimer ;
|
||||||
|
|
||||||
QObject::connect(timer,SIGNAL(timeout()),this,SLOT(showLog())) ;
|
QObject::connect(timer,SIGNAL(timeout()),this,SLOT(showLog())) ;
|
||||||
timer->start(500) ;
|
timer->start(300) ;
|
||||||
|
|
||||||
// Hide some debug output for the released version
|
// Hide some debug output for the released version
|
||||||
|
|
||||||
@ -143,23 +143,33 @@ void TorControlDialog::showLog()
|
|||||||
|
|
||||||
std::string s ;
|
std::string s ;
|
||||||
std::list<std::string> logmsgs = RsTor::logMessages() ;
|
std::list<std::string> logmsgs = RsTor::logMessages() ;
|
||||||
bool can_print = false ;
|
bool can_print = false ;
|
||||||
|
|
||||||
for(auto it(logmsgs.begin());it!=logmsgs.end();++it)
|
for(auto it(logmsgs.begin());it!=logmsgs.end();++it)
|
||||||
{
|
{
|
||||||
s += *it + "\n" ;
|
s += *it + "\n" ;
|
||||||
|
|
||||||
if(already_seen.find(*it) == already_seen.end())
|
if(already_seen.find(*it) == already_seen.end())
|
||||||
{
|
{
|
||||||
can_print = true ;
|
can_print = true ;
|
||||||
already_seen.insert(*it);
|
already_seen.insert(*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(can_print)
|
if(can_print)
|
||||||
|
{
|
||||||
std::cerr << "[TOR DEBUG LOG] " << *it << std::endl;
|
std::cerr << "[TOR DEBUG LOG] " << *it << std::endl;
|
||||||
}
|
|
||||||
|
|
||||||
std::cerr << "Connexion Proxy: " << RsTor::socksAddress() << ":" << QString::number(RsTor::socksPort()).toStdString() << std::endl;
|
QString s = QString::fromStdString(*it);
|
||||||
|
int n = s.indexOf(QString("Bootstrapped"));
|
||||||
|
|
||||||
|
if(n >= 0)
|
||||||
|
{
|
||||||
|
torBootstrapStatus_LB->setText(s.mid(n+QString("Bootstrapped").length()));
|
||||||
|
QCoreApplication::processEvents(); // forces update
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//std::cerr << "Connexion Proxy: " << RsTor::socksAddress() << ":" << QString::number(RsTor::socksPort()).toStdString() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
TorControlDialog::TorStatus TorControlDialog::checkForTor(QString& error_msg)
|
TorControlDialog::TorStatus TorControlDialog::checkForTor(QString& error_msg)
|
||||||
|
@ -40,6 +40,12 @@
|
|||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
@ -55,6 +61,12 @@
|
|||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="torStatusTxt_LB">
|
<widget class="QLabel" name="torStatusTxt_LB">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Tor status:</string>
|
<string>Tor status:</string>
|
||||||
</property>
|
</property>
|
||||||
@ -79,8 +91,14 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="HiddenServiceAddressTxt_LB">
|
<widget class="QLabel" name="HiddenServiceAddressTxt_LB">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Hidden service address:</string>
|
<string>Hidden address:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
@ -89,8 +107,14 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="torBootstrapStatusTxt_LB">
|
<widget class="QLabel" name="torBootstrapStatusTxt_LB">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Tor bootstrap status:</string>
|
<string>Tor status:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
@ -106,6 +130,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="onionAddressTxt_LB">
|
<widget class="QLabel" name="onionAddressTxt_LB">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Onion address:</string>
|
<string>Onion address:</string>
|
||||||
</property>
|
</property>
|
||||||
|
Loading…
Reference in New Issue
Block a user