added a button to clear the IP address list. Also started to add diagnostic for TOR status. This is unfinished so it does not work yet.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8268 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-05-17 10:00:00 +00:00
parent bcf0c9a9ed
commit 789b76f7b4
8 changed files with 198 additions and 54 deletions

View File

@ -460,7 +460,19 @@ bool p3PeerMgrIMPL::setProxyServerAddress(const struct sockaddr_storage &proxy_a
}
return true;
}
bool p3PeerMgrIMPL::resetOwnExternalAddressList()
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
mOwnState.ipAddrs.mLocal.mAddrs.clear() ;
mOwnState.ipAddrs.mExt.mAddrs.clear() ;
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
return true ;
}
bool p3PeerMgrIMPL::getProxyServerStatus(uint32_t& proxy_status)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/

View File

@ -135,6 +135,8 @@ virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo)
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign) = 0;
virtual bool resetOwnExternalAddressList() = 0 ;
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) =0;
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) =0;
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) =0;
@ -237,7 +239,7 @@ virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo)
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign);
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) ;
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) ;
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) ;
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) ;
@ -263,6 +265,7 @@ virtual bool updateCurrentAddress(const RsPeerId& id, const pqiIpAddress &add
virtual bool updateLastContact(const RsPeerId& id);
virtual bool updateAddressList(const RsPeerId& id, const pqiIpAddrSet &addrs);
virtual bool resetOwnExternalAddressList() ;
// THIS MUST ONLY BE CALLED BY NETMGR!!!!
virtual bool UpdateOwnAddress(const struct sockaddr_storage &local_addr, const struct sockaddr_storage &ext_addr);

View File

@ -349,7 +349,8 @@ class RsPeers
virtual void getIPServersList(std::list<std::string>& ip_servers) = 0;
virtual void allowServerIPDetermination(bool) = 0;
virtual bool getAllowServerIPDetermination() = 0 ;
virtual bool resetOwnExternalAddressList() = 0;
virtual bool getAllowServerIPDetermination() = 0 ;
/* Auth Stuff */
virtual std::string GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures) = 0;

View File

@ -725,7 +725,11 @@ void p3Peers::getIPServersList(std::list<std::string>& ip_servers)
{
mNetMgr->getIPServersList(ip_servers) ;
}
void p3Peers::allowServerIPDetermination(bool b)
bool p3Peers::resetOwnExternalAddressList()
{
return mPeerMgr->resetOwnExternalAddressList();
}
void p3Peers::allowServerIPDetermination(bool b)
{
mNetMgr->setIPServersEnabled(b) ;
}

View File

@ -101,6 +101,7 @@ virtual bool isProxyAddress(const sockaddr_storage&);
virtual void getIPServersList(std::list<std::string>& ip_servers) ;
virtual void allowServerIPDetermination(bool) ;
virtual bool getAllowServerIPDetermination() ;
virtual bool resetOwnExternalAddressList() ;
/* Auth Stuff */
// Get the invitation (GPG cert + local/ext address + SSL id for the given peer)

View File

