added testing button for incoming TOR connections ;-)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8284 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-05-21 21:12:48 +00:00
parent 18a4bef840
commit e27ff0698e
3 changed files with 48 additions and 60 deletions

View File

@ -30,8 +30,12 @@
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
#include <retroshare/rsturtle.h> #include <retroshare/rsturtle.h>
#include <QMovie>
#include <QTcpSocket> #include <QTcpSocket>
#include <QNetworkProxy> #include <QNetworkProxy>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QNetworkAccessManager>
#include <QTimer> #include <QTimer>
#define ICON_STATUS_UNKNOWN ":/images/ledoff1.png" #define ICON_STATUS_UNKNOWN ":/images/ledoff1.png"
@ -48,8 +52,7 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
connect( ui.netModeComboBox, SIGNAL( activated ( int ) ), this, SLOT( toggleUPnP( ) ) ); connect( ui.netModeComboBox, SIGNAL( activated ( int ) ), this, SLOT( toggleUPnP( ) ) );
connect( ui.allowIpDeterminationCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleIpDetermination(bool) ) ); connect( ui.allowIpDeterminationCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleIpDetermination(bool) ) );
connect( ui.cleanKnownIPs_PB, SIGNAL( clicked( ) ), this, SLOT( clearKnownAddressList() ) ); connect( ui.cleanKnownIPs_PB, SIGNAL( clicked( ) ), this, SLOT( clearKnownAddressList() ) );
//connect( ui.allowTunnelConnectionCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleTunnelConnection(bool) ) ); connect( ui.testIncomingTor_PB, SIGNAL( clicked( ) ), this, SLOT( updateTorInProxyIndicator() ) );
//connect( ui._turtle_enabled_CB, SIGNAL( toggled( bool ) ), this, SLOT( toggleTurtleRouting(bool) ) );
QTimer *timer = new QTimer(this); QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus())); timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus()));
@ -63,12 +66,6 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
ui.allowIpDeterminationCB->setChecked(b) ; ui.allowIpDeterminationCB->setChecked(b) ;
ui.IPServersLV->setEnabled(b) ; ui.IPServersLV->setEnabled(b) ;
//ui.allowTunnelConnectionCB->hide();
//this->toggleTunnelConnection(false);
//b = rsPeers->getAllowTunnelConnection() ;
//ui.allowTunnelConnectionCB->setChecked(b) ;
std::list<std::string> ip_servers ; std::list<std::string> ip_servers ;
rsPeers->getIPServersList(ip_servers) ; rsPeers->getIPServersList(ip_servers) ;
@ -232,9 +229,6 @@ void ServerPage::load()
ui.torpage_proxyPort -> setValue(proxyport); ui.torpage_proxyPort -> setValue(proxyport);
updateTorOutProxyIndicator(); updateTorOutProxyIndicator();
if(mIsHiddenNode)
updateTorInProxyIndicator();
} }
//void ServerPage::toggleTurtleRouting(bool b) //void ServerPage::toggleTurtleRouting(bool b)
@ -306,9 +300,6 @@ void ServerPage::updateStatus()
// check for TOR // check for TOR
updateTorOutProxyIndicator(); updateTorOutProxyIndicator();
if(mIsHiddenNode)
updateTorInProxyIndicator();
} }
void ServerPage::toggleUPnP() void ServerPage::toggleUPnP()
@ -552,9 +543,6 @@ void ServerPage::loadHiddenNode()
updateTorOutProxyIndicator(); updateTorOutProxyIndicator();
if(mIsHiddenNode)
updateTorInProxyIndicator();
QString expected = "HiddenServiceDir </your/path/to/hidden/directory/service>\n"; QString expected = "HiddenServiceDir </your/path/to/hidden/directory/service>\n";
expected += "HiddenServicePort "; expected += "HiddenServicePort ";
expected += QString::number(detail.hiddenNodePort); expected += QString::number(detail.hiddenNodePort);
@ -620,8 +608,6 @@ void ServerPage::updateStatusHiddenNode()
#endif #endif
updateTorOutProxyIndicator(); updateTorOutProxyIndicator();
if(mIsHiddenNode)
updateTorInProxyIndicator();
} }
void ServerPage::saveAddressesHiddenNode() void ServerPage::saveAddressesHiddenNode()
@ -707,53 +693,70 @@ void ServerPage::updateLocInProxyIndicator()
if(socket.waitForConnected(1000)) if(socket.waitForConnected(1000))
{ {
socket.disconnectFromHost(); socket.disconnectFromHost();
ui.iconlabel_local_incoming->setPixmap(QPixmap(ICON_STATUS_OK)) ; ui.iconlabel_tor_incoming->setPixmap(QPixmap(ICON_STATUS_OK)) ;
ui.iconlabel_local_incoming->setToolTip(tr("You are reachable through TOR.")) ; ui.iconlabel_tor_incoming->setToolTip(tr("You are reachable through TOR.")) ;
} }
else else
{ {
ui.iconlabel_local_incoming->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ; ui.iconlabel_tor_incoming->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ;
ui.iconlabel_local_incoming->setToolTip(tr("TOR proxy is not enabled or broken.\nAre you running a TOR hidden service?\nCheck your ports!")) ; ui.iconlabel_tor_incoming->setToolTip(tr("TOR proxy is not enabled or broken.\nAre you running a TOR hidden service?\nCheck your ports!")) ;
} }
} }
void ServerPage::updateTorInProxyIndicator() void ServerPage::updateTorInProxyIndicator()
{ {
// need to find a proper way to do this // need to find a proper way to do this
#ifdef SUSPENDED
if(!mIsHiddenNode) if(!mIsHiddenNode)
return ; return ;
QTcpSocket socket ; static QNetworkAccessManager *manager = new QNetworkAccessManager(this);
QNetworkProxy proxy ; QNetworkProxy proxy ;
proxy.setType(QNetworkProxy::DefaultProxy); proxy.setType(QNetworkProxy::Socks5Proxy);
proxy.setHostName(ui.torpage_proxyAddress->text()); proxy.setHostName(ui.torpage_proxyAddress->text());
proxy.setPort(ui.torpage_proxyPort->text().toInt()); proxy.setPort(ui.torpage_proxyPort->text().toInt());
proxy.setCapabilities(QNetworkProxy::HostNameLookupCapability | proxy.capabilities()) ; proxy.setCapabilities(QNetworkProxy::HostNameLookupCapability | proxy.capabilities()) ;
//ui.iconlabel_tor_incoming->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ;
//ui.testIncomingTor_PB->setIcon(QIcon(":/loader/circleball-16.gif")) ;
QMovie *movie = new QMovie(":/images/loader/circleball-16.gif");
ui.iconlabel_tor_incoming->setMovie(movie);
movie->start() ;
QNetworkProxy::setApplicationProxy(proxy) ;
QUrl url("https://"+ui.torpage_onionAddress->text() + ":" + ui.torpage_onionPort->text()) ;
std::cerr << "Setting proxy hostname+port to " << std::dec << ui.torpage_proxyAddress->text().toStdString() << ":" << ui.torpage_proxyPort->text().toInt() << std::endl; std::cerr << "Setting proxy hostname+port to " << std::dec << ui.torpage_proxyAddress->text().toStdString() << ":" << ui.torpage_proxyPort->text().toInt() << std::endl;
socket.setProxy(proxy) ; std::cerr << "Connecting to " << url.toString().toStdString() << std::endl;
std::cerr << "Connecting to " << ui.torpage_onionAddress->text().toStdString() << ":" << ui.torpage_onionPort->text().toInt() << std::endl; connect(manager, SIGNAL(finished(QNetworkReply*)),this,SLOT(handleNetworkReply(QNetworkReply*))) ;
manager->get( QNetworkRequest(url) ) ;
socket.connectToHost(ui.torpage_onionAddress->text(),ui.torpage_onionPort->text().toInt()); QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy) ;
//socket.connectToHost("www.showip.com",80); }
if(socket.waitForConnected(5000)) void ServerPage::handleNetworkReply(QNetworkReply *reply)
{
int error = reply->error() ;
if(reply->isOpen() && error == QNetworkReply::SslHandshakeFailedError)
{ {
std::cerr <<"Connected!" << std::endl; std::cerr <<"Connected!" << std::endl;
socket.disconnectFromHost();
ui.iconlabel_tor_incoming->setPixmap(QPixmap(ICON_STATUS_OK)) ; ui.iconlabel_tor_incoming->setPixmap(QPixmap(ICON_STATUS_OK)) ;
ui.iconlabel_tor_incoming->setToolTip(tr("You are reachable through TOR.")) ; ui.iconlabel_tor_incoming->setToolTip(tr("You are reachable through TOR.")) ;
} //ui.testIncomingTor_PB->setIcon(QIcon(ICON_STATUS_OK)) ;
else }
{ else
{
std::cerr <<"Failed!" << std::endl; std::cerr <<"Failed!" << std::endl;
std::cerr << "Error: " << socket.errorString().toStdString() << std::endl;
//ui.testIncomingTor_PB->setIcon(QIcon(ICON_STATUS_UNKNOWN)) ;
ui.iconlabel_tor_incoming->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ; ui.iconlabel_tor_incoming->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ;
ui.iconlabel_tor_incoming->setToolTip(tr("TOR proxy is not enabled or broken.\nAre you running a TOR hidden service?\nCheck your ports!")) ; ui.iconlabel_tor_incoming->setToolTip(tr("TOR proxy is not enabled or broken.\nAre you running a TOR hidden service?\nCheck your ports!")) ;
} }
#endif
reply->close();
} }

