diff --git a/retroshare-gui/src/TorControl/TorControlSocket.cpp b/retroshare-gui/src/TorControl/TorControlSocket.cpp index b4c85d096..c6b1eb707 100644 --- a/retroshare-gui/src/TorControl/TorControlSocket.cpp +++ b/retroshare-gui/src/TorControl/TorControlSocket.cpp @@ -57,7 +57,7 @@ void TorControlSocket::sendCommand(TorControlCommand *command, const QByteArray commandQueue.append(command); write(data); - std::cerr << "torctrl: Sent: \"" << QString(data.trimmed()).toStdString() << "\"" << std::endl; + std::cerr << "[TOR CTRL] Sent: \"" << QString(data.trimmed()).toStdString() << "\"" << std::endl; } void TorControlSocket::registerEvent(const QByteArray &event, TorControlCommand *command) diff --git a/retroshare-gui/src/TorControl/TorControlWindow.cpp b/retroshare-gui/src/TorControl/TorControlWindow.cpp index 7ec3f547f..f3d93a61d 100644 --- a/retroshare-gui/src/TorControl/TorControlWindow.cpp +++ b/retroshare-gui/src/TorControl/TorControlWindow.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -37,17 +38,10 @@ TorControlDialog::TorControlDialog(Tor::TorManager *tm,QWidget *parent) timer->start(500) ; // Hide some debug output for the released version -// torLog_TB->hide(); - torBootstrapStatus_LB->hide(); - label_2->hide(); setWindowFlags( Qt::Dialog | Qt::FramelessWindowHint ); adjustSize(); - -// QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect(this); -// effect->setBlurRadius(30.0); -// setGraphicsEffect(effect); } void TorControlDialog::onIncomingConnection() @@ -86,10 +80,15 @@ void TorControlDialog::statusChanged() QVariantMap qvm = mTorManager->control()->bootstrapStatus(); QString bootstrapstatus_str ; - for(auto it(qvm.begin());it!=qvm.end();++it) - bootstrapstatus_str += it.key() + ":" + it.value().toString(); + std::cerr << "Bootstrap status map: " << std::endl; - torBootstrapStatus_LB->setText(bootstrapstatus_str) ; + for(auto it(qvm.begin());it!=qvm.end();++it) + std::cerr << " " << it.key().toStdString() << " : " << it.value().toString().toStdString() << std::endl; + + if(!qvm["progress"].toString().isNull()) + torBootstrapStatus_LB->setText(qvm["progress"].toString() + " % (" + qvm["summary"].toString() + ")") ; + else + torBootstrapStatus_LB->setText(tr("[Waiting for Tor...]")) ; QString service_id ; QString onion_address ; @@ -110,19 +109,35 @@ void TorControlDialog::statusChanged() showLog(); adjustSize(); + + QCoreApplication::processEvents(); // forces update } void TorControlDialog::showLog() { + static std::set already_seen ; + QString s ; QStringList logmsgs = mTorManager->logMessages() ; + bool can_print = false ; for(QStringList::const_iterator it(logmsgs.begin());it!=logmsgs.end();++it) + { s += *it + "\n" ; -// torLog_TB->setText(s) ; + if(already_seen.find(*it) == already_seen.end()) + { + can_print = true ; + already_seen.insert(*it); + } - std::cerr << s.toStdString() << std::endl; + if(can_print) + std::cerr << "[TOR DEBUG LOG] " << (*it).toStdString() << std::endl; + } + +// torLog_TB->setText(s) ;: + + std::cerr << "Connexion Proxy: " << mTorManager->control()->socksAddress().toString().toStdString() << ":" << mTorManager->control()->socksPort() << std::endl; } TorControlDialog::TorStatus TorControlDialog::checkForTor() diff --git a/retroshare-gui/src/TorControl/TorManager.cpp b/retroshare-gui/src/TorControl/TorManager.cpp index a6a6f0ab4..b7b14e5dc 100644 --- a/retroshare-gui/src/TorControl/TorManager.cpp +++ b/retroshare-gui/src/TorControl/TorManager.cpp @@ -372,6 +372,14 @@ void TorManager::start() } } +bool TorManager::getProxyServerInfo(QHostAddress& proxy_server_adress,uint16_t& proxy_server_port) +{ + proxy_server_adress = control()->socksAddress(); + proxy_server_port = control()->socksPort(); + + return proxy_server_port > 1023 ; +} + bool TorManager::getHiddenServiceInfo(QString& service_id,QString& service_onion_address,uint16_t& service_port, QHostAddress& service_target_address,uint16_t& target_port) { QList hidden_services = control()->hiddenServices(); @@ -488,7 +496,7 @@ bool TorManagerPrivate::createDefaultTorrc(const QString &path) static const char defaultTorrcContent[] = "SocksPort auto\n" "AvoidDiskWrites 1\n" - "DisableNetwork 1\n" +// "DisableNetwork 1\n" // (cyril) I removed this because it prevents Tor to bootstrap. "__ReloadTorrcOnSIGHUP 0\n"; QFile file(path); diff --git a/retroshare-gui/src/TorControl/TorManager.h b/retroshare-gui/src/TorControl/TorManager.h index 4c5ffeb44..254306779 100644 --- a/retroshare-gui/src/TorControl/TorManager.h +++ b/retroshare-gui/src/TorControl/TorManager.h @@ -86,6 +86,7 @@ public: QString errorMessage() const; bool getHiddenServiceInfo(QString& service_id,QString& service_onion_address,uint16_t& service_port, QHostAddress& service_target_address,uint16_t& target_port); + bool getProxyServerInfo(QHostAddress& proxy_server_adress,uint16_t& proxy_server_port); public slots: void start(); diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 5cc752b10..1d86a5c13 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -403,9 +403,12 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); QString onion_address ; uint16_t service_port ; uint16_t service_target_port ; + uint16_t proxy_server_port ; QHostAddress service_target_address ; + QHostAddress proxy_server_address ; torManager->getHiddenServiceInfo(service_id,onion_address,service_port,service_target_address,service_target_port); + torManager->getProxyServerInfo(proxy_server_address,proxy_server_port) ; std::cerr << "Got hidden service info: " << std::endl; std::cerr << " onion address : " << onion_address.toStdString() << std::endl; @@ -418,6 +421,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); rsPeers->setLocalAddress(rsPeers->getOwnId(), service_target_address.toString().toStdString(), service_target_port); rsPeers->setHiddenNode(rsPeers->getOwnId(), onion_address.toStdString(), service_port); + rsPeers->setProxyServer(RS_HIDDEN_TYPE_TOR, proxy_server_address.toString().toStdString(),proxy_server_port) ; #endif Rshare::initPlugins();