mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 16:39:29 -05:00
fixed auto-configuraiton of socks proxy
This commit is contained in:
parent
77d0337ae9
commit
475b6a4a62
@ -57,7 +57,7 @@ void TorControlSocket::sendCommand(TorControlCommand *command, const QByteArray
|
|||||||
commandQueue.append(command);
|
commandQueue.append(command);
|
||||||
write(data);
|
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)
|
void TorControlSocket::registerEvent(const QByteArray &event, TorControlCommand *command)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@ -37,17 +38,10 @@ TorControlDialog::TorControlDialog(Tor::TorManager *tm,QWidget *parent)
|
|||||||
timer->start(500) ;
|
timer->start(500) ;
|
||||||
|
|
||||||
// Hide some debug output for the released version
|
// Hide some debug output for the released version
|
||||||
// torLog_TB->hide();
|
|
||||||
torBootstrapStatus_LB->hide();
|
|
||||||
label_2->hide();
|
|
||||||
|
|
||||||
setWindowFlags( Qt::Dialog | Qt::FramelessWindowHint );
|
setWindowFlags( Qt::Dialog | Qt::FramelessWindowHint );
|
||||||
|
|
||||||
adjustSize();
|
adjustSize();
|
||||||
|
|
||||||
// QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect(this);
|
|
||||||
// effect->setBlurRadius(30.0);
|
|
||||||
// setGraphicsEffect(effect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorControlDialog::onIncomingConnection()
|
void TorControlDialog::onIncomingConnection()
|
||||||
@ -86,10 +80,15 @@ void TorControlDialog::statusChanged()
|
|||||||
QVariantMap qvm = mTorManager->control()->bootstrapStatus();
|
QVariantMap qvm = mTorManager->control()->bootstrapStatus();
|
||||||
QString bootstrapstatus_str ;
|
QString bootstrapstatus_str ;
|
||||||
|
|
||||||
for(auto it(qvm.begin());it!=qvm.end();++it)
|
std::cerr << "Bootstrap status map: " << std::endl;
|
||||||
bootstrapstatus_str += it.key() + ":" + it.value().toString();
|
|
||||||
|
|
||||||
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 service_id ;
|
||||||
QString onion_address ;
|
QString onion_address ;
|
||||||
@ -110,19 +109,35 @@ void TorControlDialog::statusChanged()
|
|||||||
|
|
||||||
showLog();
|
showLog();
|
||||||
adjustSize();
|
adjustSize();
|
||||||
|
|
||||||
|
QCoreApplication::processEvents(); // forces update
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorControlDialog::showLog()
|
void TorControlDialog::showLog()
|
||||||
{
|
{
|
||||||
|
static std::set<QString> already_seen ;
|
||||||
|
|
||||||
QString s ;
|
QString s ;
|
||||||
QStringList logmsgs = mTorManager->logMessages() ;
|
QStringList logmsgs = mTorManager->logMessages() ;
|
||||||
|
bool can_print = false ;
|
||||||
|
|
||||||
for(QStringList::const_iterator it(logmsgs.begin());it!=logmsgs.end();++it)
|
for(QStringList::const_iterator it(logmsgs.begin());it!=logmsgs.end();++it)
|
||||||
|
{
|
||||||
s += *it + "\n" ;
|
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()
|
TorControlDialog::TorStatus TorControlDialog::checkForTor()
|
||||||
|
@ -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)
|
bool TorManager::getHiddenServiceInfo(QString& service_id,QString& service_onion_address,uint16_t& service_port, QHostAddress& service_target_address,uint16_t& target_port)
|
||||||
{
|
{
|
||||||
QList<Tor::HiddenService*> hidden_services = control()->hiddenServices();
|
QList<Tor::HiddenService*> hidden_services = control()->hiddenServices();
|
||||||
@ -488,7 +496,7 @@ bool TorManagerPrivate::createDefaultTorrc(const QString &path)
|
|||||||
static const char defaultTorrcContent[] =
|
static const char defaultTorrcContent[] =
|
||||||
"SocksPort auto\n"
|
"SocksPort auto\n"
|
||||||
"AvoidDiskWrites 1\n"
|
"AvoidDiskWrites 1\n"
|
||||||
"DisableNetwork 1\n"
|
// "DisableNetwork 1\n" // (cyril) I removed this because it prevents Tor to bootstrap.
|
||||||
"__ReloadTorrcOnSIGHUP 0\n";
|
"__ReloadTorrcOnSIGHUP 0\n";
|
||||||
|
|
||||||
QFile file(path);
|
QFile file(path);
|
||||||
|
@ -86,6 +86,7 @@ public:
|
|||||||
QString errorMessage() const;
|
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 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:
|
public slots:
|
||||||
void start();
|
void start();
|
||||||
|
@ -403,9 +403,12 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
|
|||||||
QString onion_address ;
|
QString onion_address ;
|
||||||
uint16_t service_port ;
|
uint16_t service_port ;
|
||||||
uint16_t service_target_port ;
|
uint16_t service_target_port ;
|
||||||
|
uint16_t proxy_server_port ;
|
||||||
QHostAddress service_target_address ;
|
QHostAddress service_target_address ;
|
||||||
|
QHostAddress proxy_server_address ;
|
||||||
|
|
||||||
torManager->getHiddenServiceInfo(service_id,onion_address,service_port,service_target_address,service_target_port);
|
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 << "Got hidden service info: " << std::endl;
|
||||||
std::cerr << " onion address : " << onion_address.toStdString() << 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->setLocalAddress(rsPeers->getOwnId(), service_target_address.toString().toStdString(), service_target_port);
|
||||||
rsPeers->setHiddenNode(rsPeers->getOwnId(), onion_address.toStdString(), service_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
|
#endif
|
||||||
|
|
||||||
Rshare::initPlugins();
|
Rshare::initPlugins();
|
||||||
|
Loading…
Reference in New Issue
Block a user