View File

@ -26,6 +26,7 @@
#include "ui_ServerPage.h" #include "ui_ServerPage.h"
#include "RsAutoUpdatePage.h" #include "RsAutoUpdatePage.h"
class QNetworkReply;
class ServerPage: public ConfigPage class ServerPage: public ConfigPage
{ {
@ -53,6 +54,8 @@ private slots:
void toggleIpDetermination(bool) ; void toggleIpDetermination(bool) ;
void toggleTunnelConnection(bool) ; void toggleTunnelConnection(bool) ;
void clearKnownAddressList() ; void clearKnownAddressList() ;
void handleNetworkReply(QNetworkReply *reply);
void updateTorInProxyIndicator();
private: private:
@ -62,7 +65,6 @@ private:
void saveAddressesHiddenNode(); void saveAddressesHiddenNode();
void updateTorOutProxyIndicator(); void updateTorOutProxyIndicator();
void updateLocInProxyIndicator(); void updateLocInProxyIndicator();
void updateTorInProxyIndicator();
Ui::ServerPage ui; Ui::ServerPage ui;

View File

@ -17,7 +17,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="title"> <attribute name="title">
@ -495,11 +495,8 @@ behind a firewall or a VPN.</string>
<zorder>allowIpDeterminationCB</zorder> <zorder>allowIpDeterminationCB</zorder>
<zorder>IPServersLV</zorder> <zorder>IPServersLV</zorder>
<zorder>ipAddressList</zorder> <zorder>ipAddressList</zorder>
<zorder>label_7</zorder>
<zorder></zorder> <zorder></zorder>
<zorder></zorder> <zorder></zorder>
<zorder>cleanKnownIPs_PB</zorder>
<zorder>horizontalSpacer</zorder>
</widget> </widget>
<widget class="QWidget" name="TorTAB"> <widget class="QWidget" name="TorTAB">
<attribute name="title"> <attribute name="title">
@ -619,25 +616,12 @@ are running a standard Node, so why not setup TOR? </string>
<item row="0" column="3"> <item row="0" column="3">
<layout class="QHBoxLayout" name="horizontalLayout_9"> <layout class="QHBoxLayout" name="horizontalLayout_9">
<item> <item>
<widget class="QLabel" name="iconlabel_local_incoming"> <widget class="QPushButton" name="testIncomingTor_PB">
<property name="maximumSize"> <property name="toolTip">
<size> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This button fakes a SSL connection to your TOR address using the TOR proxy. If your TOR node is reachable, it should cause a SSL handshake error, which RS will interpret as a valid connection state. This operation might also cause several &amp;quot;security warning&amp;quot; in the NewsFeed if you enabled it, from your local host IP (127.0.0.1).&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<width>16</width>
<height>16</height>
</size>
</property> </property>
<property name="text"> <property name="text">
<string/> <string>Test</string>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/ledoff1.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>Local incoming Okay</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -816,7 +800,6 @@ If you have issues connecting over TOR check the TOR logs too.</string>
</tabstops> </tabstops>
<resources> <resources>
<include location="../images.qrc"/> <include location="../images.qrc"/>
<include location="gui/images.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>