Browse Source

Merge pull request #5877 from dzmat/to_pull_request

locally banned IP list managment (Closes #1837 )
adaptive-webui-19844
sledgehammer999 8 years ago committed by GitHub
parent
commit
5084c01c2b
  1. 2
      src/base/base.pri
  2. 59
      src/base/bittorrent/session.cpp
  3. 2
      src/base/bittorrent/session.h
  4. 42
      src/base/utils/net.cpp
  5. 41
      src/base/utils/net.h
  6. 99
      src/gui/banlistoptions.cpp
  7. 58
      src/gui/banlistoptions.h
  8. 115
      src/gui/banlistoptions.ui
  9. 9
      src/gui/gui.pri
  10. 8
      src/gui/optionsdlg.cpp
  11. 1
      src/gui/optionsdlg.h
  12. 13
      src/gui/optionsdlg.ui
  13. 3
      src/webui/prefjson.cpp
  14. 10
      src/webui/www/public/preferences_content.html

2
src/base/base.pri

@ -52,6 +52,7 @@ HEADERS += \
$$PWD/utils/fs.h \ $$PWD/utils/fs.h \
$$PWD/utils/gzip.h \ $$PWD/utils/gzip.h \
$$PWD/utils/misc.h \ $$PWD/utils/misc.h \
$$PWD/utils/net.h \
$$PWD/utils/random.h \ $$PWD/utils/random.h \
$$PWD/utils/string.h \ $$PWD/utils/string.h \
$$PWD/unicodestrings.h \ $$PWD/unicodestrings.h \
@ -108,6 +109,7 @@ SOURCES += \
$$PWD/utils/fs.cpp \ $$PWD/utils/fs.cpp \
$$PWD/utils/gzip.cpp \ $$PWD/utils/gzip.cpp \
$$PWD/utils/misc.cpp \ $$PWD/utils/misc.cpp \
$$PWD/utils/net.cpp \
$$PWD/utils/random.cpp \ $$PWD/utils/random.cpp \
$$PWD/utils/string.cpp \ $$PWD/utils/string.cpp \
$$PWD/torrentfileguard.cpp \ $$PWD/torrentfileguard.cpp \

59
src/base/bittorrent/session.cpp

@ -1,4 +1,3 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru> * Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru>
@ -74,6 +73,7 @@
#include "base/torrentfileguard.h" #include "base/torrentfileguard.h"
#include "base/torrentfilter.h" #include "base/torrentfilter.h"
#include "base/unicodestrings.h" #include "base/unicodestrings.h"
#include "base/utils/net.h"
#include "base/utils/misc.h" #include "base/utils/misc.h"
#include "base/utils/fs.h" #include "base/utils/fs.h"
#include "base/utils/random.h" #include "base/utils/random.h"
@ -275,7 +275,15 @@ Session::Session(QObject *parent)
, m_isDisableAutoTMMWhenDefaultSavePathChanged(BITTORRENT_SESSION_KEY("DisableAutoTMMTriggers/DefaultSavePathChanged"), true) , m_isDisableAutoTMMWhenDefaultSavePathChanged(BITTORRENT_SESSION_KEY("DisableAutoTMMTriggers/DefaultSavePathChanged"), true)
, m_isDisableAutoTMMWhenCategorySavePathChanged(BITTORRENT_SESSION_KEY("DisableAutoTMMTriggers/CategorySavePathChanged"), true) , m_isDisableAutoTMMWhenCategorySavePathChanged(BITTORRENT_SESSION_KEY("DisableAutoTMMTriggers/CategorySavePathChanged"), true)
, m_isTrackerEnabled(BITTORRENT_KEY("TrackerEnabled"), false) , m_isTrackerEnabled(BITTORRENT_KEY("TrackerEnabled"), false)
, m_bannedIPs("State/BannedIPs") , m_bannedIPs("State/BannedIPs"
, QStringList()
, [](const QStringList &value)
{
QStringList tmp = value;
tmp.sort();
return tmp;
}
)
, m_wasPexEnabled(m_isPeXEnabled) , m_wasPexEnabled(m_isPeXEnabled)
, m_numResumeData(0) , m_numResumeData(0)
, m_extraLimit(0) , m_extraLimit(0)
@ -1376,6 +1384,7 @@ void Session::banIP(const QString &ip)
m_nativeSession->set_ip_filter(filter); m_nativeSession->set_ip_filter(filter);
bannedIPs << ip; bannedIPs << ip;
bannedIPs.sort();
m_bannedIPs = bannedIPs; m_bannedIPs = bannedIPs;
} }
} }
@ -2379,6 +2388,45 @@ void Session::setIPFilterFile(QString path)
} }
} }
void Session::setBannedIPs(const QStringList &newList)
{
if (newList == m_bannedIPs)
return; // do nothing
// here filter out incorrect IP
QStringList filteredList;
for (const QString &ip : newList) {
if (Utils::Net::isValidIP(ip)) {
// the same IPv6 addresses could be written in different forms;
// QHostAddress::toString() result format follows RFC5952;
// thus we avoid duplicate entries pointing to the same address
filteredList << QHostAddress(ip).toString();
}
else {
Logger::instance()->addMessage(
tr("%1 is not a valid IP address and was rejected while applying the list of banned addresses.")
.arg(ip)
, Log::WARNING);
}
}
// now we have to sort IPs and make them unique
filteredList.sort();
filteredList.removeDuplicates();
// Again ensure that the new list is different from the stored one.
if (filteredList == m_bannedIPs)
return; // do nothing
// store to session settings
// also here we have to recreate filter list including 3rd party ban file
// and install it again into m_session
m_bannedIPs = filteredList;
m_IPFilteringChanged = true;
configureDeferred();
}
QStringList Session::bannedIPs() const
{
return m_bannedIPs;
}
int Session::maxConnectionsPerTorrent() const int Session::maxConnectionsPerTorrent() const
{ {
return m_maxConnectionsPerTorrent; return m_maxConnectionsPerTorrent;
@ -2976,15 +3024,20 @@ void Session::configureDeferred()
} }
// Enable IP Filtering // Enable IP Filtering
// this method creates ban list from scratch combining user ban list and 3rd party ban list file
void Session::enableIPFilter() void Session::enableIPFilter()
{ {
qDebug("Enabling IPFilter"); qDebug("Enabling IPFilter");
// 1. Clear existing ban list
// 2. Add manual ban list
// 3. Add 3rd party ban list
m_nativeSession->set_ip_filter(libt::ip_filter());
processBannedIPs();
if (!m_filterParser) { if (!m_filterParser) {
m_filterParser = new FilterParserThread(m_nativeSession, this); m_filterParser = new FilterParserThread(m_nativeSession, this);
connect(m_filterParser.data(), SIGNAL(IPFilterParsed(int)), SLOT(handleIPFilterParsed(int))); connect(m_filterParser.data(), SIGNAL(IPFilterParsed(int)), SLOT(handleIPFilterParsed(int)));
connect(m_filterParser.data(), SIGNAL(IPFilterError()), SLOT(handleIPFilterError())); connect(m_filterParser.data(), SIGNAL(IPFilterError()), SLOT(handleIPFilterError()));
} }
m_filterParser->processFilterFile(IPFilterFile()); m_filterParser->processFilterFile(IPFilterFile());
} }

