Skip to content

Commit

Permalink
improve documentation clarity around i2p settings. Slightly simplify …
Browse files Browse the repository at this point in the history
…session_interface
  • Loading branch information
arvidn committed Feb 12, 2023
1 parent 02884d3 commit 8e54fd9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
1 change: 0 additions & 1 deletion include/libtorrent/aux_/session_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,6 @@ namespace aux {

#if TORRENT_USE_I2P
char const* i2p_session() const override { return m_i2p_conn.session_id(); }
proxy_settings i2p_proxy() const override;

void on_i2p_open(error_code const& ec);
void open_new_incoming_i2p_connection();
Expand Down
1 change: 0 additions & 1 deletion include/libtorrent/aux_/session_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ namespace aux {
virtual proxy_settings proxy() const = 0;

#if TORRENT_USE_I2P
virtual proxy_settings i2p_proxy() const = 0;
virtual char const* i2p_session() const = 0;
#endif

Expand Down
12 changes: 10 additions & 2 deletions include/libtorrent/settings_pack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,10 @@ namespace aux {
proxy_password,

// sets the i2p_ SAM bridge to connect to. set the port with the
// ``i2p_port`` setting.
// ``i2p_port`` setting. Unless this is set, i2p torrents are not
// supported. This setting is separate from the other proxy settings
// since i2p torrents and their peers are orthogonal. You can have
// i2p peers as well as regular peers via a proxy.
//
// .. _i2p: http://www.i2p2.de
i2p_hostname,
Expand Down Expand Up @@ -2206,8 +2209,13 @@ namespace aux {
// authorization. The username and password will be sent to the proxy.
http_pw,

// route through a i2p SAM proxy
#if TORRENT_USE_I2P
// internal
// This is used internally to communicate with the
// http_tracker_connection. To configure an i2p SAM bridge, set
// i2p_hostname and i2p_port.
i2p_proxy
#endif
};
private:

Expand Down
11 changes: 0 additions & 11 deletions src/session_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2354,17 +2354,6 @@ namespace {
#endif

#if TORRENT_USE_I2P

proxy_settings session_impl::i2p_proxy() const
{
proxy_settings ret;

ret.hostname = m_settings.get_str(settings_pack::i2p_hostname);
ret.type = settings_pack::i2p_proxy;
ret.port = std::uint16_t(m_settings.get_int(settings_pack::i2p_port));
return ret;
}

void session_impl::on_i2p_open(error_code const& ec)
{
if (ec)
Expand Down
10 changes: 8 additions & 2 deletions src/torrent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7350,7 +7350,7 @@ namespace {
#if TORRENT_USE_I2P
if (peerinfo->is_i2p_addr)
{
if (m_ses.i2p_proxy().hostname.empty())
if (settings().get_str(settings_pack::i2p_hostname).empty())
{
// we have an i2p torrent, but we're not connected to an i2p
// SAM proxy.
Expand Down Expand Up @@ -7396,8 +7396,14 @@ namespace {
// one. The main feature of a peer connection is that whether or not we
// proxy it is configurable. When we use i2p, we want to always prox
// everything via i2p.

aux::proxy_settings proxy;
proxy.hostname = settings().get_str(settings_pack::i2p_hostname);
proxy.port = std::uint16_t(settings().get_int(settings_pack::i2p_port));
proxy.type = settings_pack::i2p_proxy;

aux::socket_type ret = instantiate_connection(m_ses.get_context()
, m_ses.i2p_proxy(), nullptr, nullptr, false, false);
, proxy, nullptr, nullptr, false, false);
boost::get<i2p_stream>(ret).set_destination(static_cast<i2p_peer*>(peerinfo)->dest());
boost::get<i2p_stream>(ret).set_command(i2p_stream::cmd_connect);
boost::get<i2p_stream>(ret).set_session_id(m_ses.i2p_session());
Expand Down

0 comments on commit 8e54fd9

Please sign in to comment.