Don't use deprecated settings_pack members

This commit is contained in:
Vladimir Golovnev (Glassez) 2017-05-01 19:19:34 +03:00
parent bdca55f15c
commit 13b04f8d2d
2 changed files with 59 additions and 6 deletions

View file

@ -371,6 +371,8 @@ Session::Session(QObject *parent)
{ {
QMetaObject::invokeMethod(this, "readAlerts", Qt::QueuedConnection); QMetaObject::invokeMethod(this, "readAlerts", Qt::QueuedConnection);
}); });
configurePeerClasses();
#endif #endif
// Enabling plugins // Enabling plugins
@ -889,6 +891,7 @@ void Session::configure()
libt::settings_pack settingsPack = m_nativeSession->get_settings(); libt::settings_pack settingsPack = m_nativeSession->get_settings();
configure(settingsPack); configure(settingsPack);
m_nativeSession->apply_settings(settingsPack); m_nativeSession->apply_settings(settingsPack);
configurePeerClasses();
#endif #endif
if (m_IPFilteringChanged) { if (m_IPFilteringChanged) {
@ -1136,16 +1139,12 @@ void Session::configure(libtorrent::settings_pack &settingsPack)
settingsPack.set_int(libt::settings_pack::outgoing_port, outgoingPortsMin()); settingsPack.set_int(libt::settings_pack::outgoing_port, outgoingPortsMin());
settingsPack.set_int(libt::settings_pack::num_outgoing_ports, outgoingPortsMax() - outgoingPortsMin() + 1); settingsPack.set_int(libt::settings_pack::num_outgoing_ports, outgoingPortsMax() - outgoingPortsMin() + 1);
// Ignore limits on LAN
settingsPack.set_bool(libt::settings_pack::ignore_limits_on_local_network, ignoreLimitsOnLAN());
// Include overhead in transfer limits // Include overhead in transfer limits
settingsPack.set_bool(libt::settings_pack::rate_limit_ip_overhead, includeOverheadInLimits()); settingsPack.set_bool(libt::settings_pack::rate_limit_ip_overhead, includeOverheadInLimits());
// IP address to announce to trackers // IP address to announce to trackers
settingsPack.set_str(libt::settings_pack::announce_ip, announceIP().toStdString()); settingsPack.set_str(libt::settings_pack::announce_ip, announceIP().toStdString());
// Super seeding // Super seeding
settingsPack.set_bool(libt::settings_pack::strict_super_seeding, isSuperSeedingEnabled()); settingsPack.set_bool(libt::settings_pack::strict_super_seeding, isSuperSeedingEnabled());
// * Max Half-open connections
settingsPack.set_int(libt::settings_pack::half_open_limit, maxHalfOpenConnections());
// * Max connections limit // * Max connections limit
settingsPack.set_int(libt::settings_pack::connections_limit, maxConnections()); settingsPack.set_int(libt::settings_pack::connections_limit, maxConnections());
// * Global max upload slots // * Global max upload slots
@ -1153,8 +1152,6 @@ void Session::configure(libtorrent::settings_pack &settingsPack)
// uTP // uTP
settingsPack.set_bool(libt::settings_pack::enable_incoming_utp, isUTPEnabled()); settingsPack.set_bool(libt::settings_pack::enable_incoming_utp, isUTPEnabled());
settingsPack.set_bool(libt::settings_pack::enable_outgoing_utp, isUTPEnabled()); settingsPack.set_bool(libt::settings_pack::enable_outgoing_utp, isUTPEnabled());
// uTP rate limiting
settingsPack.set_bool(libt::settings_pack::rate_limit_utp, isUTPRateLimited());
settingsPack.set_int(libt::settings_pack::mixed_mode_algorithm, isUTPRateLimited() settingsPack.set_int(libt::settings_pack::mixed_mode_algorithm, isUTPRateLimited()
? libt::settings_pack::prefer_tcp ? libt::settings_pack::prefer_tcp
: libt::settings_pack::peer_proportional); : libt::settings_pack::peer_proportional);
@ -1167,6 +1164,61 @@ void Session::configure(libtorrent::settings_pack &settingsPack)
settingsPack.set_bool(libt::settings_pack::enable_lsd, isLSDEnabled()); settingsPack.set_bool(libt::settings_pack::enable_lsd, isLSDEnabled());
} }
void Session::configurePeerClasses()
{
libt::ip_filter f;
f.add_rule(libt::address_v4::from_string("0.0.0.0")
, libt::address_v4::from_string("255.255.255.255")
, 1 << libt::session::global_peer_class_id);
#if TORRENT_USE_IPV6
f.add_rule(libt::address_v6::from_string("::0")
, libt::address_v6::from_string("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
, 1 << libt::session::global_peer_class_id);
#endif
if (ignoreLimitsOnLAN()) {
f.add_rule(libt::address_v4::from_string("10.0.0.0")
, libt::address_v4::from_string("10.255.255.255")
, 1 << libt::session::local_peer_class_id);
f.add_rule(libt::address_v4::from_string("172.16.0.0")
, libt::address_v4::from_string("172.16.255.255")
, 1 << libt::session::local_peer_class_id);
f.add_rule(libt::address_v4::from_string("192.168.0.0")
, libt::address_v4::from_string("192.168.255.255")
, 1 << libt::session::local_peer_class_id);
f.add_rule(libt::address_v4::from_string("169.254.0.0")
, libt::address_v4::from_string("169.254.255.255")
, 1 << libt::session::local_peer_class_id);
f.add_rule(libt::address_v4::from_string("127.0.0.0")
, libt::address_v4::from_string("127.255.255.255")
, 1 << libt::session::local_peer_class_id);
#if TORRENT_USE_IPV6
f.add_rule(libt::address_v6::from_string("fe80::")
, libt::address_v6::from_string("febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
, 1 << libt::session::local_peer_class_id);
f.add_rule(libt::address_v6::from_string("::1")
, libt::address_v6::from_string("::1")
, 1 << libt::session::local_peer_class_id);
#endif
}
m_nativeSession->set_peer_class_filter(f);
libt::peer_class_type_filter peerClassTypeFilter;
peerClassTypeFilter.add(libt::peer_class_type_filter::tcp_socket, libt::session::tcp_peer_class_id);
peerClassTypeFilter.add(libt::peer_class_type_filter::ssl_tcp_socket, libt::session::tcp_peer_class_id);
peerClassTypeFilter.add(libt::peer_class_type_filter::i2p_socket, libt::session::tcp_peer_class_id);
if (isUTPRateLimited()) {
peerClassTypeFilter.add(libt::peer_class_type_filter::utp_socket
, libt::session::local_peer_class_id);
peerClassTypeFilter.add(libt::peer_class_type_filter::utp_socket
, libt::session::global_peer_class_id);
peerClassTypeFilter.add(libt::peer_class_type_filter::ssl_utp_socket
, libt::session::local_peer_class_id);
peerClassTypeFilter.add(libt::peer_class_type_filter::ssl_utp_socket
, libt::session::global_peer_class_id);
}
m_nativeSession->set_peer_class_type_filter(peerClassTypeFilter);
}
#else #else
void Session::adjustLimits(libt::session_settings &sessionSettings) void Session::adjustLimits(libt::session_settings &sessionSettings)

View file

@ -483,6 +483,7 @@ namespace BitTorrent
void adjustLimits(libtorrent::session_settings &sessionSettings); void adjustLimits(libtorrent::session_settings &sessionSettings);
#else #else
void configure(libtorrent::settings_pack &settingsPack); void configure(libtorrent::settings_pack &settingsPack);
void configurePeerClasses();
void adjustLimits(libtorrent::settings_pack &settingsPack); void adjustLimits(libtorrent::settings_pack &settingsPack);
void initMetrics(); void initMetrics();
#endif #endif