2
src/base/bittorrent/session.h

@ -326,6 +326,8 @@ namespace BitTorrent
void setUTPRateLimited(bool limited); void setUTPRateLimited(bool limited);
bool isTrackerFilteringEnabled() const; bool isTrackerFilteringEnabled() const;
void setTrackerFilteringEnabled(bool enabled); void setTrackerFilteringEnabled(bool enabled);
QStringList bannedIPs() const;
void setBannedIPs(const QStringList &list);
TorrentHandle *findTorrent(const InfoHash &hash) const; TorrentHandle *findTorrent(const InfoHash &hash) const;
QHash<InfoHash, TorrentHandle *> torrents() const; QHash<InfoHash, TorrentHandle *> torrents() const;

42
src/base/utils/net.cpp

@ -0,0 +1,42 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2016 Alexandr Milovantsev <dzmat@yandex.ru>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#include "net.h"
#include <QHostAddress>
#include <QString>
namespace Utils
{
namespace Net
{
bool isValidIP(const QString &ip)
{
return !QHostAddress(ip).isNull();
}
}
}

41
src/base/utils/net.h

@ -0,0 +1,41 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2016 Alexandr Milovantsev <dzmat@yandex.ru>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#ifndef BASE_UTILS_NET_H
#define BASE_UTILS_NET_H
class QString;
namespace Utils
{
namespace Net
{
bool isValidIP(const QString &ip);
}
}
#endif // BASE_UTILS_NET_H

