Loading changes/newBridgeLines 0 → 100644 +3 −0 Original line number Diff line number Diff line o Vidalia only validates IPv4 bridge lines. IPv6 bridges are now available, and there will be pluggable transport bridge lines. So the validation is now delegated to Tor through SETCONF. No newline at end of file src/vidalia/config/NetworkPage.cpp +3 −59 Original line number Diff line number Diff line Loading @@ -122,74 +122,18 @@ NetworkPage::onLinkActivated(const QString &url) emit helpRequested(url); } /** Verifies that <b>bridge</b> is a valid bridge identifier and places a * normalized identifier in <b>out</b>. The normalized identifier will have * all spaces removed from the fingerprint portion (if any) and all * hexadecimal characters converted to uppercase. Returns true if * <b>bridge</b> is a valid bridge identifier, false otherwise. */ bool NetworkPage::validateBridge(const QString &bridge, QString *out) { QString temp = bridge; if (temp.startsWith("bridge ", Qt::CaseInsensitive)) temp = temp.remove(0, 7); /* remove "bridge " */ QStringList parts = temp.split(" ", QString::SkipEmptyParts); if (parts.isEmpty()) return false; QString s = parts.at(0); QRegExp re("(\\d{1,3}\\.){3}\\d{1,3}(:\\d{1,5})?"); if (re.exactMatch(s)) { if (s.endsWith(":")) return false; int index = s.indexOf(":"); QString host = s.mid(0, index); if (QHostAddress(host).isNull() || QHostAddress(host).protocol() != QAbstractSocket::IPv4Protocol) { return false; } if (index > 0) { QString port = s.mid(index + 1); if (port.toUInt() < 1 || port.toUInt() > 65535) return false; } temp = s; if (parts.size() > 1) { QString fp = static_cast<QStringList>(parts.mid(1)).join(""); if (fp.length() != 40 || !string_is_hex(fp)) return false; temp += " " + fp.toUpper(); } } else { return false; } *out = temp; return true; } /** Adds a bridge to the bridge list box. */ void NetworkPage::addBridge() { QString bridge; QString input = ui.lineBridge->text().trimmed(); if (input.isEmpty()) return; if (!validateBridge(input, &bridge)) { VMessageBox::warning(this, tr("Invalid Bridge"), tr("The specified bridge identifier is not valid."), VMessageBox::Ok|VMessageBox::Default); return; } if (!ui.listBridges->findItems(bridge, Qt::MatchFixedString).isEmpty()) if (!ui.listBridges->findItems(input, Qt::MatchFixedString).isEmpty()) return; /* duplicate bridge */ ui.listBridges->addItem(bridge); ui.listBridges->addItem(input); ui.lineBridge->clear(); } Loading Loading @@ -319,7 +263,7 @@ NetworkPage::save(QString &errmsg) if (ui.chkUseBridges->isChecked()) { if (ui.listBridges->count() < 1) { errmsg = tr("You must specify one or more briges."); errmsg = tr("You must specify one or more bridges."); return false; } } Loading src/vidalia/config/NetworkPage.h +0 −7 Original line number Diff line number Diff line Loading @@ -81,13 +81,6 @@ private slots: void proxyTypeChanged(int selection); private: /** Verifies that <b>bridge</b> is a valid bridge identifier and places a * normalized identifier in <b>out</b>. The normalized identifier will have * all spaces removed from the fingerprint portion (if any) and all * hexadecimal characters converted to uppercase. Returns true if * <b>bridge</b> is a valid bridge identifier, false otherwise. */ bool validateBridge(const QString &bridge, QString *out); /** Helper class used to facilitate downloading one or more bridge * addresses. */ BridgeDownloader* _bridgeDownloader; Loading Loading
changes/newBridgeLines 0 → 100644 +3 −0 Original line number Diff line number Diff line o Vidalia only validates IPv4 bridge lines. IPv6 bridges are now available, and there will be pluggable transport bridge lines. So the validation is now delegated to Tor through SETCONF. No newline at end of file
src/vidalia/config/NetworkPage.cpp +3 −59 Original line number Diff line number Diff line Loading @@ -122,74 +122,18 @@ NetworkPage::onLinkActivated(const QString &url) emit helpRequested(url); } /** Verifies that <b>bridge</b> is a valid bridge identifier and places a * normalized identifier in <b>out</b>. The normalized identifier will have * all spaces removed from the fingerprint portion (if any) and all * hexadecimal characters converted to uppercase. Returns true if * <b>bridge</b> is a valid bridge identifier, false otherwise. */ bool NetworkPage::validateBridge(const QString &bridge, QString *out) { QString temp = bridge; if (temp.startsWith("bridge ", Qt::CaseInsensitive)) temp = temp.remove(0, 7); /* remove "bridge " */ QStringList parts = temp.split(" ", QString::SkipEmptyParts); if (parts.isEmpty()) return false; QString s = parts.at(0); QRegExp re("(\\d{1,3}\\.){3}\\d{1,3}(:\\d{1,5})?"); if (re.exactMatch(s)) { if (s.endsWith(":")) return false; int index = s.indexOf(":"); QString host = s.mid(0, index); if (QHostAddress(host).isNull() || QHostAddress(host).protocol() != QAbstractSocket::IPv4Protocol) { return false; } if (index > 0) { QString port = s.mid(index + 1); if (port.toUInt() < 1 || port.toUInt() > 65535) return false; } temp = s; if (parts.size() > 1) { QString fp = static_cast<QStringList>(parts.mid(1)).join(""); if (fp.length() != 40 || !string_is_hex(fp)) return false; temp += " " + fp.toUpper(); } } else { return false; } *out = temp; return true; } /** Adds a bridge to the bridge list box. */ void NetworkPage::addBridge() { QString bridge; QString input = ui.lineBridge->text().trimmed(); if (input.isEmpty()) return; if (!validateBridge(input, &bridge)) { VMessageBox::warning(this, tr("Invalid Bridge"), tr("The specified bridge identifier is not valid."), VMessageBox::Ok|VMessageBox::Default); return; } if (!ui.listBridges->findItems(bridge, Qt::MatchFixedString).isEmpty()) if (!ui.listBridges->findItems(input, Qt::MatchFixedString).isEmpty()) return; /* duplicate bridge */ ui.listBridges->addItem(bridge); ui.listBridges->addItem(input); ui.lineBridge->clear(); } Loading Loading @@ -319,7 +263,7 @@ NetworkPage::save(QString &errmsg) if (ui.chkUseBridges->isChecked()) { if (ui.listBridges->count() < 1) { errmsg = tr("You must specify one or more briges."); errmsg = tr("You must specify one or more bridges."); return false; } } Loading
src/vidalia/config/NetworkPage.h +0 −7 Original line number Diff line number Diff line Loading @@ -81,13 +81,6 @@ private slots: void proxyTypeChanged(int selection); private: /** Verifies that <b>bridge</b> is a valid bridge identifier and places a * normalized identifier in <b>out</b>. The normalized identifier will have * all spaces removed from the fingerprint portion (if any) and all * hexadecimal characters converted to uppercase. Returns true if * <b>bridge</b> is a valid bridge identifier, false otherwise. */ bool validateBridge(const QString &bridge, QString *out); /** Helper class used to facilitate downloading one or more bridge * addresses. */ BridgeDownloader* _bridgeDownloader; Loading