properly expose endpoints and addresses from alerts to python
This commit is contained in:
parent
dc9af94ee1
commit
2ce418f344
|
@ -15,24 +15,30 @@ std::string get_buffer(read_piece_alert const& rpa)
|
||||||
: std::string();
|
: std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct endpoint_to_python
|
tuple endpoint_to_tuple(tcp::endpoint const& ep)
|
||||||
{
|
{
|
||||||
static PyObject* convert(tcp::endpoint const& ep)
|
return make_tuple(ep.address().to_string(), ep.port());
|
||||||
{
|
}
|
||||||
return incref(make_tuple(ep.address().to_string(), ep.port()).ptr());
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyObject* convert(udp::endpoint const& ep)
|
tuple peer_alert_ip(peer_alert const& pa)
|
||||||
{
|
{
|
||||||
return incref(make_tuple(ep.address().to_string(), ep.port()).ptr());
|
return endpoint_to_tuple(pa.ip);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
std::string peer_blocked_alert_ip(peer_blocked_alert const& pa)
|
||||||
|
{
|
||||||
|
error_code ec;
|
||||||
|
return pa.ip.to_string(ec);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string dht_announce_alert_ip(dht_announce_alert const& pa)
|
||||||
|
{
|
||||||
|
error_code ec;
|
||||||
|
return pa.ip.to_string(ec);
|
||||||
|
}
|
||||||
|
|
||||||
void bind_alert()
|
void bind_alert()
|
||||||
{
|
{
|
||||||
to_python_converter<tcp::endpoint, endpoint_to_python>();
|
|
||||||
to_python_converter<udp::endpoint, endpoint_to_python>();
|
|
||||||
|
|
||||||
using boost::noncopyable;
|
using boost::noncopyable;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -93,7 +99,7 @@ void bind_alert()
|
||||||
|
|
||||||
class_<peer_alert, bases<torrent_alert>, noncopyable>(
|
class_<peer_alert, bases<torrent_alert>, noncopyable>(
|
||||||
"peer_alert", no_init)
|
"peer_alert", no_init)
|
||||||
.def_readonly("ip", &peer_alert::ip)
|
.add_property("ip", &peer_alert_ip)
|
||||||
.def_readonly("pid", &peer_alert::pid)
|
.def_readonly("pid", &peer_alert::pid)
|
||||||
;
|
;
|
||||||
class_<tracker_error_alert, bases<tracker_alert>, noncopyable>(
|
class_<tracker_error_alert, bases<tracker_alert>, noncopyable>(
|
||||||
|
@ -250,7 +256,7 @@ void bind_alert()
|
||||||
|
|
||||||
class_<peer_blocked_alert, bases<alert>, noncopyable>(
|
class_<peer_blocked_alert, bases<alert>, noncopyable>(
|
||||||
"peer_blocked_alert", no_init)
|
"peer_blocked_alert", no_init)
|
||||||
.def_readonly("ip", &peer_blocked_alert::ip)
|
.add_property("ip", &peer_blocked_alert_ip)
|
||||||
;
|
;
|
||||||
|
|
||||||
class_<scrape_reply_alert, bases<tracker_alert>, noncopyable>(
|
class_<scrape_reply_alert, bases<tracker_alert>, noncopyable>(
|
||||||
|
@ -312,7 +318,7 @@ void bind_alert()
|
||||||
|
|
||||||
class_<dht_announce_alert, bases<alert>, noncopyable>(
|
class_<dht_announce_alert, bases<alert>, noncopyable>(
|
||||||
"dht_announce_alert", no_init)
|
"dht_announce_alert", no_init)
|
||||||
.def_readonly("ip", &dht_announce_alert::ip)
|
.add_property("ip", &dht_announce_alert_ip)
|
||||||
.def_readonly("port", &dht_announce_alert::port)
|
.def_readonly("port", &dht_announce_alert::port)
|
||||||
.def_readonly("info_hash", &dht_announce_alert::info_hash)
|
.def_readonly("info_hash", &dht_announce_alert::info_hash)
|
||||||
;
|
;
|
||||||
|
|
Loading…
Reference in New Issue