99
src/gui/banlistoptions.cpp

@ -0,0 +1,99 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2016 Alexandr Milovantsev <dzmat@yandex.ru>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#include "banlistoptions.h"
#include "ui_banlistoptions.h"
#include <QMessageBox>
#include <QHostAddress>
#include "base/bittorrent/session.h"
#include "base/utils/net.h"
BanListOptions::BanListOptions(QWidget *parent)
: QDialog(parent)
, m_ui(new Ui::BanListOptions)
, m_modified(false)
{
m_ui->setupUi(this);
m_ui->bannedIPList->addItems(BitTorrent::Session::instance()->bannedIPs());
m_ui->buttonBanIP->setEnabled(false);
}
BanListOptions::~BanListOptions()
{
delete m_ui;
}
void BanListOptions::on_buttonBox_accepted()
{
if (m_modified) {
// save to session
QStringList IPList;
for (int i = 0; i < m_ui->bannedIPList->count(); ++i)
IPList << m_ui->bannedIPList->item(i)->text();
BitTorrent::Session::instance()->setBannedIPs(IPList);
}
QDialog::accept();
}
void BanListOptions::on_buttonBanIP_clicked()
{
QString ip=m_ui->txtIP->text();
if (!Utils::Net::isValidIP(ip)) {
QMessageBox::warning(this, tr("Warning"), tr("The entered IP address is invalid."));
return;
}
// the same IPv6 addresses could be written in different forms;
// QHostAddress::toString() result format follows RFC5952;
// thus we avoid duplicate entries pointing to the same address
ip = QHostAddress(ip).toString();
QList<QListWidgetItem *> findres = m_ui->bannedIPList->findItems(ip, Qt::MatchExactly);
if (!findres.isEmpty()) {
QMessageBox::warning(this, tr("Warning"), tr("The entered IP is already banned."));
return;
}
m_ui->bannedIPList->addItem(ip);
m_ui->txtIP->clear();
m_modified = true;
}
void BanListOptions::on_buttonDeleteIP_clicked()
{
QList<QListWidgetItem *> selection = m_ui->bannedIPList->selectedItems();
for (auto &i : selection) {
m_ui->bannedIPList->removeItemWidget(i);
delete i;
}
m_modified = true;
}
void BanListOptions::on_txtIP_textChanged(const QString &ip)
{
m_ui->buttonBanIP->setEnabled(Utils::Net::isValidIP(ip));
}

58
src/gui/banlistoptions.h

@ -0,0 +1,58 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2016 Alexandr Milovantsev <dzmat@yandex.ru>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#ifndef OPTIONS_BANLIST_H
#define OPTIONS_BANLIST_H
#include <QDialog>
namespace Ui
{
class BanListOptions;
}
class BanListOptions: public QDialog
{
Q_OBJECT
public:
explicit BanListOptions(QWidget *parent = 0);
~BanListOptions();
private slots:
void on_buttonBox_accepted();
void on_buttonBanIP_clicked();
void on_buttonDeleteIP_clicked();
void on_txtIP_textChanged(const QString &ip);
private:
Ui::BanListOptions *m_ui;
bool m_modified;
};
#endif // OPTIONS_BANLIST_H

115
src/gui/banlistoptions.ui

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BanListOptions</class>
<widget class="QDialog" name="BanListOptions">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>360</width>
<height>450</height>
</rect>
</property>
<property name="windowTitle">
<string>List of banned IP addresses</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="bannedIPBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="midLineWidth">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_21">
<item>
<widget class="QListWidget" name="bannedIPList">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_18">
<item>
<widget class="QLineEdit" name="txtIP"/>
</item>
<item>
<widget class="QPushButton" name="buttonBanIP">
<property name="text">
<string>Ban IP</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonDeleteIP">
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>bannedIPList</tabstop>
<tabstop>txtIP</tabstop>
<tabstop>buttonBanIP</tabstop>
<tabstop>buttonDeleteIP</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>BanListOptions</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>179</x>
<y>427</y>
</hint>
<hint type="destinationlabel">
<x>179</x>
<y>224</y>
</hint>
</hints>
</connection>
</connections>
</ui>

