Browse Source

Misc fixes.

adaptive-webui-19844
sledgehammer999 8 years ago
parent
commit
1757973f88
  1. 24
      src/base/bittorrent/session.cpp
  2. 4
      src/base/net/portforwarder.cpp
  3. 7
      src/base/net/proxyconfigurationmanager.cpp
  4. 2
      src/base/settingsstorage.cpp
  5. 2
      src/gui/advancedsettings.cpp

24
src/base/bittorrent/session.cpp

@ -90,9 +90,9 @@
#include "tracker.h" #include "tracker.h"
#include "trackerentry.h" #include "trackerentry.h"
const char PEER_ID[] = "qB"; static const char PEER_ID[] = "qB";
const char RESUME_FOLDER[] = "BT_backup"; static const char RESUME_FOLDER[] = "BT_backup";
const char USER_AGENT[] = "qBittorrent " VERSION; static const char USER_AGENT[] = "qBittorrent " VERSION;
namespace libt = libtorrent; namespace libt = libtorrent;
using namespace BitTorrent; using namespace BitTorrent;
@ -416,7 +416,6 @@ Session::Session(QObject *parent)
.arg(encryption() == 0 ? tr("ON") : encryption() == 1 ? tr("FORCED") : tr("OFF")) .arg(encryption() == 0 ? tr("ON") : encryption() == 1 ? tr("FORCED") : tr("OFF"))
, Log::INFO); , Log::INFO);
m_nativeSession->set_ip_filter({});
if (isIPFilteringEnabled()) if (isIPFilteringEnabled())
enableIPFilter(); enableIPFilter();
// Add the banned IPs // Add the banned IPs
@ -901,7 +900,7 @@ void Session::adjustLimits()
adjustLimits(sessionSettings); adjustLimits(sessionSettings);
m_nativeSession->set_settings(sessionSettings); m_nativeSession->set_settings(sessionSettings);
#else #else
libt::settings_pack settingsPack; libt::settings_pack settingsPack = m_nativeSession->get_settings();
adjustLimits(settingsPack); adjustLimits(settingsPack);
m_nativeSession->apply_settings(settingsPack); m_nativeSession->apply_settings(settingsPack);
#endif #endif
@ -917,7 +916,7 @@ void Session::configure()
configure(sessionSettings); configure(sessionSettings);
m_nativeSession->set_settings(sessionSettings); m_nativeSession->set_settings(sessionSettings);
#else #else
libt::settings_pack settingsPack; libt::settings_pack settingsPack = m_nativeSession->get_settings();
configure(settingsPack); configure(settingsPack);
m_nativeSession->apply_settings(settingsPack); m_nativeSession->apply_settings(settingsPack);
#endif #endif
@ -942,7 +941,8 @@ void Session::processBannedIPs()
boost::system::error_code ec; boost::system::error_code ec;
libt::address addr = libt::address::from_string(ip.toLatin1().constData(), ec); libt::address addr = libt::address::from_string(ip.toLatin1().constData(), ec);
Q_ASSERT(!ec); Q_ASSERT(!ec);
filter.add_rule(addr, addr, libt::ip_filter::blocked); if (!ec)
filter.add_rule(addr, addr, libt::ip_filter::blocked);
} }
m_nativeSession->set_ip_filter(filter); m_nativeSession->set_ip_filter(filter);
@ -1206,7 +1206,7 @@ void Session::configure(libtorrent::session_settings &sessionSettings)
sessionSettings.announce_to_all_trackers = announceToAll; sessionSettings.announce_to_all_trackers = announceToAll;
sessionSettings.announce_to_all_tiers = announceToAll; sessionSettings.announce_to_all_tiers = announceToAll;
int cacheSize = diskCacheSize(); int cacheSize = diskCacheSize();
sessionSettings.cache_size = cacheSize ? cacheSize * 64 : -1; sessionSettings.cache_size = (cacheSize > 0) ? cacheSize * 64 : -1;
sessionSettings.cache_expiry = diskCacheTTL(); sessionSettings.cache_expiry = diskCacheTTL();
qDebug() << "Using a disk cache size of" << cacheSize << "MiB"; qDebug() << "Using a disk cache size of" << cacheSize << "MiB";
libt::session_settings::io_buffer_mode_t mode = useOSCache() ? libt::session_settings::enable_os_cache libt::session_settings::io_buffer_mode_t mode = useOSCache() ? libt::session_settings::enable_os_cache
@ -1254,10 +1254,9 @@ void Session::configure(libtorrent::session_settings &sessionSettings)
sessionSettings.enable_outgoing_utp = isUTPEnabled(); sessionSettings.enable_outgoing_utp = isUTPEnabled();
// uTP rate limiting // uTP rate limiting
sessionSettings.rate_limit_utp = isUTPRateLimited(); sessionSettings.rate_limit_utp = isUTPRateLimited();
if (sessionSettings.rate_limit_utp) sessionSettings.mixed_mode_algorithm = isUTPRateLimited()
sessionSettings.mixed_mode_algorithm = libt::session_settings::prefer_tcp; ? libt::session_settings::prefer_tcp
else : libt::session_settings::peer_proportional;
sessionSettings.mixed_mode_algorithm = libt::session_settings::peer_proportional;
sessionSettings.apply_ip_filter_to_trackers = isTrackerFilteringEnabled(); sessionSettings.apply_ip_filter_to_trackers = isTrackerFilteringEnabled();
@ -1402,6 +1401,7 @@ void Session::banIP(const QString &ip)
boost::system::error_code ec; boost::system::error_code ec;
libt::address addr = libt::address::from_string(ip.toLatin1().constData(), ec); libt::address addr = libt::address::from_string(ip.toLatin1().constData(), ec);
Q_ASSERT(!ec); Q_ASSERT(!ec);
if (ec) return;
filter.add_rule(addr, addr, libt::ip_filter::blocked); filter.add_rule(addr, addr, libt::ip_filter::blocked);
m_nativeSession->set_ip_filter(filter); m_nativeSession->set_ip_filter(filter);

