Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve documentation clarity around i2p settings #7305

Merged
merged 1 commit into from
Feb 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion include/libtorrent/aux_/session_impl.hpp
Original file line number Diff line number Diff line change
@@ -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();
1 change: 0 additions & 1 deletion include/libtorrent/aux_/session_interface.hpp
Original file line number Diff line number Diff line change
@@ -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

12 changes: 10 additions & 2 deletions include/libtorrent/settings_pack.hpp
Original file line number Diff line number Diff line change
@@ -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,
@@ -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:

11 changes: 0 additions & 11 deletions src/session_impl.cpp
Original file line number Diff line number Diff line change
@@ -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)
10 changes: 8 additions & 2 deletions src/torrent.cpp
Original file line number Diff line number Diff line change
@@ -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.
@@ -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());