9
src/gui/gui.pri

@ -51,7 +51,8 @@ HEADERS += \
$$PWD/cookiesmodel.h \ $$PWD/cookiesmodel.h \
$$PWD/cookiesdialog.h \ $$PWD/cookiesdialog.h \
$$PWD/categoryfiltermodel.h \ $$PWD/categoryfiltermodel.h \
$$PWD/categoryfilterwidget.h $$PWD/categoryfilterwidget.h \
$$PWD/banlistoptions.h
SOURCES += \ SOURCES += \
$$PWD/mainwindow.cpp \ $$PWD/mainwindow.cpp \
@ -93,7 +94,8 @@ SOURCES += \
$$PWD/cookiesmodel.cpp \ $$PWD/cookiesmodel.cpp \
$$PWD/cookiesdialog.cpp \ $$PWD/cookiesdialog.cpp \
$$PWD/categoryfiltermodel.cpp \ $$PWD/categoryfiltermodel.cpp \
$$PWD/categoryfilterwidget.cpp $$PWD/categoryfilterwidget.cpp \
$$PWD/banlistoptions.cpp
win32|macx { win32|macx {
HEADERS += $$PWD/programupdater.h HEADERS += $$PWD/programupdater.h
@ -120,6 +122,7 @@ FORMS += \
$$PWD/search/pluginselectdlg.ui \ $$PWD/search/pluginselectdlg.ui \
$$PWD/search/pluginsourcedlg.ui \ $$PWD/search/pluginsourcedlg.ui \
$$PWD/search/searchtab.ui \ $$PWD/search/searchtab.ui \
$$PWD/cookiesdialog.ui $$PWD/cookiesdialog.ui \
$$PWD/banlistoptions.ui
RESOURCES += $$PWD/about.qrc RESOURCES += $$PWD/about.qrc

8
src/gui/optionsdlg.cpp

@ -61,6 +61,7 @@
#include "base/utils/random.h" #include "base/utils/random.h"
#include "addnewtorrentdialog.h" #include "addnewtorrentdialog.h"
#include "advancedsettings.h" #include "advancedsettings.h"
#include "banlistoptions.h"
#include "guiiconprovider.h" #include "guiiconprovider.h"
#include "scanfoldersdelegate.h" #include "scanfoldersdelegate.h"
@ -1701,3 +1702,10 @@ bool OptionsDialog::webUIAuthenticationOk()
} }
return true; return true;
} }
void OptionsDialog::on_banListButton_clicked()
{
//have to call dialog window
BanListOptions bl(this);
bl.exec();
}

1
src/gui/optionsdlg.h

@ -93,6 +93,7 @@ private slots:
void handleScanFolderViewSelectionChanged(); void handleScanFolderViewSelectionChanged();
void on_IpFilterRefreshBtn_clicked(); void on_IpFilterRefreshBtn_clicked();
void handleIPFilterParsed(bool error, int ruleCount); void handleIPFilterParsed(bool error, int ruleCount);
void on_banListButton_clicked();
void on_browseFileLogDir_clicked(); void on_browseFileLogDir_clicked();
void on_browseExportDirButton_clicked(); void on_browseExportDirButton_clicked();
void on_browseExportDirFinButton_clicked(); void on_browseExportDirFinButton_clicked();

13
src/gui/optionsdlg.ui

@ -1768,6 +1768,19 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QPushButton" name="banListButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Manually banned IP addresses...</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="checkIpFilterTrackers"> <widget class="QCheckBox" name="checkIpFilterTrackers">
<property name="text"> <property name="text">

3
src/webui/prefjson.cpp

