mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 13:04:23 +00:00
Migrate away from deprecated address::from_string()
This commit is contained in:
parent
2a2ae2a566
commit
25a47dadeb
@ -96,7 +96,7 @@ namespace
|
|||||||
if (parser.tryParse(data))
|
if (parser.tryParse(data))
|
||||||
address = lt::address_v4(parser.parsed());
|
address = lt::address_v4(parser.parsed());
|
||||||
else
|
else
|
||||||
address = lt::address_v6::from_string(data, ec);
|
address = lt::make_address(data, ec);
|
||||||
|
|
||||||
return !ec;
|
return !ec;
|
||||||
}
|
}
|
||||||
|
@ -1065,7 +1065,7 @@ void Session::processBannedIPs(lt::ip_filter &filter)
|
|||||||
// First, import current filter
|
// First, import current filter
|
||||||
for (const QString &ip : asConst(m_bannedIPs.value())) {
|
for (const QString &ip : asConst(m_bannedIPs.value())) {
|
||||||
lt::error_code ec;
|
lt::error_code ec;
|
||||||
const lt::address addr = lt::address::from_string(ip.toLatin1().constData(), ec);
|
const lt::address addr = lt::make_address(ip.toLatin1().constData(), ec);
|
||||||
Q_ASSERT(!ec);
|
Q_ASSERT(!ec);
|
||||||
if (!ec)
|
if (!ec)
|
||||||
filter.add_rule(addr, addr, lt::ip_filter::blocked);
|
filter.add_rule(addr, addr, lt::ip_filter::blocked);
|
||||||
@ -1442,7 +1442,7 @@ void Session::configureNetworkInterfaces(lt::settings_pack &settingsPack)
|
|||||||
void Session::configurePeerClasses()
|
void Session::configurePeerClasses()
|
||||||
{
|
{
|
||||||
lt::ip_filter f;
|
lt::ip_filter f;
|
||||||
// address_v4::from_string("255.255.255.255") crashes on some people's systems
|
// lt::make_address("255.255.255.255") crashes on some people's systems
|
||||||
// so instead we use address_v4::broadcast()
|
// so instead we use address_v4::broadcast()
|
||||||
// Proactively do the same for 0.0.0.0 and address_v4::any()
|
// Proactively do the same for 0.0.0.0 and address_v4::any()
|
||||||
f.add_rule(lt::address_v4::any()
|
f.add_rule(lt::address_v4::any()
|
||||||
@ -1454,29 +1454,29 @@ void Session::configurePeerClasses()
|
|||||||
// Affects Windows XP
|
// Affects Windows XP
|
||||||
try {
|
try {
|
||||||
f.add_rule(lt::address_v6::any()
|
f.add_rule(lt::address_v6::any()
|
||||||
, lt::address_v6::from_string("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
|
, lt::make_address("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
|
||||||
, 1 << static_cast<LTUnderlyingType<lt::peer_class_t>>(lt::session::global_peer_class_id));
|
, 1 << static_cast<LTUnderlyingType<lt::peer_class_t>>(lt::session::global_peer_class_id));
|
||||||
}
|
}
|
||||||
catch (const std::exception &) {}
|
catch (const std::exception &) {}
|
||||||
|
|
||||||
if (ignoreLimitsOnLAN()) {
|
if (ignoreLimitsOnLAN()) {
|
||||||
// local networks
|
// local networks
|
||||||
f.add_rule(lt::address_v4::from_string("10.0.0.0")
|
f.add_rule(lt::make_address("10.0.0.0")
|
||||||
, lt::address_v4::from_string("10.255.255.255")
|
, lt::make_address("10.255.255.255")
|
||||||
, 1 << static_cast<LTUnderlyingType<lt::peer_class_t>>(lt::session::local_peer_class_id));
|
, 1 << static_cast<LTUnderlyingType<lt::peer_class_t>>(lt::session::local_peer_class_id));
|
||||||
f.add_rule(lt::address_v4::from_string("172.16.0.0")
|
f.add_rule(lt::make_address("172.16.0.0")
|
||||||
, lt::address_v4::from_string("172.31.255.255")
|
, lt::make_address("172.31.255.255")
|
||||||
, 1 << static_cast<LTUnderlyingType<lt::peer_class_t>>(lt::session::local_peer_class_id));
|
, 1 << static_cast<LTUnderlyingType<lt::peer_class_t>>(lt::session::local_peer_class_id));
|
||||||
f.add_rule(lt::address_v4::from_string("192.168.0.0")
|
f.add_rule(lt::make_address("192.168.0.0")
|
||||||
, lt::address_v4::from_string("192.168.255.255")
|
, lt::make_address("192.168.255.255")
|
||||||
, 1 << static_cast<LTUnderlyingType<lt::peer_class_t>>(lt::session::local_peer_class_id));
|
, 1 << static_cast<LTUnderlyingType<lt::peer_class_t>>(lt::session::local_peer_class_id));
|
||||||
// link local
|
// link local
|
||||||
f.add_rule(lt::address_v4::from_string("169.254.0.0")
|
f.add_rule(lt::make_address("169.254.0.0")
|
||||||
, lt::address_v4::from_string("169.254.255.255")
|
, lt::make_address("169.254.255.255")
|
||||||
, 1 << static_cast<LTUnderlyingType<lt::peer_class_t>>(lt::session::local_peer_class_id));
|
, 1 << static_cast<LTUnderlyingType<lt::peer_class_t>>(lt::session::local_peer_class_id));
|
||||||
// loopback
|
// loopback
|
||||||
f.add_rule(lt::address_v4::from_string("127.0.0.0")
|
f.add_rule(lt::make_address("127.0.0.0")
|
||||||
, lt::address_v4::from_string("127.255.255.255")
|
, lt::make_address("127.255.255.255")
|
||||||
, 1 << static_cast<LTUnderlyingType<lt::peer_class_t>>(lt::session::local_peer_class_id));
|
, 1 << static_cast<LTUnderlyingType<lt::peer_class_t>>(lt::session::local_peer_class_id));
|
||||||
|
|
||||||
// IPv6 may not be available on OS and the parsing
|
// IPv6 may not be available on OS and the parsing
|
||||||
@ -1484,12 +1484,12 @@ void Session::configurePeerClasses()
|
|||||||
// Affects Windows XP
|
// Affects Windows XP
|
||||||
try {
|
try {
|
||||||
// link local
|
// link local
|
||||||
f.add_rule(lt::address_v6::from_string("fe80::")
|
f.add_rule(lt::make_address("fe80::")
|
||||||
, lt::address_v6::from_string("febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
|
, lt::make_address("febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
|
||||||
, 1 << static_cast<LTUnderlyingType<lt::peer_class_t>>(lt::session::local_peer_class_id));
|
, 1 << static_cast<LTUnderlyingType<lt::peer_class_t>>(lt::session::local_peer_class_id));
|
||||||
// unique local addresses
|
// unique local addresses
|
||||||
f.add_rule(lt::address_v6::from_string("fc00::")
|
f.add_rule(lt::make_address("fc00::")
|
||||||
, lt::address_v6::from_string("fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
|
, lt::make_address("fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
|
||||||
, 1 << static_cast<LTUnderlyingType<lt::peer_class_t>>(lt::session::local_peer_class_id));
|
, 1 << static_cast<LTUnderlyingType<lt::peer_class_t>>(lt::session::local_peer_class_id));
|
||||||
// loopback
|
// loopback
|
||||||
f.add_rule(lt::address_v6::loopback()
|
f.add_rule(lt::address_v6::loopback()
|
||||||
@ -1675,7 +1675,7 @@ void Session::banIP(const QString &ip)
|
|||||||
if (!bannedIPs.contains(ip)) {
|
if (!bannedIPs.contains(ip)) {
|
||||||
lt::ip_filter filter = m_nativeSession->get_ip_filter();
|
lt::ip_filter filter = m_nativeSession->get_ip_filter();
|
||||||
lt::error_code ec;
|
lt::error_code ec;
|
||||||
const lt::address addr = lt::address::from_string(ip.toLatin1().constData(), ec);
|
const lt::address addr = lt::make_address(ip.toLatin1().constData(), ec);
|
||||||
Q_ASSERT(!ec);
|
Q_ASSERT(!ec);
|
||||||
if (ec) return;
|
if (ec) return;
|
||||||
filter.add_rule(addr, addr, lt::ip_filter::blocked);
|
filter.add_rule(addr, addr, lt::ip_filter::blocked);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user