4
src/base/net/portforwarder.cpp

@ -36,7 +36,7 @@
#include "base/logger.h" #include "base/logger.h"
#include "base/settingsstorage.h" #include "base/settingsstorage.h"
const QString KEY_ENABLED = QLatin1String("Network/PortForwardingEnabled"); static const QString KEY_ENABLED = QLatin1String("Network/PortForwardingEnabled");
namespace libt = libtorrent; namespace libt = libtorrent;
using namespace Net; using namespace Net;
@ -86,6 +86,8 @@ void PortForwarder::setEnabled(bool enabled)
start(); start();
else else
stop(); stop();
SettingsStorage::instance()->storeValue(KEY_ENABLED, enabled);
} }
} }

7
src/base/net/proxyconfigurationmanager.cpp

@ -34,7 +34,6 @@ const QString KEY_DISABLED = SETTINGS_KEY("Disabled");
const QString KEY_TYPE = SETTINGS_KEY("Type"); const QString KEY_TYPE = SETTINGS_KEY("Type");
const QString KEY_IP = SETTINGS_KEY("IP"); const QString KEY_IP = SETTINGS_KEY("IP");
const QString KEY_PORT = SETTINGS_KEY("Port"); const QString KEY_PORT = SETTINGS_KEY("Port");
const QString KEY_AUTHENTICATION = SETTINGS_KEY("Authentication");
const QString KEY_USERNAME = SETTINGS_KEY("Username"); const QString KEY_USERNAME = SETTINGS_KEY("Username");
const QString KEY_PASSWORD = SETTINGS_KEY("Password"); const QString KEY_PASSWORD = SETTINGS_KEY("Password");
@ -68,6 +67,7 @@ ProxyConfigurationManager::ProxyConfigurationManager(QObject *parent)
m_config.port = static_cast<ushort>(settings()->loadValue(KEY_PORT, 8080).toUInt()); m_config.port = static_cast<ushort>(settings()->loadValue(KEY_PORT, 8080).toUInt());
m_config.username = settings()->loadValue(KEY_USERNAME).toString(); m_config.username = settings()->loadValue(KEY_USERNAME).toString();
m_config.password = settings()->loadValue(KEY_PASSWORD).toString(); m_config.password = settings()->loadValue(KEY_PASSWORD).toString();
configureProxy();
} }
void ProxyConfigurationManager::initInstance() void ProxyConfigurationManager::initInstance()
@ -78,7 +78,10 @@ void ProxyConfigurationManager::initInstance()
void ProxyConfigurationManager::freeInstance() void ProxyConfigurationManager::freeInstance()
{ {
delete m_instance; if (m_instance) {
delete m_instance;
m_instance = 0;
}
} }
ProxyConfigurationManager *ProxyConfigurationManager::instance() ProxyConfigurationManager *ProxyConfigurationManager::instance()

2
src/base/settingsstorage.cpp

@ -155,7 +155,7 @@ namespace
{"BitTorrent/Session/MaxHalfOpenConnections", "Preferences/Connection/MaxHalfOpenConnec"}, {"BitTorrent/Session/MaxHalfOpenConnections", "Preferences/Connection/MaxHalfOpenConnec"},
{"BitTorrent/Session/uTPEnabled", "Preferences/Bittorrent/uTP"}, {"BitTorrent/Session/uTPEnabled", "Preferences/Bittorrent/uTP"},
{"BitTorrent/Session/uTPRateLimited", "Preferences/Bittorrent/uTP_rate_limited"}, {"BitTorrent/Session/uTPRateLimited", "Preferences/Bittorrent/uTP_rate_limited"},
{"BitTorrent/TrackerEnabled", "Preferences/TrackerEnabled"}, {"BitTorrent/TrackerEnabled", "Preferences/Advanced/trackerEnabled"},
{"Network/Proxy/Disabled", "Preferences/Connection/ProxyOnlyForTorrents"}, {"Network/Proxy/Disabled", "Preferences/Connection/ProxyOnlyForTorrents"},
{"Network/Proxy/Type", "Preferences/Connection/ProxyType"}, {"Network/Proxy/Type", "Preferences/Connection/ProxyType"},
{"Network/Proxy/Authentication", "Preferences/Connection/Proxy/Authentication"}, {"Network/Proxy/Authentication", "Preferences/Connection/Proxy/Authentication"},

2
src/gui/advancedsettings.cpp

@ -236,7 +236,7 @@ void AdvancedSettings::updateInterfaceAddressCombo()
void AdvancedSettings::loadAdvancedSettings() void AdvancedSettings::loadAdvancedSettings()
{ {
const Preferences* const pref = Preferences::instance(); const Preferences* const pref = Preferences::instance();
BitTorrent::Session *const session = BitTorrent::Session::instance(); const BitTorrent::Session *const session = BitTorrent::Session::instance();
// add section headers // add section headers
QFont boldFont; QFont boldFont;

Loading…
Cancel
Save