@ -114,6 +114,7 @@ QByteArray prefjson::getPreferences()
data["ip_filter_enabled"] = session->isIPFilteringEnabled(); data["ip_filter_enabled"] = session->isIPFilteringEnabled();
data["ip_filter_path"] = Utils::Fs::toNativePath(session->IPFilterFile()); data["ip_filter_path"] = Utils::Fs::toNativePath(session->IPFilterFile());
data["ip_filter_trackers"] = session->isTrackerFilteringEnabled(); data["ip_filter_trackers"] = session->isTrackerFilteringEnabled();
data["banned_IPs"] = session->bannedIPs().join("\n");
// Speed // Speed
// Global Rate Limits // Global Rate Limits
@ -309,6 +310,8 @@ void prefjson::setPreferences(const QString& json)
session->setIPFilterFile(m["ip_filter_path"].toString()); session->setIPFilterFile(m["ip_filter_path"].toString());
if (m.contains("ip_filter_trackers")) if (m.contains("ip_filter_trackers"))
session->setTrackerFilteringEnabled(m["ip_filter_trackers"].toBool()); session->setTrackerFilteringEnabled(m["ip_filter_trackers"].toBool());
if (m.contains("banned_IPs"))
session->setBannedIPs(m["banned_IPs"].toString().split('\n'));
// Speed // Speed
// Global Rate Limits // Global Rate Limits

10
src/webui/www/public/preferences_content.html

@ -180,6 +180,12 @@
<input type="text" id="ipfilter_text"/><br/> <input type="text" id="ipfilter_text"/><br/>
<input type="checkbox" id="ipfilter_trackers_checkbox"/> <input type="checkbox" id="ipfilter_trackers_checkbox"/>
<label for="ipfilter_trackers_checkbox">QBT_TR(Apply to trackers)QBT_TR</label> <label for="ipfilter_trackers_checkbox">QBT_TR(Apply to trackers)QBT_TR</label>
<div class="formRow">
<fieldset class="settings">
<legend>QBT_TR(Manually banned IP addresses...)QBT_TR</legend>
<textarea id="banned_IPs_textarea" rows="5" cols="70"></textarea>
</fieldset>
</div>
</fieldset> </fieldset>
</div> </div>
@ -637,9 +643,11 @@ updateFilterSettings = function() {
if($('ipfilter_enabled_checkbox').getProperty('checked')) { if($('ipfilter_enabled_checkbox').getProperty('checked')) {
$('ipfilter_text').setProperty('disabled', false); $('ipfilter_text').setProperty('disabled', false);
$('ipfilter_trackers_checkbox').setProperty('disabled', false); $('ipfilter_trackers_checkbox').setProperty('disabled', false);
$('banned_IPs_textarea').setProperty('disabled', false);
} else { } else {
$('ipfilter_text').setProperty('disabled', true); $('ipfilter_text').setProperty('disabled', true);
$('ipfilter_trackers_checkbox').setProperty('disabled', true); $('ipfilter_trackers_checkbox').setProperty('disabled', true);
$('banned_IPs_textarea').setProperty('disabled', true);
} }
} }
@ -913,6 +921,7 @@ loadPreferences = function() {
$('ipfilter_enabled_checkbox').setProperty('checked', pref.ip_filter_enabled); $('ipfilter_enabled_checkbox').setProperty('checked', pref.ip_filter_enabled);
$('ipfilter_text').setProperty('value', pref.ip_filter_path); $('ipfilter_text').setProperty('value', pref.ip_filter_path);
$('ipfilter_trackers_checkbox').setProperty('checked', pref.ip_filter_trackers); $('ipfilter_trackers_checkbox').setProperty('checked', pref.ip_filter_trackers);
$('banned_IPs_textarea').setProperty('value', pref.banned_IPs);
updateFilterSettings(); updateFilterSettings();
// Speed tab // Speed tab
@ -1146,6 +1155,7 @@ applyPreferences = function() {
settings.set('ip_filter_enabled', $('ipfilter_enabled_checkbox').getProperty('checked')); settings.set('ip_filter_enabled', $('ipfilter_enabled_checkbox').getProperty('checked'));
settings.set('ip_filter_path', $('ipfilter_text').getProperty('value')); settings.set('ip_filter_path', $('ipfilter_text').getProperty('value'));
settings.set('ip_filter_trackers', $('ipfilter_trackers_checkbox').getProperty('checked')); settings.set('ip_filter_trackers', $('ipfilter_trackers_checkbox').getProperty('checked'));
settings.set('banned_IPs', $('banned_IPs_textarea').getProperty('value'));
// Speed tab // Speed tab
// Global Rate Limits // Global Rate Limits

Loading…
Cancel
Save