mirror of
https://github.com/arvidn/libtorrent.git
synced 2026-05-07 16:30:54 -04:00
disable deprecated boost.asio APIs
This commit is contained in:
@@ -766,6 +766,7 @@ local usage-requirements =
|
||||
<define>BOOST_ASIO_ENABLE_CANCELIO
|
||||
# make sure asio uses std::chrono
|
||||
<define>BOOST_ASIO_HAS_STD_CHRONO
|
||||
<define>BOOST_ASIO_NO_DEPRECATED
|
||||
<conditional>@linking
|
||||
# msvc optimizations
|
||||
<toolset>msvc,<variant>release:<linkflags>"/OPT:ICF=5"
|
||||
|
||||
@@ -57,7 +57,7 @@ struct tuple_to_endpoint
|
||||
extract<std::uint16_t> port(object(borrowed(PyTuple_GetItem(x, 1))));
|
||||
if (!port.check()) return nullptr;
|
||||
lt::error_code ec;
|
||||
lt::address::from_string(ip, ec);
|
||||
lt::make_address(ip, ec);
|
||||
if (ec) return nullptr;
|
||||
return x;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ struct tuple_to_endpoint
|
||||
->storage.bytes;
|
||||
|
||||
object o(borrowed(x));
|
||||
data->convertible = new (storage) T(lt::address::from_string(
|
||||
data->convertible = new (storage) T(lt::make_address(
|
||||
extract<std::string>(o[0])), extract<std::uint16_t>(o[1]));
|
||||
}
|
||||
};
|
||||
@@ -87,8 +87,7 @@ struct address_to_tuple
|
||||
{
|
||||
static PyObject* convert(Addr const& addr)
|
||||
{
|
||||
lt::error_code ec;
|
||||
return incref(bp::object(addr.to_string(ec)).ptr());
|
||||
return incref(bp::object(addr.to_string()).ptr());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -13,12 +13,12 @@ namespace
|
||||
{
|
||||
void add_rule(ip_filter& filter, std::string start, std::string end, int flags)
|
||||
{
|
||||
return filter.add_rule(address::from_string(start), address::from_string(end), flags);
|
||||
return filter.add_rule(make_address(start), make_address(end), flags);
|
||||
}
|
||||
|
||||
int access0(ip_filter& filter, std::string addr)
|
||||
{
|
||||
return filter.access(address::from_string(addr));
|
||||
return filter.access(make_address(addr));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -49,7 +49,7 @@ int main()
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::printf("Default gateway: %s\n", def_gw.to_string(ec).c_str());
|
||||
std::printf("Default gateway: %s\n", def_gw.to_string().c_str());
|
||||
|
||||
std::printf("=========== Routes ===========\n");
|
||||
auto const routes = enum_routes(ios, ec);
|
||||
@@ -64,9 +64,9 @@ int main()
|
||||
for (auto const& r : routes)
|
||||
{
|
||||
std::printf("%-18s%-18s%-35s%-7d%s\n"
|
||||
, r.destination.to_string(ec).c_str()
|
||||
, r.netmask.to_string(ec).c_str()
|
||||
, r.gateway.to_string(ec).c_str()
|
||||
, r.destination.to_string().c_str()
|
||||
, r.netmask.to_string().c_str()
|
||||
, r.gateway.to_string().c_str()
|
||||
, r.mtu
|
||||
, r.name);
|
||||
}
|
||||
@@ -86,13 +86,13 @@ int main()
|
||||
{
|
||||
address const iface_def_gw = get_default_gateway(ios, i.name, i.interface_address.is_v6(), ec);
|
||||
std::printf("%-34s%-45s%-20s%s%s%-20s%-34s%s %s\n"
|
||||
, i.interface_address.to_string(ec).c_str()
|
||||
, i.netmask.to_string(ec).c_str()
|
||||
, i.interface_address.to_string().c_str()
|
||||
, i.netmask.to_string().c_str()
|
||||
, i.name
|
||||
, (i.interface_address.is_multicast()?"multicast ":"")
|
||||
, (is_local(i.interface_address)?"local ":"")
|
||||
, (is_loopback(i.interface_address)?"loopback ":"")
|
||||
, iface_def_gw.to_string(ec).c_str()
|
||||
, iface_def_gw.to_string().c_str()
|
||||
, i.friendly_name, i.description);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,25 +93,24 @@ int main(int argc, char* argv[])
|
||||
natpmp_handler->add_mapping(portmap_protocol::udp, atoi(argv[2])
|
||||
, tcp::endpoint({}, aux::numeric_cast<std::uint16_t>(atoi(argv[2]))));
|
||||
|
||||
error_code ec;
|
||||
timer.expires_from_now(seconds(2), ec);
|
||||
timer.expires_after(seconds(2));
|
||||
timer.async_wait([&] (error_code const&) { ios.io_context::stop(); });
|
||||
std::cout << "mapping ports TCP: " << argv[1]
|
||||
<< " UDP: " << argv[2] << std::endl;
|
||||
|
||||
ios.restart();
|
||||
ios.run(ec);
|
||||
timer.expires_from_now(seconds(2), ec);
|
||||
ios.run();
|
||||
timer.expires_after(seconds(2));
|
||||
timer.async_wait([&] (error_code const&) { ios.io_context::stop(); });
|
||||
std::cout << "removing mapping " << tcp_map << std::endl;
|
||||
natpmp_handler->delete_mapping(tcp_map);
|
||||
|
||||
ios.restart();
|
||||
ios.run(ec);
|
||||
ios.run();
|
||||
std::cout << "removing mappings" << std::endl;
|
||||
natpmp_handler->close();
|
||||
|
||||
ios.restart();
|
||||
ios.run(ec);
|
||||
ios.run();
|
||||
std::cout << "closing" << std::endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user