update to latest trunk fixes from kripken
This commit is contained in:
parent
b92a704e43
commit
e1a3f460f5
|
@ -1,32 +1,17 @@
|
||||||
#include "libtorrent/io.hpp"
|
#ifndef TORRENT_SOCKS5_STREAM_HPP_INCLUDED
|
||||||
#include "libtorrent/socket.hpp"
|
#define TORRENT_SOCKS5_STREAM_HPP_INCLUDED
|
||||||
#include <boost/bind.hpp>
|
#include "libtorrent/proxy_base.hpp"
|
||||||
#include <boost/lexical_cast.hpp>
|
|
||||||
#include <boost/function.hpp>
|
|
||||||
#include <asio/read.hpp>
|
|
||||||
#include <asio/write.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
namespace libtorrent {
|
namespace libtorrent {
|
||||||
|
|
||||||
class socks5_stream : boost::noncopyable
|
class socks5_stream : public proxy_base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef stream_socket::lowest_layer_type lowest_layer_type;
|
|
||||||
typedef stream_socket::endpoint_type endpoint_type;
|
|
||||||
typedef stream_socket::protocol_type protocol_type;
|
|
||||||
|
|
||||||
explicit socks5_stream(asio::io_service& io_service)
|
explicit socks5_stream(asio::io_service& io_service)
|
||||||
: m_sock(io_service)
|
: proxy_base(io_service)
|
||||||
, m_resolver(io_service)
|
|
||||||
{}
|
|
||||||
|
|
||||||
void set_proxy(std::string hostname, int port)
|
{}
|
||||||
{
|
|
||||||
m_hostname = hostname;
|
|
||||||
m_port = port;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_username(std::string const& user
|
void set_username(std::string const& user
|
||||||
, std::string const& password)
|
, std::string const& password)
|
||||||
|
@ -35,107 +20,6 @@ public:
|
||||||
m_password = password;
|
m_password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Mutable_Buffers, class Handler>
|
|
||||||
void async_read_some(Mutable_Buffers const& buffers, Handler const& handler)
|
|
||||||
{
|
|
||||||
m_sock.async_read_some(buffers, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Mutable_Buffers>
|
|
||||||
std::size_t read_some(Mutable_Buffers const& buffers, asio::error_code& ec)
|
|
||||||
{
|
|
||||||
return m_sock.read_some(buffers, ec);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Mutable_Buffers>
|
|
||||||
std::size_t read_some(Mutable_Buffers const& buffers)
|
|
||||||
{
|
|
||||||
return m_sock.read_some(buffers);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class IO_Control_Command>
|
|
||||||
void io_control(IO_Control_Command& ioc)
|
|
||||||
{
|
|
||||||
m_sock.io_control(ioc);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class IO_Control_Command>
|
|
||||||
void io_control(IO_Control_Command& ioc, asio::error_code& ec)
|
|
||||||
{
|
|
||||||
m_sock.io_control(ioc, ec);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Const_Buffers, class Handler>
|
|
||||||
void async_write_some(Const_Buffers const& buffers, Handler const& handler)
|
|
||||||
{
|
|
||||||
m_sock.async_write_some(buffers, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
void bind(endpoint_type const& endpoint)
|
|
||||||
{
|
|
||||||
m_sock.bind(endpoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Error_Handler>
|
|
||||||
void bind(endpoint_type const& endpoint, Error_Handler const& error_handler)
|
|
||||||
{
|
|
||||||
m_sock.bind(endpoint, error_handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
void open(protocol_type const& p)
|
|
||||||
{
|
|
||||||
m_sock.open(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Error_Handler>
|
|
||||||
void open(protocol_type const& p, Error_Handler const& error_handler)
|
|
||||||
{
|
|
||||||
m_sock.open(p, error_handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
void close()
|
|
||||||
{
|
|
||||||
m_remote_endpoint = endpoint_type();
|
|
||||||
m_sock.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Error_Handler>
|
|
||||||
void close(Error_Handler const& error_handler)
|
|
||||||
{
|
|
||||||
m_sock.close(error_handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
endpoint_type remote_endpoint()
|
|
||||||
{
|
|
||||||
return m_remote_endpoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Error_Handler>
|
|
||||||
endpoint_type remote_endpoint(Error_Handler const& error_handler)
|
|
||||||
{
|
|
||||||
return m_remote_endpoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
endpoint_type local_endpoint()
|
|
||||||
{
|
|
||||||
return m_sock.local_endpoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Error_Handler>
|
|
||||||
endpoint_type local_endpoint(Error_Handler const& error_handler)
|
|
||||||
{
|
|
||||||
return m_sock.local_endpoint(error_handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
asio::io_service& io_service()
|
|
||||||
{
|
|
||||||
return m_sock.io_service();
|
|
||||||
}
|
|
||||||
|
|
||||||
lowest_layer_type& lowest_layer()
|
|
||||||
{
|
|
||||||
return m_sock.lowest_layer();
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef boost::function<void(asio::error_code const&)> handler_type;
|
typedef boost::function<void(asio::error_code const&)> handler_type;
|
||||||
|
|
||||||
|
@ -176,20 +60,14 @@ private:
|
||||||
void connect2(asio::error_code const& e, boost::shared_ptr<handler_type> h);
|
void connect2(asio::error_code const& e, boost::shared_ptr<handler_type> h);
|
||||||
void connect3(asio::error_code const& e, boost::shared_ptr<handler_type> h);
|
void connect3(asio::error_code const& e, boost::shared_ptr<handler_type> h);
|
||||||
|
|
||||||
stream_socket m_sock;
|
|
||||||
// the socks5 proxy
|
|
||||||
std::string m_hostname;
|
|
||||||
int m_port;
|
|
||||||
// send and receive buffer
|
// send and receive buffer
|
||||||
std::vector<char> m_buffer;
|
std::vector<char> m_buffer;
|
||||||
// proxy authentication
|
// proxy authentication
|
||||||
std::string m_user;
|
std::string m_user;
|
||||||
std::string m_password;
|
std::string m_password;
|
||||||
|
|
||||||
endpoint_type m_remote_endpoint;
|
|
||||||
|
|
||||||
tcp::resolver m_resolver;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -1819,7 +1819,8 @@ namespace libtorrent
|
||||||
bool torrent::want_more_peers() const
|
bool torrent::want_more_peers() const
|
||||||
{
|
{
|
||||||
return int(m_connections.size()) < m_connections_quota.given
|
return int(m_connections.size()) < m_connections_quota.given
|
||||||
&& m_ses.m_half_open.free_slots();
|
&& m_ses.m_half_open.free_slots()
|
||||||
|
&& !m_paused;;
|
||||||
}
|
}
|
||||||
|
|
||||||
void torrent::disconnect_all()
|
void torrent::disconnect_all()
|
||||||
|
|
|
@ -611,15 +611,6 @@ static PyObject *torrent_get_torrent_state(PyObject *self, PyObject *args)
|
||||||
std::vector<peer_info> peers;
|
std::vector<peer_info> peers;
|
||||||
t.handle.get_peer_info(peers);
|
t.handle.get_peer_info(peers);
|
||||||
|
|
||||||
long total_seeds = 0;
|
|
||||||
long total_peers = 0;
|
|
||||||
|
|
||||||
for (unsigned long i = 0; i < peers.size(); i++)
|
|
||||||
if (peers[i].seed)
|
|
||||||
total_seeds++;
|
|
||||||
else
|
|
||||||
total_peers++;
|
|
||||||
|
|
||||||
return Py_BuildValue("{s:s,s:l,s:l,s:l,s:l,s:f,s:f,s:d,s:f,s:l,s:l,s:s,s:s,s:f,s:d,s:l,s:l,s:l,s:d,s:l,s:l,s:l,s:l,s:l,s:l,s:d,s:d,s:l,s:l}",
|
return Py_BuildValue("{s:s,s:l,s:l,s:l,s:l,s:f,s:f,s:d,s:f,s:l,s:l,s:s,s:s,s:f,s:d,s:l,s:l,s:l,s:d,s:l,s:l,s:l,s:l,s:l,s:l,s:d,s:d,s:l,s:l}",
|
||||||
"name", t.handle.get_torrent_info().name().c_str(),
|
"name", t.handle.get_torrent_info().name().c_str(),
|
||||||
"num_files", t.handle.get_torrent_info().num_files(),
|
"num_files", t.handle.get_torrent_info().num_files(),
|
||||||
|
@ -642,8 +633,8 @@ static PyObject *torrent_get_torrent_state(PyObject *self, PyObject *args)
|
||||||
"total_size", double(i.total_size()),
|
"total_size", double(i.total_size()),
|
||||||
"piece_length", long(i.piece_length()),
|
"piece_length", long(i.piece_length()),
|
||||||
"num_pieces", long(i.num_pieces()),
|
"num_pieces", long(i.num_pieces()),
|
||||||
"total_seeds", total_seeds,
|
"total_seeds", s.num_complete != -1 ? s.num_complete: s.num_seeds,
|
||||||
"total_peers", total_peers,
|
"total_peers", s.num_incomplete != -1 ? s.num_incomplete : s.num_peers,
|
||||||
"is_paused", long(t.handle.is_paused()),
|
"is_paused", long(t.handle.is_paused()),
|
||||||
"is_seed", long(t.handle.is_seed()),
|
"is_seed", long(t.handle.is_seed()),
|
||||||
"total_wanted", double(s.total_wanted),
|
"total_wanted", double(s.total_wanted),
|
||||||
|
@ -779,7 +770,7 @@ static PyObject *torrent_pop_event(PyObject *self, PyObject *args)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (handle_exists(handle))
|
if (handle_exists(handle))
|
||||||
return Py_BuildValue("{s:i,s:i,s:s,s:s}",
|
return Py_BuildValue("{s:i,s:i,s:s,s:i,s:s}",
|
||||||
"event_type", EVENT_TRACKER,
|
"event_type", EVENT_TRACKER,
|
||||||
"unique_ID",
|
"unique_ID",
|
||||||
M_torrents->at(index).unique_ID,
|
M_torrents->at(index).unique_ID,
|
||||||
|
@ -800,6 +791,7 @@ static PyObject *torrent_pop_event(PyObject *self, PyObject *args)
|
||||||
"unique_ID",
|
"unique_ID",
|
||||||
M_torrents->at(index).unique_ID,
|
M_torrents->at(index).unique_ID,
|
||||||
"tracker_status", "Announce succeeded",
|
"tracker_status", "Announce succeeded",
|
||||||
|
"num_peers", long(dynamic_cast<tracker_reply_alert*>(popped_alert)->num_peers),
|
||||||
"message", a->msg().c_str());
|
"message", a->msg().c_str());
|
||||||
else
|
else
|
||||||
{ Py_INCREF(Py_None); return Py_None; }
|
{ Py_INCREF(Py_None); return Py_None; }
|
||||||
|
|
|
@ -619,6 +619,8 @@ class DelugeGTK:
|
||||||
|
|
||||||
## Call via a timer to update the interface
|
## Call via a timer to update the interface
|
||||||
def update(self):
|
def update(self):
|
||||||
|
# Tell the core to handle messages (now, so we show their output on this tick)
|
||||||
|
self.manager.handle_events()
|
||||||
# Make sure that the interface still exists
|
# Make sure that the interface still exists
|
||||||
try:
|
try:
|
||||||
tab = self.wtree.get_widget("torrent_info").get_current_page()
|
tab = self.wtree.get_widget("torrent_info").get_current_page()
|
||||||
|
|
Loading…
Reference in New Issue