@ -31,6 +31,7 @@
#include <retroshare/rsturtle.h>
#include <QTcpSocket>
#include <QNetworkProxy>
#include <QTimer>
#define ICON_STATUS_UNKNOWN ":/images/ledoff1.png"
@ -46,6 +47,7 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
connect( ui.netModeComboBox, SIGNAL( activated ( int ) ), this, SLOT( toggleUPnP( ) ) );
connect( ui.allowIpDeterminationCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleIpDetermination(bool) ) );
connect( ui.cleanKnownIPs_PB, SIGNAL( clicked( ) ), this, SLOT( clearKnownAddressList() ) );
//connect( ui.allowTunnelConnectionCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleTunnelConnection(bool) ) );
//connect( ui._turtle_enabled_CB, SIGNAL( toggled( bool ) ), this, SLOT( toggleTurtleRouting(bool) ) );
@ -86,7 +88,12 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
#endif
}
void ServerPage::clearKnownAddressList()
{
rsPeers->resetOwnExternalAddressList() ;
load() ;
}
void ServerPage::toggleIpDetermination(bool b)
{
@ -225,6 +232,7 @@ void ServerPage::load()
ui.torpage_proxyPort -> setValue(proxyport);
updateTorOutProxyIndicator();
updateTorInProxyIndicator();
}
//void ServerPage::toggleTurtleRouting(bool b)
@ -296,6 +304,7 @@ void ServerPage::updateStatus()
// check for TOR
updateTorOutProxyIndicator();
updateTorInProxyIndicator();
}
void ServerPage::toggleUPnP()
@ -538,6 +547,7 @@ void ServerPage::loadHiddenNode()
ui.torpage_proxyPort -> setValue(proxyport);
updateTorOutProxyIndicator();
updateTorInProxyIndicator();
QString expected = "HiddenServiceDir </your/path/to/hidden/directory/service>\n";
expected += "HiddenServicePort ";
@ -604,6 +614,7 @@ void ServerPage::updateStatusHiddenNode()
#endif
updateTorOutProxyIndicator();
updateTorInProxyIndicator();
}
void ServerPage::saveAddressesHiddenNode()
@ -664,25 +675,70 @@ void ServerPage::saveAddressesHiddenNode()
rsConfig->SetMaxDataRates( ui.totalDownloadRate->value(), ui.totalUploadRate->value() );
load();
}
void ServerPage::updateTorOutProxyIndicator()
{
QTcpSocket socket ;
socket.connectToHost(ui.torpage_proxyAddress->text(),ui.torpage_proxyPort->text().toInt());
QTcpSocket socket ;
socket.connectToHost(ui.torpage_proxyAddress->text(),ui.torpage_proxyPort->text().toInt());
if(socket.waitForConnected(500))
{
//std::cerr << "connected !" << std::endl;
if(socket.waitForConnected(500))
{
socket.disconnectFromHost();
ui.iconlabel_tor_outgoing->setPixmap(QPixmap(ICON_STATUS_OK)) ;
ui.iconlabel_tor_outgoing->setToolTip(tr("Proxy seems to work.")) ;
}
else
{
ui.iconlabel_tor_outgoing->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ;
ui.iconlabel_tor_outgoing->setToolTip(tr("TOR proxy is not enabled")) ;
}
}
void ServerPage::updateLocInProxyIndicator()
{
QTcpSocket socket ;
socket.connectToHost(ui.torpage_localAddress->text(),ui.torpage_localPort->text().toInt());
if(socket.waitForConnected(1000))
{
socket.disconnectFromHost();
ui.iconlabel_local_incoming->setPixmap(QPixmap(ICON_STATUS_OK)) ;
ui.iconlabel_local_incoming->setToolTip(tr("You are reachable through TOR.")) ;
}
else
{
ui.iconlabel_local_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!")) ;
}
}
void ServerPage::updateTorInProxyIndicator()
{
QTcpSocket socket ;
QNetworkProxy proxy ;
proxy.setType(QNetworkProxy::Socks5Proxy);
proxy.setHostName(ui.torpage_proxyAddress->text());
proxy.setPort(ui.torpage_proxyPort->text().toInt());
std::cerr << "Setting proxy hostname+port to " << ui.torpage_proxyAddress->text().toStdString() << ":" << ui.torpage_proxyPort->text().toInt() << std::endl;
socket.setProxy(proxy) ;
std::cerr << "Connecting to " << ui.torpage_onionAddress->text().toStdString() << ":" << ui.torpage_onionPort->text().toInt() << std::endl;
socket.connectToHost(ui.torpage_onionAddress->text(),ui.torpage_onionPort->text().toInt(),QAbstractSocket::ReadOnly);
if(socket.waitForConnected(5000))
{
std::cerr <<"Connected!" << std::endl;
socket.disconnectFromHost();
ui.iconlabel_tor_outgoing->setPixmap(QPixmap(ICON_STATUS_OK)) ;
ui.iconlabel_tor_outgoing->setToolTip(tr("Proxy seems to work.")) ;
ui.iconlabel_tor_incoming->setPixmap(QPixmap(ICON_STATUS_OK)) ;
ui.iconlabel_tor_incoming->setToolTip(tr("You are reachable through TOR.")) ;
}
else
{
ui.iconlabel_tor_outgoing->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ;
ui.iconlabel_tor_outgoing->setToolTip(tr("TOR proxy is not enabled")) ;
std::cerr <<"Failed!" << std::endl;
std::cerr << "Error: " << socket.errorString().toStdString() << std::endl;
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!")) ;
}
}

View File

@ -40,9 +40,9 @@ public:
/** Loads the settings for this page */
virtual void load();
virtual QPixmap iconPixmap() const { return QPixmap(":/images/server_24x24.png") ; }
virtual QString pageName() const { return tr("Network") ; }
virtual QString helpText() const { return ""; }
virtual QPixmap iconPixmap() const { return QPixmap(":/images/server_24x24.png") ; }
virtual QString pageName() const { return tr("Network") ; }
virtual QString helpText() const { return ""; }
public slots:
void updateStatus();
@ -52,20 +52,22 @@ private slots:
void toggleUPnP();
void toggleIpDetermination(bool) ;
void toggleTunnelConnection(bool) ;
void clearKnownAddressList() ;
private:
// Alternative Versions for HiddenNode Mode.
void loadHiddenNode();
void updateStatusHiddenNode();
void saveAddressesHiddenNode();
void updateTorOutProxyIndicator();
// Alternative Versions for HiddenNode Mode.
void loadHiddenNode();
void updateStatusHiddenNode();
void saveAddressesHiddenNode();
void updateTorOutProxyIndicator();
void updateLocInProxyIndicator();
void updateTorInProxyIndicator();
Ui::ServerPage ui;
bool mIsHiddenNode;
bool mIsHiddenNode;
};
#endif // !SERVERPAGE_H

