Added TOR Configuration page. Allows STD Nodes to configure Proxy too.

Moved most of hidden node parameters to this page.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-initdev@7038 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2014-01-19 06:27:02 +00:00
parent 6526dd6c4b
commit 45bd72203e
2 changed files with 331 additions and 57 deletions

View File

@ -84,7 +84,8 @@ ServerPage::ServerPage(QWidget * parent, Qt::WFlags flags)
ui.tabWidget->widget(2)->layout()->addItem(verticalSpacer) ; ui.tabWidget->widget(2)->layout()->addItem(verticalSpacer) ;
ui.tabWidget->widget(2)->layout()->update() ; ui.tabWidget->widget(2)->layout()->update() ;
ui.torPort->setVisible(false); ui.torpage_incoming->setVisible(false);
/* Hide platform specific features */ /* Hide platform specific features */
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
@ -236,6 +237,13 @@ void ServerPage::load()
ui.ipAddressList->clear(); ui.ipAddressList->clear();
for(std::list<std::string>::const_iterator it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it) for(std::list<std::string>::const_iterator it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it)
ui.ipAddressList->addItem(QString::fromStdString(*it)); ui.ipAddressList->addItem(QString::fromStdString(*it));
/* TOR PAGE SETTINGS - only Proxy (outgoing) */
std::string proxyaddr;
uint16_t proxyport;
rsPeers->getProxyServer(proxyaddr, proxyport);
ui.torpage_proxyAddress -> setText(QString::fromStdString(proxyaddr));
ui.torpage_proxyPort -> setValue(proxyport);
} }
void ServerPage::toggleTurtleRouting(bool b) void ServerPage::toggleTurtleRouting(bool b)
@ -412,6 +420,19 @@ void ServerPage::saveAddresses()
rsPeers->setDynDNS(ownId, ui.dynDNS->text().toStdString()); rsPeers->setDynDNS(ownId, ui.dynDNS->text().toStdString());
rsConfig->SetMaxDataRates( ui.totalDownloadRate->value(), ui.totalUploadRate->value() ); rsConfig->SetMaxDataRates( ui.totalDownloadRate->value(), ui.totalUploadRate->value() );
// HANDLE PROXY SERVER.
std::string orig_proxyaddr;
uint16_t orig_proxyport;
rsPeers->getProxyServer(orig_proxyaddr, orig_proxyport);
std::string new_proxyaddr = ui.torpage_proxyAddress -> text().toStdString();
uint16_t new_proxyport = ui.torpage_proxyPort -> value();
if ((new_proxyaddr != orig_proxyaddr) || (new_proxyport != orig_proxyport))
{
rsPeers->setProxyServer(new_proxyaddr, new_proxyport);
}
load(); load();
} }
@ -476,9 +497,13 @@ void ServerPage::loadHiddenNode()
// Addresses. // Addresses.
ui.localAddress->setEnabled(false); ui.localAddress->setEnabled(false);
ui.localPort -> setEnabled(true); ui.localPort -> setEnabled(false);
ui.extAddress -> setEnabled(true); ui.extAddress -> setEnabled(false);
ui.extPort -> setEnabled(true); ui.extPort -> setVisible(false);
ui.label_dynDNS->setVisible(false);
ui.dynDNS ->setVisible(false);
ui.torpage_incoming->setVisible(true);
/* Addresses must be set here - otherwise can't edit it */ /* Addresses must be set here - otherwise can't edit it */
/* set local address */ /* set local address */
@ -486,21 +511,7 @@ void ServerPage::loadHiddenNode()
ui.localPort -> setValue(detail.localPort); ui.localPort -> setValue(detail.localPort);
/* set the server address */ /* set the server address */
ui.extAddress->setText(tr("Hidden - See TOR Config"));
ui.label_extAddress->setText(tr("TOR Onion Address"));
ui.extAddress->setText(QString::fromStdString(detail.hiddenNodeAddress));
ui.extPort -> setValue(detail.hiddenNodePort);
/* set DynDNS */
ui.label_dynDNS -> setText("TOR Server Port");
std::string proxyaddr;
uint16_t proxyport;
rsPeers->getProxyServer(proxyaddr, proxyport);
ui.dynDNS -> setText(QString::fromStdString(proxyaddr));
ui.torPort -> setVisible(true);
ui.torPort -> setValue(proxyport);
ui.showDiscStatusBar->setChecked(Settings->getStatusBarFlags() & STATUSBAR_DISC); ui.showDiscStatusBar->setChecked(Settings->getStatusBarFlags() & STATUSBAR_DISC);
@ -519,6 +530,33 @@ void ServerPage::loadHiddenNode()
ui.allowIpDeterminationCB->setChecked(false); ui.allowIpDeterminationCB->setChecked(false);
ui.allowIpDeterminationCB->setEnabled(false); ui.allowIpDeterminationCB->setEnabled(false);
ui.IPServersLV->setEnabled(false); ui.IPServersLV->setEnabled(false);
/* TOR PAGE SETTINGS */
/* set local address */
ui.torpage_localAddress->setEnabled(false);
ui.torpage_localAddress->setText(QString::fromStdString(detail.localAddr));
ui.torpage_localPort -> setValue(detail.localPort);
/* set the server address */
ui.torpage_onionAddress->setText(QString::fromStdString(detail.hiddenNodeAddress));
ui.torpage_onionPort -> setValue(detail.hiddenNodePort);
std::string proxyaddr;
uint16_t proxyport;
rsPeers->getProxyServer(proxyaddr, proxyport);
ui.torpage_proxyAddress -> setText(QString::fromStdString(proxyaddr));
ui.torpage_proxyPort -> setValue(proxyport);
QString expected = "HiddenServiceDir </your/path/to/hidden/directory/service>\n";
expected += "HiddenServicePort ";
expected += QString::number(detail.hiddenNodePort);
expected += " ";
expected += QString::fromStdString(detail.localAddr);
expected += ":";
expected += QString::number(detail.localPort);
ui.torpage_configuration->setPlainText(expected);
} }
/** Loads the settings for this page */ /** Loads the settings for this page */
@ -602,30 +640,26 @@ void ServerPage::saveAddressesHiddenNode()
if ((vs_disc != detail.vs_disc) || (vs_dht != detail.vs_dht)) if ((vs_disc != detail.vs_disc) || (vs_dht != detail.vs_dht))
rsPeers->setVisState(ownId, vs_disc, vs_dht); rsPeers->setVisState(ownId, vs_disc, vs_dht);
// Work out what we do with addresses! if (detail.localPort != ui.torpage_localPort->value())
//rsPeers->setExtAddress(ownId, ui.extAddress->text().toStdString(), ui.extPort->value());
if (detail.localPort != ui.localPort->value())
{ {
// Set Local Address - force to 127.0.0.1 // Set Local Address - force to 127.0.0.1
rsPeers->setLocalAddress(ownId, "127.0.0.1", ui.localPort->value()); rsPeers->setLocalAddress(ownId, "127.0.0.1", ui.torpage_localPort->value());
} }
std::string hiddenAddr = ui.extAddress->text().toStdString(); std::string hiddenAddr = ui.torpage_onionAddress->text().toStdString();
uint16_t hiddenPort = ui.extPort->value(); uint16_t hiddenPort = ui.torpage_onionPort->value();
if ((hiddenAddr != detail.hiddenNodeAddress) || (hiddenPort != detail.hiddenNodePort)) if ((hiddenAddr != detail.hiddenNodeAddress) || (hiddenPort != detail.hiddenNodePort))
{ {
rsPeers->setHiddenNode(ownId, hiddenAddr, hiddenPort); rsPeers->setHiddenNode(ownId, hiddenAddr, hiddenPort);
} }
// HANDLE PROXY SERVER. // HANDLE PROXY SERVER.
std::string orig_proxyaddr; std::string orig_proxyaddr;
uint16_t orig_proxyport; uint16_t orig_proxyport;
rsPeers->getProxyServer(orig_proxyaddr, orig_proxyport); rsPeers->getProxyServer(orig_proxyaddr, orig_proxyport);
std::string new_proxyaddr = ui.dynDNS -> text().toStdString(); std::string new_proxyaddr = ui.torpage_proxyAddress -> text().toStdString();
uint16_t new_proxyport = ui.torPort -> value(); uint16_t new_proxyport = ui.torpage_proxyPort -> value();
if ((new_proxyaddr != orig_proxyaddr) || (new_proxyport != orig_proxyport)) if ((new_proxyaddr != orig_proxyaddr) || (new_proxyport != orig_proxyport))
{ {

View File

@ -6,18 +6,18 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>632</width> <width>602</width>
<height>683</height> <height>535</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout"> <layout class="QGridLayout">
<property name="margin"> <property name="margin">
<number>6</number> <number>6</number>
</property> </property>
<item row="1" column="0"> <item row="0" column="0">
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>3</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="title"> <attribute name="title">
@ -201,29 +201,6 @@ peers still need to trust each other to allow connection. </string>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLineEdit" name="dynDNS"/> <widget class="QLineEdit" name="dynDNS"/>
</item> </item>
<item row="2" column="2">
<widget class="QSpinBox" name="torPort">
<property name="toolTip">
<string>The Port that TOR is listening to for outgoing connections. Normally 9100 or 9150</string>
</property>
<property name="minimum">
<number>1024</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>9100</number>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@ -568,6 +545,270 @@ The default value is 20.</string>
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="TorTAB">
<attribute name="title">
<string>TOR Configuration</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QGroupBox" name="torpage_outgoing">
<property name="title">
<string>Outgoing TOR Connections</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>TOR Socks Proxy</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="torpage_proxyAddress"/>
</item>
<item>
<widget class="QSpinBox" name="torpage_proxyPort">
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="iconlabel_tor_outgoing">
<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_9">
<property name="text">
<string>Outgoing Okay</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="plainTextEdit">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="plainText">
<string>TOR Socks Proxy default: 127.0.01:9050. Set in torrc config and update here.
You can connect to Hidden Nodes, even if you
are running a standard Node, so why not setup TOR? </string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="torpage_incoming">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Incoming TOR Connections</string>
</property>
<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">
<number>10</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
<item row="0" column="3">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<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_13">
<property name="text">
<string>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">
<number>10</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>Expected torrc Port Configuration:</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="torpage_configuration">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>10</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="plainText">
<string>HiddenServiceDir &lt;/your/path/to/hidden/directory/service&gt;
HiddenServicePort 9191 127.0.0.1:9191</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="plainTextEdit_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="plainText">
<string>To Receive Connections, you must first setup a TOR Hidden Service.
See TOR documentation for HOWTO details.
Once this is done, paste the Onion Address in the box above.
This is your external address on the TOR network.
Finally make sure that the Ports match the TOR configuration.
If you have issues connecting over TOR check the TOR logs too.</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>18</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -575,7 +816,6 @@ The default value is 20.</string>
<tabstops> <tabstops>
<tabstop>netModeComboBox</tabstop> <tabstop>netModeComboBox</tabstop>
<tabstop>discComboBox</tabstop> <tabstop>discComboBox</tabstop>
<tabstop>tabWidget</tabstop>
<tabstop>localAddress</tabstop> <tabstop>localAddress</tabstop>
<tabstop>localPort</tabstop> <tabstop>localPort</tabstop>
<tabstop>extAddress</tabstop> <tabstop>extAddress</tabstop>