commit 552ea29ed456c9275f075863b15166135ddb3967 Author: Tomas Touceda chiiph@gentoo.org Date: Sat Apr 30 18:18:18 2011 -0300
Adds a non-exit option to the sharing tab
Set middleman as the default exitpolicy for everything, the user has to explicitly check boxes to allow exit traffic. --- src/vidalia/config/ServerPage.cpp | 94 ++++++++++++++++++++------------- src/vidalia/config/ServerPage.ui | 9 +++- src/vidalia/config/ServerSettings.cpp | 18 ++++++- src/vidalia/config/ServerSettings.h | 6 ++ 4 files changed, 89 insertions(+), 38 deletions(-)
diff --git a/src/vidalia/config/ServerPage.cpp b/src/vidalia/config/ServerPage.cpp index d42fb70..16e244a 100644 --- a/src/vidalia/config/ServerPage.cpp +++ b/src/vidalia/config/ServerPage.cpp @@ -89,6 +89,8 @@ ServerPage::ServerPage(QWidget *parent) this, SLOT(customRateChanged())); connect(ui.rdoClientMode, SIGNAL(toggled(bool)), this, SLOT(serverModeChanged(bool))); + connect(ui.rdoNonExitMode, SIGNAL(toggled(bool)), + this, SLOT(serverModeChanged(bool))); connect(ui.rdoServerMode, SIGNAL(toggled(bool)), this, SLOT(serverModeChanged(bool))); connect(ui.rdoBridgeMode, SIGNAL(toggled(bool)), @@ -217,10 +219,12 @@ ServerPage::serverModeChanged(bool enabled) { Q_UNUSED(enabled); bool bridgeEnabled = ui.rdoBridgeMode->isChecked(); + bool relayEnabled = ui.rdoServerMode->isChecked() || + ui.rdoNonExitMode->isChecked();
/* Show the tab menu only if the user is running a normal relay or a bridge * relay. */ - ui.tabsMenu->setVisible(ui.rdoServerMode->isChecked() || bridgeEnabled); + ui.tabsMenu->setVisible(relayEnabled || bridgeEnabled);
/* Disable the Exit Policies tab when bridge relay mode is selected */ ui.tabsMenu->setTabEnabled(2, !bridgeEnabled); @@ -236,6 +240,13 @@ ServerPage::serverModeChanged(bool enabled)
ui.lineDirPort->setEnabled(!bridgeEnabled); ui.chkMirrorDirectory->setEnabled(!bridgeEnabled); + + ui.chkWebsites->setEnabled(!ui.rdoNonExitMode->isChecked()); + ui.chkSecWebsites->setEnabled(!ui.rdoNonExitMode->isChecked()); + ui.chkMail->setEnabled(!ui.rdoNonExitMode->isChecked()); + ui.chkIRC->setEnabled(!ui.rdoNonExitMode->isChecked()); + ui.chkIM->setEnabled(!ui.rdoNonExitMode->isChecked()); + ui.chkMisc->setEnabled(!ui.rdoNonExitMode->isChecked()); }
/** Returns true if the user has changed their server settings since the @@ -270,7 +281,9 @@ ServerPage::save(QString &errmsg) /* Force the bandwidth rate limits to validate */ customRateChanged();
- if (ui.rdoServerMode->isChecked() || ui.rdoBridgeMode->isChecked()) { + if (ui.rdoServerMode->isChecked() || + ui.rdoNonExitMode->isChecked() || + ui.rdoBridgeMode->isChecked()) { /* A server must have an ORPort and a nickname */ if (ui.lineServerPort->text().isEmpty() || ui.lineServerNickname->text().isEmpty()) { @@ -289,7 +302,9 @@ ServerPage::save(QString &errmsg) /* "Server" is enabled whether we're a bridge or normal relay. "Bridge" is * only enabled if we're a bridge (obviously). */ _settings->setServerEnabled(ui.rdoServerMode->isChecked() + || ui.rdoNonExitMode->isChecked() || ui.rdoBridgeMode->isChecked()); + _settings->setNonExitEnabled(ui.rdoNonExitMode->isChecked()); _settings->setBridgeEnabled(ui.rdoBridgeMode->isChecked()); if (ui.rdoBridgeMode->isChecked()) _settings->setPublishServerDescriptor(ui.chkPublishBridgeAddress->isChecked()); @@ -320,6 +335,8 @@ ServerPage::load() { if (_settings->isBridgeEnabled()) ui.rdoBridgeMode->setChecked(true); + else if (_settings->isNonExitEnabled()) + ui.rdoNonExitMode->setChecked(true); else if (_settings->isServerEnabled()) ui.rdoServerMode->setChecked(true); else @@ -460,41 +477,46 @@ ServerPage::loadExitPolicies() void ServerPage::saveExitPolicies() { - ExitPolicy exitPolicy; - bool rejectUnchecked = ui.chkMisc->isChecked(); - - /* If misc is checked, then reject unchecked items and leave the default exit - * policy alone. Else, accept only checked items and end with reject *:*, - * replacing the default exit policy. */ - if (ui.chkWebsites->isChecked() && !rejectUnchecked) { - exitPolicy.addAcceptedPorts(PORTS_HTTP); - } else if (!ui.chkWebsites->isChecked() && rejectUnchecked) { - exitPolicy.addRejectedPorts(PORTS_HTTP); - } - if (ui.chkSecWebsites->isChecked() && !rejectUnchecked) { - exitPolicy.addAcceptedPorts(PORTS_HTTPS); - } else if (!ui.chkSecWebsites->isChecked() && rejectUnchecked) { - exitPolicy.addRejectedPorts(PORTS_HTTPS); - } - if (ui.chkMail->isChecked() && !rejectUnchecked) { - exitPolicy.addAcceptedPorts(PORTS_MAIL); - } else if (!ui.chkMail->isChecked() && rejectUnchecked) { - exitPolicy.addRejectedPorts(PORTS_MAIL); - } - if (ui.chkIRC->isChecked() && !rejectUnchecked) { - exitPolicy.addAcceptedPorts(PORTS_IRC); - } else if (!ui.chkIRC->isChecked() && rejectUnchecked) { - exitPolicy.addRejectedPorts(PORTS_IRC); - } - if (ui.chkIM->isChecked() && !rejectUnchecked) { - exitPolicy.addAcceptedPorts(PORTS_IM); - } else if (!ui.chkIM->isChecked() && rejectUnchecked) { - exitPolicy.addRejectedPorts(PORTS_IM); - } - if (!ui.chkMisc->isChecked()) { - exitPolicy.addPolicy(Policy(Policy::RejectAll)); + ExitPolicy *exitPolicy; + if(ui.rdoNonExitMode->isChecked()) { + exitPolicy = new ExitPolicy(ExitPolicy::Middleman); + } else { + exitPolicy = new ExitPolicy(); + bool rejectUnchecked = ui.chkMisc->isChecked(); + + /* If misc is checked, then reject unchecked items and leave the default exit + * policy alone. Else, accept only checked items and end with reject *:*, + * replacing the default exit policy. */ + if (ui.chkWebsites->isChecked() && !rejectUnchecked) { + exitPolicy->addAcceptedPorts(PORTS_HTTP); + } else if (!ui.chkWebsites->isChecked() && rejectUnchecked) { + exitPolicy->addRejectedPorts(PORTS_HTTP); + } + if (ui.chkSecWebsites->isChecked() && !rejectUnchecked) { + exitPolicy->addAcceptedPorts(PORTS_HTTPS); + } else if (!ui.chkSecWebsites->isChecked() && rejectUnchecked) { + exitPolicy->addRejectedPorts(PORTS_HTTPS); + } + if (ui.chkMail->isChecked() && !rejectUnchecked) { + exitPolicy->addAcceptedPorts(PORTS_MAIL); + } else if (!ui.chkMail->isChecked() && rejectUnchecked) { + exitPolicy->addRejectedPorts(PORTS_MAIL); + } + if (ui.chkIRC->isChecked() && !rejectUnchecked) { + exitPolicy->addAcceptedPorts(PORTS_IRC); + } else if (!ui.chkIRC->isChecked() && rejectUnchecked) { + exitPolicy->addRejectedPorts(PORTS_IRC); + } + if (ui.chkIM->isChecked() && !rejectUnchecked) { + exitPolicy->addAcceptedPorts(PORTS_IM); + } else if (!ui.chkIM->isChecked() && rejectUnchecked) { + exitPolicy->addRejectedPorts(PORTS_IM); + } + if (!ui.chkMisc->isChecked()) { + exitPolicy->addPolicy(Policy(Policy::RejectAll)); + } } - _settings->setExitPolicy(exitPolicy); + _settings->setExitPolicy(*exitPolicy); }
/** Called when the user selects a new value from the rate combo box. */ diff --git a/src/vidalia/config/ServerPage.ui b/src/vidalia/config/ServerPage.ui index 6584058..c922710 100644 --- a/src/vidalia/config/ServerPage.ui +++ b/src/vidalia/config/ServerPage.ui @@ -22,9 +22,16 @@ </widget> </item> <item> + <widget class="QRadioButton" name="rdoNonExitMode"> + <property name="text"> + <string>Relay traffic inside the Tor network (non-exit relay)</string> + </property> + </widget> + </item> + <item> <widget class="QRadioButton" name="rdoServerMode"> <property name="text"> - <string>Relay traffic for the Tor network</string> + <string>Relay traffic for the Tor network (exit relay)</string> </property> </widget> </item> diff --git a/src/vidalia/config/ServerSettings.cpp b/src/vidalia/config/ServerSettings.cpp index 22de6d6..2fde4f3 100644 --- a/src/vidalia/config/ServerSettings.cpp +++ b/src/vidalia/config/ServerSettings.cpp @@ -43,6 +43,7 @@ #define SETTING_BANDWIDTH_RATE "BandwidthRate" #define SETTING_BANDWIDTH_BURST "BandwidthBurst" #define SETTING_BRIDGE_RELAY "BridgeRelay" +#define SETTING_NONEXIT_RELAY "NonExitRelay" #define SETTING_ENABLE_UPNP "EnableUPnP" #define SETTING_RELAY_BANDWIDTH_RATE "RelayBandwidthRate" #define SETTING_RELAY_BANDWIDTH_BURST "RelayBandwidthBurst" @@ -71,7 +72,7 @@ ServerSettings::ServerSettings(TorControl *torControl) setDefault(SETTING_BANDWIDTH_BURST, 10485760); setDefault(SETTING_RELAY_BANDWIDTH_BURST, 10485760); setDefault(SETTING_EXITPOLICY, - ExitPolicy(ExitPolicy::Default).toString()); + ExitPolicy(ExitPolicy::Middleman).toString()); setDefault(SETTING_ENABLE_UPNP, false); setDefault(SETTING_BRIDGE_RELAY, false); setDefault(SETTING_PUBLISH_SERVER_DESCRIPTOR, "1"); @@ -258,6 +259,21 @@ ServerSettings::isBridgeEnabled() return value(SETTING_BRIDGE_RELAY).toBool() && isServerEnabled(); }
+/** Sets to <b>enabled</b> whether Tor should be a non-exit node when acting as + * a server. */ +void +ServerSettings::setNonExitEnabled(bool enabled) +{ + setValue(SETTING_NONEXIT_RELAY, enabled); +} + +/** Returns true if Tor is configured to act as a non-exit node. */ +bool +ServerSettings::isNonExitEnabled() +{ + return value(SETTING_NONEXIT_RELAY).toBool() && isServerEnabled(); +} + /** Sets the server's ORPort. */ void ServerSettings::setORPort(quint16 orPort) diff --git a/src/vidalia/config/ServerSettings.h b/src/vidalia/config/ServerSettings.h index 79a5db9..f5d5b9a 100644 --- a/src/vidalia/config/ServerSettings.h +++ b/src/vidalia/config/ServerSettings.h @@ -42,6 +42,12 @@ public: /** Returns true if Tor is configured to act as a bridge node. */ bool isBridgeEnabled();
+ /** Sets to <b>enabled</b> whether Tor should be a non-exit node when acting + * as a server. */ + void setNonExitEnabled(bool enable); + /** Returns true if Tor is configured to act as a non-exit node. */ + bool isNonExitEnabled(); + /** Sets the server's ORPort value. */ void setORPort(quint16 orPort); /** Gets the server's ORPort value. */
tor-commits@lists.torproject.org