View File

@ -23,7 +23,7 @@
<attribute name="title">
<string>Network Configuration</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_9">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
@ -317,11 +317,38 @@
</layout>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Known / Previous IPs:</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Known / Previous IPs:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cleanKnownIPs_PB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This clears the list of known addresses. This action is useful if for some reason your address list contains an invalid/irrelevant/expired address that you want to avoid passing to your friends as a contact address.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="ipAddressList">
@ -471,6 +498,8 @@ behind a firewall or a VPN.</string>
<zorder>label_7</zorder>
<zorder></zorder>
<zorder></zorder>
<zorder>cleanKnownIPs_PB</zorder>
<zorder>horizontalSpacer</zorder>
</widget>
<widget class="QWidget" name="TorTAB">
<attribute name="title">
@ -530,7 +559,7 @@ behind a firewall or a VPN.</string>
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>Outgoing Okay</string>
<string>TOR outgoing Okay</string>
</property>
</widget>
</item>
@ -577,16 +606,6 @@ are running a standard Node, so why not setup TOR? </string>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Local Address</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="torpage_localAddress"/>
</item>
<item row="0" column="2">
<widget class="QSpinBox" name="torpage_localPort">
<property name="minimum">
@ -600,7 +619,7 @@ are running a standard Node, so why not setup TOR? </string>
<item row="0" column="3">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="iconlabel_tor_incoming">
<widget class="QLabel" name="iconlabel_local_incoming">
<property name="maximumSize">
<size>
<width>16</width>
@ -618,22 +637,12 @@ are running a standard Node, so why not setup TOR? </string>
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>Incoming Okay</string>
<string>Local incoming Okay</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Onion Address</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="torpage_onionAddress"/>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="torpage_onionPort">
<property name="minimum">
@ -644,6 +653,61 @@ are running a standard Node, so why not setup TOR? </string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Onion Address</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Local Address</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="torpage_onionAddress">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This is your onion address. It should look like &lt;span style=&quot; font-weight:600;&quot;&gt;[something].onion. &lt;/span&gt;If you configured a hidden service with TOR, the onion address is generated automatically by TOR. You can get it in e.g. &lt;span style=&quot; font-weight:600;&quot;&gt;/var/lib/tor/[service name]/hostname&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="torpage_localAddress">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This is the local address to which the TOR hidden service points at your localhost. Most of the time, &lt;span style=&quot; font-weight:600;&quot;&gt;127.0.0.1&lt;/span&gt; is the right answer.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="3">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="iconlabel_tor_incoming">
<property name="maximumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/ledoff1.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_16">
<property name="text">
<string>TOR incoming ok</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
@ -752,6 +816,7 @@ If you have issues connecting over TOR check the TOR logs too.</string>
</tabstops>
<resources>
<include location="../images.qrc"/>
<include location="gui/images.qrc"/>
</resources>
<connections/>
</ui>