forked from premiere/premiere-libtorrent
Merge pull request #442 from arvidn/listen-failed-alert-1.1
restore the endpoint field in listen_failed_alert (but deprecated)
This commit is contained in:
commit
07d7d72a58
|
@ -411,9 +411,10 @@ void bind_alert()
|
||||||
class_<listen_failed_alert, bases<alert>, noncopyable>(
|
class_<listen_failed_alert, bases<alert>, noncopyable>(
|
||||||
"listen_failed_alert", no_init)
|
"listen_failed_alert", no_init)
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
.def_readonly("interface", &listen_failed_alert::interface)
|
.def_readonly("endpoint", &listen_failed_alert::endpoint)
|
||||||
#endif
|
#endif
|
||||||
.def("listen_interface", &listen_failed_alert::listen_interface)
|
.def("listen_interface", &listen_failed_alert::listen_interface)
|
||||||
|
.def_readonly("port", &listen_failed_alert::port)
|
||||||
.def_readonly("error", &listen_failed_alert::error)
|
.def_readonly("error", &listen_failed_alert::error)
|
||||||
.def_readonly("operation", &listen_failed_alert::operation)
|
.def_readonly("operation", &listen_failed_alert::operation)
|
||||||
.def_readonly("sock_type", &listen_failed_alert::sock_type)
|
.def_readonly("sock_type", &listen_failed_alert::sock_type)
|
||||||
|
|
|
@ -1267,7 +1267,8 @@ namespace libtorrent
|
||||||
// internal
|
// internal
|
||||||
listen_failed_alert(
|
listen_failed_alert(
|
||||||
aux::stack_allocator& alloc
|
aux::stack_allocator& alloc
|
||||||
, std::string iface
|
, std::string const& iface
|
||||||
|
, int port
|
||||||
, int op
|
, int op
|
||||||
, error_code const& ec
|
, error_code const& ec
|
||||||
, socket_type_t t);
|
, socket_type_t t);
|
||||||
|
@ -1277,11 +1278,6 @@ namespace libtorrent
|
||||||
static const int static_category = alert::status_notification | alert::error_notification;
|
static const int static_category = alert::status_notification | alert::error_notification;
|
||||||
virtual std::string message() const TORRENT_OVERRIDE;
|
virtual std::string message() const TORRENT_OVERRIDE;
|
||||||
|
|
||||||
#if !defined(TORRENT_NO_DEPRECATE) && !defined(TORRENT_WINRT)
|
|
||||||
// the interface libtorrent attempted to listen on
|
|
||||||
std::string interface;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// the interface libtorrent attempted to listen on that failed.
|
// the interface libtorrent attempted to listen on that failed.
|
||||||
char const* listen_interface() const;
|
char const* listen_interface() const;
|
||||||
|
|
||||||
|
@ -1296,8 +1292,17 @@ namespace libtorrent
|
||||||
// the specific low level operation that failed. See op_t.
|
// the specific low level operation that failed. See op_t.
|
||||||
int operation;
|
int operation;
|
||||||
|
|
||||||
|
// the port attempted to be opened for listening
|
||||||
|
int port;
|
||||||
|
|
||||||
// the type of listen socket this alert refers to.
|
// the type of listen socket this alert refers to.
|
||||||
socket_type_t sock_type;
|
socket_type_t sock_type;
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
|
// the address and port libtorrent attempted to listen on
|
||||||
|
tcp::endpoint endpoint;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
aux::stack_allocator const& m_alloc;
|
aux::stack_allocator const& m_alloc;
|
||||||
int m_interface_idx;
|
int m_interface_idx;
|
||||||
|
|
|
@ -786,21 +786,31 @@ namespace libtorrent {
|
||||||
"HTTPS",
|
"HTTPS",
|
||||||
"SSL/uTP"
|
"SSL/uTP"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
|
tcp::endpoint parse_interface(std::string const& iface, int port)
|
||||||
|
{
|
||||||
|
// ignore errors
|
||||||
|
error_code ec;
|
||||||
|
return tcp::endpoint(address::from_string(iface, ec), port);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
listen_failed_alert::listen_failed_alert(
|
listen_failed_alert::listen_failed_alert(
|
||||||
aux::stack_allocator& alloc
|
aux::stack_allocator& alloc
|
||||||
, std::string iface
|
, std::string const& iface
|
||||||
|
, int prt
|
||||||
, int op
|
, int op
|
||||||
, error_code const& ec
|
, error_code const& ec
|
||||||
, socket_type_t t)
|
, socket_type_t t)
|
||||||
:
|
: error(ec)
|
||||||
#if !defined(TORRENT_NO_DEPRECATE) && !defined(TORRENT_WINRT)
|
|
||||||
interface(iface),
|
|
||||||
#endif
|
|
||||||
error(ec)
|
|
||||||
, operation(op)
|
, operation(op)
|
||||||
|
, port(prt)
|
||||||
, sock_type(t)
|
, sock_type(t)
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
|
, endpoint(parse_interface(iface, prt))
|
||||||
|
#endif
|
||||||
, m_alloc(alloc)
|
, m_alloc(alloc)
|
||||||
, m_interface_idx(alloc.copy_string(iface))
|
, m_interface_idx(alloc.copy_string(iface))
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -1698,7 +1698,8 @@ namespace aux {
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
if (m_alerts.should_post<listen_failed_alert>())
|
if (m_alerts.should_post<listen_failed_alert>())
|
||||||
m_alerts.emplace_alert<listen_failed_alert>(device, last_op, ec, sock_type);
|
m_alerts.emplace_alert<listen_failed_alert>(device, port, last_op
|
||||||
|
, ec, sock_type);
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
session_log("failed to open socket: %s: %s"
|
session_log("failed to open socket: %s: %s"
|
||||||
|
@ -1773,7 +1774,7 @@ namespace aux {
|
||||||
|
|
||||||
// not even that worked, give up
|
// not even that worked, give up
|
||||||
if (m_alerts.should_post<listen_failed_alert>())
|
if (m_alerts.should_post<listen_failed_alert>())
|
||||||
m_alerts.emplace_alert<listen_failed_alert>(device, last_op, ec, sock_type);
|
m_alerts.emplace_alert<listen_failed_alert>(device, port, last_op, ec, sock_type);
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
session_log("cannot to bind to interface [%s %d] \"%s : %s\": %s"
|
session_log("cannot to bind to interface [%s %d] \"%s : %s\": %s"
|
||||||
, device.c_str(), port, bind_ip.to_string(ec).c_str()
|
, device.c_str(), port, bind_ip.to_string(ec).c_str()
|
||||||
|
@ -1792,7 +1793,7 @@ namespace aux {
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
if (m_alerts.should_post<listen_failed_alert>())
|
if (m_alerts.should_post<listen_failed_alert>())
|
||||||
m_alerts.emplace_alert<listen_failed_alert>(device, last_op, ec, sock_type);
|
m_alerts.emplace_alert<listen_failed_alert>(device, port, last_op, ec, sock_type);
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
session_log("cannot listen on interface \"%s\": %s"
|
session_log("cannot listen on interface \"%s\": %s"
|
||||||
, device.c_str(), ec.message().c_str());
|
, device.c_str(), ec.message().c_str());
|
||||||
|
@ -1809,7 +1810,7 @@ namespace aux {
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
if (m_alerts.should_post<listen_failed_alert>())
|
if (m_alerts.should_post<listen_failed_alert>())
|
||||||
m_alerts.emplace_alert<listen_failed_alert>(device, last_op, ec, sock_type);
|
m_alerts.emplace_alert<listen_failed_alert>(device, port, last_op, ec, sock_type);
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
session_log("failed to get peer name \"%s\": %s"
|
session_log("failed to get peer name \"%s\": %s"
|
||||||
, device.c_str(), ec.message().c_str());
|
, device.c_str(), ec.message().c_str());
|
||||||
|
@ -2018,8 +2019,11 @@ retry:
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
if (m_alerts.should_post<listen_failed_alert>())
|
if (m_alerts.should_post<listen_failed_alert>())
|
||||||
m_alerts.emplace_alert<listen_failed_alert>(print_endpoint(m_listen_interface)
|
m_alerts.emplace_alert<listen_failed_alert>(
|
||||||
, listen_failed_alert::bind, ec, listen_failed_alert::udp);
|
m_listen_interface.address().to_string()
|
||||||
|
, m_listen_interface.port()
|
||||||
|
, listen_failed_alert::bind
|
||||||
|
, ec, listen_failed_alert::udp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2041,8 +2045,8 @@ retry:
|
||||||
if (m_alerts.should_post<listen_failed_alert>())
|
if (m_alerts.should_post<listen_failed_alert>())
|
||||||
{
|
{
|
||||||
error_code err;
|
error_code err;
|
||||||
m_alerts.emplace_alert<listen_failed_alert>(print_endpoint(ssl_bind_if)
|
m_alerts.emplace_alert<listen_failed_alert>(ssl_bind_if.address().to_string()
|
||||||
, listen_failed_alert::bind, ec, listen_failed_alert::utp_ssl);
|
, ssl_port, listen_failed_alert::bind, ec, listen_failed_alert::utp_ssl);
|
||||||
}
|
}
|
||||||
ec.clear();
|
ec.clear();
|
||||||
}
|
}
|
||||||
|
@ -2068,8 +2072,10 @@ retry:
|
||||||
if (m_alerts.should_post<listen_failed_alert>())
|
if (m_alerts.should_post<listen_failed_alert>())
|
||||||
{
|
{
|
||||||
error_code err;
|
error_code err;
|
||||||
m_alerts.emplace_alert<listen_failed_alert>(print_endpoint(m_listen_interface)
|
m_alerts.emplace_alert<listen_failed_alert>(m_listen_interface.address().to_string()
|
||||||
, listen_failed_alert::bind, ec, listen_failed_alert::udp);
|
, m_listen_interface.port()
|
||||||
|
, listen_failed_alert::bind
|
||||||
|
, ec, listen_failed_alert::udp);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2283,7 +2289,9 @@ retry:
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
if (m_alerts.should_post<listen_failed_alert>())
|
if (m_alerts.should_post<listen_failed_alert>())
|
||||||
m_alerts.emplace_alert<listen_failed_alert>("i2p", listen_failed_alert::accept
|
m_alerts.emplace_alert<listen_failed_alert>("i2p"
|
||||||
|
, m_listen_interface.port()
|
||||||
|
, listen_failed_alert::accept
|
||||||
, e, listen_failed_alert::i2p);
|
, e, listen_failed_alert::i2p);
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
session_log("cannot bind to port %d: %s"
|
session_log("cannot bind to port %d: %s"
|
||||||
|
@ -2422,7 +2430,8 @@ retry:
|
||||||
if (m_alerts.should_post<listen_failed_alert>())
|
if (m_alerts.should_post<listen_failed_alert>())
|
||||||
{
|
{
|
||||||
error_code err;
|
error_code err;
|
||||||
m_alerts.emplace_alert<listen_failed_alert>(print_endpoint(ep), listen_failed_alert::accept, e
|
m_alerts.emplace_alert<listen_failed_alert>(ep.address().to_string()
|
||||||
|
, ep.port(), listen_failed_alert::accept, e
|
||||||
, ssl ? listen_failed_alert::tcp_ssl : listen_failed_alert::tcp);
|
, ssl ? listen_failed_alert::tcp_ssl : listen_failed_alert::tcp);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -2757,7 +2766,8 @@ retry:
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
if (m_alerts.should_post<listen_failed_alert>())
|
if (m_alerts.should_post<listen_failed_alert>())
|
||||||
m_alerts.emplace_alert<listen_failed_alert>("socks5", listen_failed_alert::accept, e
|
m_alerts.emplace_alert<listen_failed_alert>("socks5"
|
||||||
|
, -1, listen_failed_alert::accept, e
|
||||||
, listen_failed_alert::socks5);
|
, listen_failed_alert::socks5);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue