rename http_settings class as http_proxy class

This commit is contained in:
spyhole 2005-08-24 23:08:26 +00:00
parent 84ddeacea0
commit 67527bec0b
14 changed files with 57 additions and 57 deletions

View File

@ -89,7 +89,7 @@
<li><a class="reference" href="#torrent-status" id="id74" name="id74">torrent_status</a></li> <li><a class="reference" href="#torrent-status" id="id74" name="id74">torrent_status</a></li>
<li><a class="reference" href="#peer-info" id="id75" name="id75">peer_info</a></li> <li><a class="reference" href="#peer-info" id="id75" name="id75">peer_info</a></li>
<li><a class="reference" href="#address" id="id76" name="id76">address</a></li> <li><a class="reference" href="#address" id="id76" name="id76">address</a></li>
<li><a class="reference" href="#http-settings" id="id77" name="id77">http_settings</a></li> <li><a class="reference" href="#http-settings" id="id77" name="id77">http_proxy</a></li>
<li><a class="reference" href="#ip-filter" id="id78" name="id78">ip_filter</a><ul> <li><a class="reference" href="#ip-filter" id="id78" name="id78">ip_filter</a><ul>
<li><a class="reference" href="#id14" id="id79" name="id79">ip_filter()</a></li> <li><a class="reference" href="#id14" id="id79" name="id79">ip_filter()</a></li>
<li><a class="reference" href="#add-rule" id="id80" name="id80">add_rule()</a></li> <li><a class="reference" href="#add-rule" id="id80" name="id80">add_rule()</a></li>
@ -542,7 +542,7 @@ class session: public boost::noncopyable
void disable_extensions(); void disable_extensions();
void enable_extension(peer_connection::extension_index); void enable_extension(peer_connection::extension_index);
void set_http_settings(const http_settings&amp; settings); void set_http_proxy(const http_proxy&amp; settings);
void set_upload_rate_limit(int bytes_per_second); void set_upload_rate_limit(int bytes_per_second);
void set_download_rate_limit(int bytes_per_second); void set_download_rate_limit(int bytes_per_second);
@ -591,7 +591,7 @@ the parameters, see <tt class="docutils literal"><span class="pre">listen_on()</
If some trackers are down, they will time out. All this before the destructor of session If some trackers are down, they will time out. All this before the destructor of session
returns. So, it's adviced that any kind of interface (such as windows) are closed before returns. So, it's adviced that any kind of interface (such as windows) are closed before
destructing the sessoin object. Because it can take a few second for it to finish. The destructing the sessoin object. Because it can take a few second for it to finish. The
timeout can be set with <tt class="docutils literal"><span class="pre">set_http_settings()</span></tt>.</p> timeout can be set with <tt class="docutils literal"><span class="pre">set_http_proxy()</span></tt>.</p>
</div> </div>
<div class="section" id="add-torrent"> <div class="section" id="add-torrent">
<h2><a name="add-torrent">add_torrent()</a></h2> <h2><a name="add-torrent">add_torrent()</a></h2>
@ -1790,15 +1790,15 @@ while it does the DNS lookup, it returns a string that points to the address rep
<p><tt class="docutils literal"><span class="pre">ip()</span></tt> will return the 32-bit ip-address as an integer. <tt class="docutils literal"><span class="pre">port()</span></tt> returns the port number.</p> <p><tt class="docutils literal"><span class="pre">ip()</span></tt> will return the 32-bit ip-address as an integer. <tt class="docutils literal"><span class="pre">port()</span></tt> returns the port number.</p>
</div> </div>
<div class="section" id="http-settings"> <div class="section" id="http-settings">
<h1><a name="http-settings">http_settings</a></h1> <h1><a name="http-settings">http_proxy</a></h1>
<p>You have some control over tracker requests through the <tt class="docutils literal"><span class="pre">http_settings</span></tt> object. You <p>You have some control over tracker requests through the <tt class="docutils literal"><span class="pre">http_proxy</span></tt> object. You
create it and fill it with your settings and then use <tt class="docutils literal"><span class="pre">session::set_http_settings()</span></tt> create it and fill it with your settings and then use <tt class="docutils literal"><span class="pre">session::set_http_proxy()</span></tt>
to apply them. You have control over proxy and authorization settings and also the user-agent to apply them. You have control over proxy and authorization settings and also the user-agent
that will be sent to the tracker. The user-agent is a good way to identify your client.</p> that will be sent to the tracker. The user-agent is a good way to identify your client.</p>
<pre class="literal-block"> <pre class="literal-block">
struct http_settings struct http_proxy
{ {
http_settings(); http_proxy();
std::string proxy_ip; std::string proxy_ip;
int proxy_port; int proxy_port;
std::string proxy_login; std::string proxy_login;
@ -2563,7 +2563,7 @@ int main(int argc, char* argv[])
#include &quot;libtorrent/entry.hpp&quot; #include &quot;libtorrent/entry.hpp&quot;
#include &quot;libtorrent/bencode.hpp&quot; #include &quot;libtorrent/bencode.hpp&quot;
#include &quot;libtorrent/session.hpp&quot; #include &quot;libtorrent/session.hpp&quot;
#include &quot;libtorrent/http_settings.hpp&quot; #include &quot;libtorrent/http_proxy.hpp&quot;
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {

View File

@ -420,7 +420,7 @@ The ``session`` class has the following synopsis::
void disable_extensions(); void disable_extensions();
void enable_extension(peer_connection::extension_index); void enable_extension(peer_connection::extension_index);
void set_http_settings(const http_settings& settings); void set_http_proxy(const http_proxy& settings);
void set_upload_rate_limit(int bytes_per_second); void set_upload_rate_limit(int bytes_per_second);
void set_download_rate_limit(int bytes_per_second); void set_download_rate_limit(int bytes_per_second);
@ -471,7 +471,7 @@ The destructor of session will notify all trackers that our torrents have been s
If some trackers are down, they will time out. All this before the destructor of session If some trackers are down, they will time out. All this before the destructor of session
returns. So, it's adviced that any kind of interface (such as windows) are closed before returns. So, it's adviced that any kind of interface (such as windows) are closed before
destructing the sessoin object. Because it can take a few second for it to finish. The destructing the sessoin object. Because it can take a few second for it to finish. The
timeout can be set with ``set_http_settings()``. timeout can be set with ``set_http_proxy()``.
add_torrent() add_torrent()
@ -1768,19 +1768,19 @@ while it does the DNS lookup, it returns a string that points to the address rep
http_settings http_proxy
============= =============
You have some control over tracker requests through the ``http_settings`` object. You You have some control over tracker requests through the ``http_proxy`` object. You
create it and fill it with your settings and then use ``session::set_http_settings()`` create it and fill it with your settings and then use ``session::set_http_proxy()``
to apply them. You have control over proxy and authorization settings and also the user-agent to apply them. You have control over proxy and authorization settings and also the user-agent
that will be sent to the tracker. The user-agent is a good way to identify your client. that will be sent to the tracker. The user-agent is a good way to identify your client.
:: ::
struct http_settings struct http_proxy
{ {
http_settings(); http_proxy();
std::string proxy_ip; std::string proxy_ip;
int proxy_port; int proxy_port;
std::string proxy_login; std::string proxy_login;
@ -2643,7 +2643,7 @@ This is a simple client. It doesn't have much output to keep it simple::
#include "libtorrent/entry.hpp" #include "libtorrent/entry.hpp"
#include "libtorrent/bencode.hpp" #include "libtorrent/bencode.hpp"
#include "libtorrent/session.hpp" #include "libtorrent/session.hpp"
#include "libtorrent/http_settings.hpp" #include "libtorrent/http_proxy.hpp"
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {

View File

@ -51,7 +51,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/entry.hpp" #include "libtorrent/entry.hpp"
#include "libtorrent/bencode.hpp" #include "libtorrent/bencode.hpp"
#include "libtorrent/session.hpp" #include "libtorrent/session.hpp"
#include "libtorrent/http_settings.hpp" #include "libtorrent/http_proxy.hpp"
#include "libtorrent/identify_client.hpp" #include "libtorrent/identify_client.hpp"
#include "libtorrent/alert_types.hpp" #include "libtorrent/alert_types.hpp"
@ -303,7 +303,7 @@ int main(int argc, char* argv[])
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
fs::path::default_name_check(fs::no_check); fs::path::default_name_check(fs::no_check);
http_settings settings; http_proxy settings;
// settings.proxy_ip = "192.168.0.1"; // settings.proxy_ip = "192.168.0.1";
// settings.proxy_port = 80; // settings.proxy_port = 80;
// settings.proxy_login = "hyd"; // settings.proxy_login = "hyd";
@ -319,7 +319,7 @@ int main(int argc, char* argv[])
ses.listen_on(std::make_pair(6880, 6889)); ses.listen_on(std::make_pair(6880, 6889));
//ses.set_upload_rate_limit(512 * 1024); //ses.set_upload_rate_limit(512 * 1024);
ses.set_http_settings(settings); ses.set_http_proxy(settings);
ses.set_severity_level(alert::debug); ses.set_severity_level(alert::debug);
// ses.set_severity_level(alert::info); // ses.set_severity_level(alert::info);

View File

@ -41,7 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/entry.hpp" #include "libtorrent/entry.hpp"
#include "libtorrent/bencode.hpp" #include "libtorrent/bencode.hpp"
#include "libtorrent/session.hpp" #include "libtorrent/session.hpp"
#include "libtorrent/http_settings.hpp" #include "libtorrent/http_proxy.hpp"
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {

View File

@ -9,7 +9,7 @@ libtorrent/escape_string.hpp \
libtorrent/file.hpp \ libtorrent/file.hpp \
libtorrent/fingerprint.hpp \ libtorrent/fingerprint.hpp \
libtorrent/hasher.hpp \ libtorrent/hasher.hpp \
libtorrent/http_settings.hpp \ libtorrent/http_proxy.hpp \
libtorrent/http_tracker_connection.hpp \ libtorrent/http_tracker_connection.hpp \
libtorrent/identify_client.hpp \ libtorrent/identify_client.hpp \
libtorrent/invariant_check.hpp \ libtorrent/invariant_check.hpp \

View File

@ -52,7 +52,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket.hpp" #include "libtorrent/socket.hpp"
#include "libtorrent/entry.hpp" #include "libtorrent/entry.hpp"
#include "libtorrent/http_settings.hpp" #include "libtorrent/http_proxy.hpp"
#include "libtorrent/peer_id.hpp" #include "libtorrent/peer_id.hpp"
#include "libtorrent/peer.hpp" #include "libtorrent/peer.hpp"
#include "libtorrent/tracker_manager.hpp" #include "libtorrent/tracker_manager.hpp"
@ -73,7 +73,7 @@ namespace libtorrent
, unsigned short port , unsigned short port
, std::string request , std::string request
, boost::weak_ptr<request_callback> c , boost::weak_ptr<request_callback> c
, const http_settings& stn , const http_proxy& http_proxy
, std::string const& password = ""); , std::string const& password = "");
virtual bool tick(); virtual bool tick();
virtual bool send_finished() const virtual bool send_finished() const
@ -109,7 +109,7 @@ namespace libtorrent
std::string m_server_message; std::string m_server_message;
std::string m_server_protocol; std::string m_server_protocol;
const http_settings& m_settings; const http_proxy& m_http_proxy;
tracker_request m_req; tracker_request m_req;
std::string m_password; std::string m_password;
int m_code; int m_code;

View File

@ -236,7 +236,7 @@ namespace libtorrent
bool extensions_enabled() const; bool extensions_enabled() const;
// the settings for the client // the settings for the client
http_settings m_settings; http_proxy m_http_proxy;
// set to true when the session object // set to true when the session object
// is being destructed and the thread // is being destructed and the thread
@ -277,7 +277,7 @@ namespace libtorrent
}; };
} }
struct http_settings; struct http_proxy;
struct session_status struct session_status
{ {
@ -359,7 +359,7 @@ namespace libtorrent
void remove_torrent(const torrent_handle& h); void remove_torrent(const torrent_handle& h);
void set_http_settings(const http_settings& s); void set_http_proxy(const http_proxy& http_proxy);
void set_upload_rate_limit(int bytes_per_second); void set_upload_rate_limit(int bytes_per_second);
void set_download_rate_limit(int bytes_per_second); void set_download_rate_limit(int bytes_per_second);
void set_max_uploads(int limit); void set_max_uploads(int limit);

View File

@ -53,7 +53,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket.hpp" #include "libtorrent/socket.hpp"
#include "libtorrent/entry.hpp" #include "libtorrent/entry.hpp"
#include "libtorrent/http_settings.hpp" #include "libtorrent/http_proxy.hpp"
#include "libtorrent/peer_id.hpp" #include "libtorrent/peer_id.hpp"
#include "libtorrent/peer.hpp" #include "libtorrent/peer.hpp"
@ -162,8 +162,8 @@ namespace libtorrent
{ {
public: public:
tracker_manager(const http_settings& s) tracker_manager(const http_proxy& http_proxy)
: m_settings(s) {} : m_http_proxy(http_proxy) {}
void tick(); void tick();
void queue_request( void queue_request(
@ -179,7 +179,7 @@ namespace libtorrent
typedef std::list<boost::shared_ptr<tracker_connection> > typedef std::list<boost::shared_ptr<tracker_connection> >
tracker_connections_t; tracker_connections_t;
tracker_connections_t m_connections; tracker_connections_t m_connections;
const http_settings& m_settings; const http_proxy& m_http_proxy;
}; };
} }

View File

@ -52,7 +52,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket.hpp" #include "libtorrent/socket.hpp"
#include "libtorrent/entry.hpp" #include "libtorrent/entry.hpp"
#include "libtorrent/http_settings.hpp" #include "libtorrent/http_proxy.hpp"
#include "libtorrent/peer_id.hpp" #include "libtorrent/peer_id.hpp"
#include "libtorrent/peer.hpp" #include "libtorrent/peer.hpp"
#include "libtorrent/tracker_manager.hpp" #include "libtorrent/tracker_manager.hpp"
@ -70,7 +70,7 @@ namespace libtorrent
, std::string const& hostname , std::string const& hostname
, unsigned short port , unsigned short port
, boost::weak_ptr<request_callback> c , boost::weak_ptr<request_callback> c
, const http_settings& stn); , const http_proxy& http_proxy);
virtual bool tick(); virtual bool tick();
virtual bool send_finished() const; virtual bool send_finished() const;
@ -103,7 +103,7 @@ namespace libtorrent
tracker_request m_request; tracker_request m_request;
int m_transaction_id; int m_transaction_id;
boost::int64_t m_connection_id; boost::int64_t m_connection_id;
const http_settings& m_settings; const http_proxy& m_http_proxy;
int m_attempts; int m_attempts;
}; };

View File

@ -21,7 +21,7 @@ $(top_srcdir)/include/libtorrent/escape_string.hpp \
$(top_srcdir)/include/libtorrent/file.hpp \ $(top_srcdir)/include/libtorrent/file.hpp \
$(top_srcdir)/include/libtorrent/fingerprint.hpp \ $(top_srcdir)/include/libtorrent/fingerprint.hpp \
$(top_srcdir)/include/libtorrent/hasher.hpp \ $(top_srcdir)/include/libtorrent/hasher.hpp \
$(top_srcdir)/include/libtorrent/http_settings.hpp \ $(top_srcdir)/include/libtorrent/http_proxy.hpp \
$(top_srcdir)/include/libtorrent/http_tracker_connection.hpp \ $(top_srcdir)/include/libtorrent/http_tracker_connection.hpp \
$(top_srcdir)/include/libtorrent/identify_client.hpp \ $(top_srcdir)/include/libtorrent/identify_client.hpp \
$(top_srcdir)/include/libtorrent/invariant_check.hpp \ $(top_srcdir)/include/libtorrent/invariant_check.hpp \

View File

@ -85,7 +85,7 @@ namespace libtorrent
, unsigned short port , unsigned short port
, std::string request , std::string request
, boost::weak_ptr<request_callback> c , boost::weak_ptr<request_callback> c
, const http_settings& stn , const http_proxy& http_proxy
, std::string const& auth) , std::string const& auth)
: tracker_connection(c) : tracker_connection(c)
, m_man(man) , m_man(man)
@ -94,7 +94,7 @@ namespace libtorrent
, m_content_length(0) , m_content_length(0)
, m_recv_pos(0) , m_recv_pos(0)
, m_request_time(second_clock::universal_time()) , m_request_time(second_clock::universal_time())
, m_settings(stn) , m_http_proxy(http_proxy)
, m_req(req) , m_req(req)
, m_password(auth) , m_password(auth)
, m_code(0) , m_code(0)
@ -103,10 +103,10 @@ namespace libtorrent
bool using_proxy = false; bool using_proxy = false;
// should we use the proxy? // should we use the proxy?
if (!m_settings.proxy_ip.empty()) if (!m_http_proxy.proxy_ip.empty())
{ {
connect_to_host = &m_settings.proxy_ip; connect_to_host = &m_http_proxy.proxy_ip;
if (m_settings.proxy_port != 0) port = m_settings.proxy_port; if (m_http_proxy.proxy_port != 0) port = m_http_proxy.proxy_port;
using_proxy = true; using_proxy = true;
} }
else else
@ -189,7 +189,7 @@ namespace libtorrent
m_send_buffer += " HTTP/1.0\r\nAccept-Encoding: gzip\r\n" m_send_buffer += " HTTP/1.0\r\nAccept-Encoding: gzip\r\n"
"User-Agent: "; "User-Agent: ";
m_send_buffer += m_settings.user_agent; m_send_buffer += m_http_proxy.user_agent;
m_send_buffer += " (libtorrent)\r\n" m_send_buffer += " (libtorrent)\r\n"
"Host: "; "Host: ";
m_send_buffer += hostname; m_send_buffer += hostname;
@ -198,10 +198,10 @@ namespace libtorrent
m_send_buffer += ':'; m_send_buffer += ':';
m_send_buffer += boost::lexical_cast<std::string>(port); m_send_buffer += boost::lexical_cast<std::string>(port);
} }
if (using_proxy && !m_settings.proxy_login.empty()) if (using_proxy && !m_http_proxy.proxy_login.empty())
{ {
m_send_buffer += "\r\nProxy-Authorization: Basic "; m_send_buffer += "\r\nProxy-Authorization: Basic ";
m_send_buffer += base64encode(m_settings.proxy_login + ":" + m_settings.proxy_password); m_send_buffer += base64encode(m_http_proxy.proxy_login + ":" + m_http_proxy.proxy_password);
} }
if (auth != "") if (auth != "")
{ {
@ -259,8 +259,8 @@ namespace libtorrent
using namespace boost::posix_time; using namespace boost::posix_time;
time_duration d = second_clock::universal_time() - m_request_time; time_duration d = second_clock::universal_time() - m_request_time;
if (d > seconds(m_settings.tracker_timeout) || if (d > seconds(m_http_proxy.tracker_timeout) ||
(!has_requester() && d > seconds(m_settings.stop_tracker_timeout))) (!has_requester() && d > seconds(m_http_proxy.stop_tracker_timeout)))
{ {
if (has_requester()) requester().tracker_request_timed_out(m_req); if (has_requester()) requester().tracker_request_timed_out(m_req);
return true; return true;
@ -310,7 +310,7 @@ namespace libtorrent
// if the receive buffer is full, expand it with http_buffer_size // if the receive buffer is full, expand it with http_buffer_size
if ((int)m_buffer.size() == m_recv_pos) if ((int)m_buffer.size() == m_recv_pos)
{ {
if ((int)m_buffer.size() > m_settings.tracker_maximum_response_length) if ((int)m_buffer.size() > m_http_proxy.tracker_maximum_response_length)
{ {
if (has_requester()) if (has_requester())
{ {
@ -415,7 +415,7 @@ namespace libtorrent
} }
return true; return true;
} }
if (m_content_length > m_settings.tracker_maximum_response_length) if (m_content_length > m_http_proxy.tracker_maximum_response_length)
{ {
if (has_requester()) if (has_requester())
{ {
@ -514,7 +514,7 @@ namespace libtorrent
boost::shared_ptr<request_callback> r = m_requester.lock(); boost::shared_ptr<request_callback> r = m_requester.lock();
if (!r) return true; if (!r) return true;
if (inflate_gzip(m_buffer, m_req, r.get(), if (inflate_gzip(m_buffer, m_req, r.get(),
m_settings.tracker_maximum_response_length)) m_http_proxy.tracker_maximum_response_length))
return true; return true;
} }

View File

@ -223,7 +223,7 @@ namespace libtorrent { namespace detail
std::pair<int, int> listen_port_range std::pair<int, int> listen_port_range
, const fingerprint& cl_fprint , const fingerprint& cl_fprint
, const char* listen_interface = 0) , const char* listen_interface = 0)
: m_tracker_manager(m_settings) : m_tracker_manager(m_http_proxy)
, m_listen_port_range(listen_port_range) , m_listen_port_range(listen_port_range)
, m_listen_interface(listen_interface, listen_port_range.first) , m_listen_interface(listen_interface, listen_port_range.first)
, m_abort(false) , m_abort(false)
@ -1167,10 +1167,10 @@ namespace libtorrent
return m_impl.m_listen_socket; return m_impl.m_listen_socket;
} }
void session::set_http_settings(const http_settings& s) void session::set_http_proxy(const http_proxy& http_proxy)
{ {
boost::mutex::scoped_lock l(m_impl.m_mutex); boost::mutex::scoped_lock l(m_impl.m_mutex);
m_impl.m_settings = s; m_impl.m_http_proxy = http_proxy;
} }
session::~session() session::~session()

View File

@ -448,7 +448,7 @@ namespace libtorrent
, port , port
, request_string , request_string
, c , c
, m_settings , m_http_proxy
, auth)); , auth));
} }
else if (protocol == "udp") else if (protocol == "udp")
@ -458,7 +458,7 @@ namespace libtorrent
, hostname , hostname
, port , port
, c , c
, m_settings)); , m_http_proxy));
} }
else else
{ {

View File

@ -64,13 +64,13 @@ namespace libtorrent
, std::string const& hostname , std::string const& hostname
, unsigned short port , unsigned short port
, boost::weak_ptr<request_callback> c , boost::weak_ptr<request_callback> c
, const http_settings& stn) , const http_proxy& http_proxy)
: tracker_connection(c) : tracker_connection(c)
, m_request_time(second_clock::universal_time()) , m_request_time(second_clock::universal_time())
, m_request(req) , m_request(req)
, m_transaction_id(0) , m_transaction_id(0)
, m_connection_id(0) , m_connection_id(0)
, m_settings(stn) , m_http_proxy(http_proxy)
, m_attempts(0) , m_attempts(0)
{ {
m_name_lookup = dns_lookup(hostname.c_str(), port); m_name_lookup = dns_lookup(hostname.c_str(), port);
@ -85,7 +85,7 @@ namespace libtorrent
time_duration d = second_clock::universal_time() - m_request_time; time_duration d = second_clock::universal_time() - m_request_time;
return (m_transaction_id != 0 return (m_transaction_id != 0
&& m_connection_id != 0) && m_connection_id != 0)
|| d > seconds(m_settings.tracker_timeout); || d > seconds(m_http_proxy.tracker_timeout);
} }
bool udp_tracker_connection::tick() bool udp_tracker_connection::tick()