mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-22 20:44:56 +00:00
exporting get/put dht data to upper levels. completely untested.
This commit is contained in:
parent
e46256a2f5
commit
36e2230b58
@ -1149,6 +1149,20 @@ namespace libtorrent
|
|||||||
sha1_hash info_hash;
|
sha1_hash info_hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TORRENT_EXPORT dht_reply_data_alert: alert
|
||||||
|
{
|
||||||
|
dht_reply_data_alert(entry::list_type const& lst)
|
||||||
|
: m_lst(lst)
|
||||||
|
{}
|
||||||
|
|
||||||
|
TORRENT_DEFINE_ALERT(dht_reply_data_alert);
|
||||||
|
|
||||||
|
const static int static_category = alert::dht_notification;
|
||||||
|
virtual std::string message() const;
|
||||||
|
|
||||||
|
entry::list_type const m_lst;
|
||||||
|
};
|
||||||
|
|
||||||
struct TORRENT_EXPORT stats_alert: torrent_alert
|
struct TORRENT_EXPORT stats_alert: torrent_alert
|
||||||
{
|
{
|
||||||
stats_alert(torrent_handle const& h, int interval
|
stats_alert(torrent_handle const& h, int interval
|
||||||
|
@ -307,6 +307,13 @@ namespace libtorrent
|
|||||||
// the DHT, to get the initial peers quickly
|
// the DHT, to get the initial peers quickly
|
||||||
void prioritize_dht(boost::weak_ptr<torrent> t);
|
void prioritize_dht(boost::weak_ptr<torrent> t);
|
||||||
|
|
||||||
|
void dht_putData(std::string const &username, std::string const &resource, bool multi,
|
||||||
|
entry const &value, std::string const &sig_user,
|
||||||
|
int timeutc, int seq);
|
||||||
|
|
||||||
|
void dht_getData(std::string const &username, std::string const &resource, bool multi);
|
||||||
|
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
entry dht_state() const;
|
entry dht_state() const;
|
||||||
#endif
|
#endif
|
||||||
|
@ -93,6 +93,13 @@ namespace libtorrent { namespace dht
|
|||||||
void announce(sha1_hash const& ih, int listen_port, bool seed
|
void announce(sha1_hash const& ih, int listen_port, bool seed
|
||||||
, boost::function<void(std::vector<tcp::endpoint> const&)> f);
|
, boost::function<void(std::vector<tcp::endpoint> const&)> f);
|
||||||
|
|
||||||
|
void putData(std::string const &username, std::string const &resource, bool multi,
|
||||||
|
entry const &value, std::string const &sig_user,
|
||||||
|
int timeutc, int seq);
|
||||||
|
|
||||||
|
void getData(std::string const &username, std::string const &resource, bool multi,
|
||||||
|
boost::function<void(entry::list_type const&)> f);
|
||||||
|
|
||||||
void dht_status(session_status& s);
|
void dht_status(session_status& s);
|
||||||
void network_stats(int& sent, int& received);
|
void network_stats(int& sent, int& received);
|
||||||
|
|
||||||
|
@ -437,6 +437,13 @@ namespace libtorrent
|
|||||||
void add_dht_node(std::pair<std::string, int> const& node);
|
void add_dht_node(std::pair<std::string, int> const& node);
|
||||||
void add_dht_router(std::pair<std::string, int> const& node);
|
void add_dht_router(std::pair<std::string, int> const& node);
|
||||||
|
|
||||||
|
// [MF] twister
|
||||||
|
void dht_putData(std::string const &username, std::string const &resource, bool multi,
|
||||||
|
entry const &value, std::string const &sig_user,
|
||||||
|
int timeutc, int seq);
|
||||||
|
|
||||||
|
void dht_getData(std::string const &username, std::string const &resource, bool multi);
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
// deprecated in 0.15
|
// deprecated in 0.15
|
||||||
// use save_state and load_state instead
|
// use save_state and load_state instead
|
||||||
|
@ -351,6 +351,13 @@ namespace libtorrent {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string dht_reply_data_alert::message() const
|
||||||
|
{
|
||||||
|
char msg[200];
|
||||||
|
snprintf(msg, sizeof(msg), "reply to dht getData received %d entries", m_lst.size());
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
stats_alert::stats_alert(torrent_handle const& h, int in
|
stats_alert::stats_alert(torrent_handle const& h, int in
|
||||||
, stat const& s)
|
, stat const& s)
|
||||||
: torrent_alert(h)
|
: torrent_alert(h)
|
||||||
|
@ -422,6 +422,19 @@ namespace libtorrent { namespace dht
|
|||||||
m_dht.announce(ih, listen_port, seed, f);
|
m_dht.announce(ih, listen_port, seed, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dht_tracker::putData(std::string const &username, std::string const &resource, bool multi,
|
||||||
|
entry const &value, std::string const &sig_user,
|
||||||
|
int timeutc, int seq)
|
||||||
|
{
|
||||||
|
m_dht.putData(username,resource, multi, value, sig_user, timeutc, seq);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dht_tracker::getData(std::string const &username, std::string const &resource, bool multi,
|
||||||
|
boost::function<void(entry::list_type const&)> f)
|
||||||
|
{
|
||||||
|
m_dht.getData(username, resource, multi, f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// translate bittorrent kademlia message into the generice kademlia message
|
// translate bittorrent kademlia message into the generice kademlia message
|
||||||
// used by the library
|
// used by the library
|
||||||
|
@ -329,6 +329,12 @@ namespace libtorrent
|
|||||||
#define TORRENT_ASYNC_CALL2(x, a1, a2) \
|
#define TORRENT_ASYNC_CALL2(x, a1, a2) \
|
||||||
m_impl->m_io_service.dispatch(boost::bind(&session_impl:: x, m_impl.get(), a1, a2))
|
m_impl->m_io_service.dispatch(boost::bind(&session_impl:: x, m_impl.get(), a1, a2))
|
||||||
|
|
||||||
|
#define TORRENT_ASYNC_CALL3(x, a1, a2, a3) \
|
||||||
|
m_impl->m_io_service.dispatch(boost::bind(&session_impl:: x, m_impl.get(), a1, a2, a3))
|
||||||
|
|
||||||
|
#define TORRENT_ASYNC_CALL7(x, a1, a2, a3, a4, a5, a6, a7) \
|
||||||
|
m_impl->m_io_service.dispatch(boost::bind(&session_impl:: x, m_impl.get(), a1, a2, a3, a4, a5, a6, a7))
|
||||||
|
|
||||||
#define TORRENT_WAIT \
|
#define TORRENT_WAIT \
|
||||||
mutex::scoped_lock l(m_impl->mut); \
|
mutex::scoped_lock l(m_impl->mut); \
|
||||||
while (!done) { m_impl->cond.wait(l); };
|
while (!done) { m_impl->cond.wait(l); };
|
||||||
@ -845,6 +851,22 @@ namespace libtorrent
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void session::dht_putData(std::string const &username, std::string const &resource, bool multi,
|
||||||
|
entry const &value, std::string const &sig_user,
|
||||||
|
int timeutc, int seq)
|
||||||
|
{
|
||||||
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
|
TORRENT_ASYNC_CALL7(dht_putData, username, resource, multi, value, sig_user, timeutc, seq);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void session::dht_getData(std::string const &username, std::string const &resource, bool multi)
|
||||||
|
{
|
||||||
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
|
TORRENT_ASYNC_CALL3(dht_getData, username, resource, multi);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bool session::is_dht_running() const
|
bool session::is_dht_running() const
|
||||||
{
|
{
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
|
@ -5733,6 +5733,26 @@ retry:
|
|||||||
boost::bind(&session_impl::on_dht_router_name_lookup, this, _1, _2));
|
boost::bind(&session_impl::on_dht_router_name_lookup, this, _1, _2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void session_impl::dht_putData(std::string const &username, std::string const &resource, bool multi,
|
||||||
|
entry const &value, std::string const &sig_user,
|
||||||
|
int timeutc, int seq)
|
||||||
|
{
|
||||||
|
if (m_dht) m_dht->putData(username, resource, multi, value, sig_user, timeutc, seq);
|
||||||
|
}
|
||||||
|
|
||||||
|
void post_dht_getData(aux::session_impl *si, entry::list_type const&lst)
|
||||||
|
{
|
||||||
|
if( si->m_alerts.should_post<dht_reply_data_alert>() ) {
|
||||||
|
si->m_alerts.post_alert(dht_reply_data_alert(lst));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void session_impl::dht_getData(std::string const &username, std::string const &resource, bool multi)
|
||||||
|
{
|
||||||
|
if (m_dht) m_dht->getData(username, resource, multi, boost::bind( post_dht_getData, this, _1));
|
||||||
|
}
|
||||||
|
|
||||||
void session_impl::on_dht_router_name_lookup(error_code const& e
|
void session_impl::on_dht_router_name_lookup(error_code const& e
|
||||||
, tcp::resolver::iterator host)
|
, tcp::resolver::iterator host)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user