improve error messages and error reporting of failing enum_routes()
This commit is contained in:
parent
8dbb7c4232
commit
cc792d8638
|
@ -172,6 +172,9 @@ namespace libtorrent {
|
||||||
|
|
||||||
// set socket option
|
// set socket option
|
||||||
sock_option,
|
sock_option,
|
||||||
|
|
||||||
|
// enumeration network routes
|
||||||
|
enum_route,
|
||||||
};
|
};
|
||||||
|
|
||||||
// maps an operation id (from peer_error_alert and peer_disconnected_alert)
|
// maps an operation id (from peer_error_alert and peer_disconnected_alert)
|
||||||
|
|
|
@ -897,6 +897,7 @@ namespace {
|
||||||
case o::symlink: return -1;
|
case o::symlink: return -1;
|
||||||
case o::handshake: return -1;
|
case o::handshake: return -1;
|
||||||
case o::sock_option: return -1;
|
case o::sock_option: return -1;
|
||||||
|
case o::enum_route: return -1;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1564,7 +1565,8 @@ namespace {
|
||||||
"hostname_lookup",
|
"hostname_lookup",
|
||||||
"symlink",
|
"symlink",
|
||||||
"handshake",
|
"handshake",
|
||||||
"sock_option"
|
"sock_option",
|
||||||
|
"enum_route"
|
||||||
};
|
};
|
||||||
|
|
||||||
int const idx = static_cast<int>(op);
|
int const idx = static_cast<int>(op);
|
||||||
|
|
|
@ -1359,8 +1359,12 @@ namespace aux {
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
if (should_log())
|
if (should_log())
|
||||||
{
|
{
|
||||||
session_log("attempting to open listen socket to: %s on device: %s ssl: %x"
|
session_log("attempting to open listen socket to: %s on device: %s %s%s%s%s"
|
||||||
, print_endpoint(bind_ep).c_str(), lep.device.c_str(), static_cast<int>(lep.ssl));
|
, print_endpoint(bind_ep).c_str(), lep.device.c_str()
|
||||||
|
, (lep.ssl == transport::ssl) ? "ssl " : ""
|
||||||
|
, (lep.flags & listen_socket_t::has_gateway) ? "has-gateway " : ""
|
||||||
|
, (lep.flags & listen_socket_t::accept_incoming) ? "accept-incoming " : "no-incoming "
|
||||||
|
, (lep.flags & listen_socket_t::was_expanded) ? "expanded-ip " : "");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1806,6 +1810,20 @@ namespace aux {
|
||||||
? listen_socket_flags_t{}
|
? listen_socket_flags_t{}
|
||||||
: listen_socket_t::accept_incoming;
|
: listen_socket_t::accept_incoming;
|
||||||
|
|
||||||
|
std::vector<ip_interface> const ifs = enum_net_interfaces(m_io_service, ec);
|
||||||
|
if (ec && m_alerts.should_post<listen_failed_alert>())
|
||||||
|
{
|
||||||
|
m_alerts.emplace_alert<listen_failed_alert>(""
|
||||||
|
, operation_t::enum_if, ec, socket_type_t::tcp);
|
||||||
|
}
|
||||||
|
auto const routes = enum_routes(m_io_service, ec);
|
||||||
|
if (ec && m_alerts.should_post<listen_failed_alert>())
|
||||||
|
{
|
||||||
|
m_alerts.emplace_alert<listen_failed_alert>(""
|
||||||
|
, operation_t::enum_route, ec, socket_type_t::tcp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// expand device names and populate eps
|
||||||
for (auto const& iface : m_listen_interfaces)
|
for (auto const& iface : m_listen_interfaces)
|
||||||
{
|
{
|
||||||
std::string const& device = iface.device;
|
std::string const& device = iface.device;
|
||||||
|
@ -1847,13 +1865,8 @@ namespace aux {
|
||||||
, listen_socket_flags_t{});
|
, listen_socket_flags_t{});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ip_interface> const ifs = enum_net_interfaces(m_io_service, ec);
|
expand_unspecified_address(ifs, eps);
|
||||||
if (!ec)
|
expand_devices(ifs, routes, eps);
|
||||||
{
|
|
||||||
expand_unspecified_address(ifs, eps);
|
|
||||||
auto const routes = enum_routes(m_io_service, ec);
|
|
||||||
if (!ec) expand_devices(ifs, routes, eps);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto remove_iter = partition_listen_sockets(eps, m_listen_sockets);
|
auto remove_iter = partition_listen_sockets(eps, m_listen_sockets);
|
||||||
|
|
||||||
|
|
|
@ -278,9 +278,9 @@ namespace libtorrent {
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this parses the string that's used as the listen_interfaces setting.
|
// this parses the string that's used as the dht_bootstrap setting.
|
||||||
// it is a comma-separated list of IP or device names with ports. For
|
// it is a comma-separated list of IP or hostnames with ports. For
|
||||||
// example: "eth0:6881,eth1:6881" or "127.0.0.1:6881"
|
// example: "router.bittorrent.com:6881,router.utorrent.com:6881" or "127.0.0.1:6881"
|
||||||
void parse_comma_separated_string_port(std::string const& in
|
void parse_comma_separated_string_port(std::string const& in
|
||||||
, std::vector<std::pair<std::string, int>>& out)
|
, std::vector<std::pair<std::string, int>>& out)
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,7 +46,7 @@ int main()
|
||||||
auto const routes = enum_routes(ios, ec);
|
auto const routes = enum_routes(ios, ec);
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
std::printf("%s\n", ec.message().c_str());
|
std::printf("enum_routes: %s\n", ec.message().c_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ int main()
|
||||||
auto const net = enum_net_interfaces(ios, ec);
|
auto const net = enum_net_interfaces(ios, ec);
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
std::printf("%s\n", ec.message().c_str());
|
std::printf("enum_ifs: %s\n", ec.message().c_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,8 +142,10 @@ TORRENT_TEST(dht_state)
|
||||||
|
|
||||||
TEST_EQUAL(params1.dht_state.nids.size(), 1);
|
TEST_EQUAL(params1.dht_state.nids.size(), 1);
|
||||||
|
|
||||||
// not a chance the nid will be the fake initial ones
|
if (params1.dht_state.nids.size() >= 1) {
|
||||||
TEST_CHECK(params1.dht_state.nids[0].second != s.nids[0].second);
|
// not a chance the nid will be the fake initial ones
|
||||||
|
TEST_CHECK(params1.dht_state.nids[0].second != s.nids[0].second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue