Skip to content

I2p flag - #8414

Draft
arvidn wants to merge 2 commits into
RC_2_1from
i2p-flag
Draft

arvidn wants to merge 2 commits into
RC_2_1from
i2p-flag

Conversation

@arvidn

@arvidn arvidn commented May 24, 2026

Copy link
Copy Markdown
Owner

perhaps this is better targeting master.

The idea is to simplify the control of i2p torrents with a single flag allow_i2p_peers, instead of the allow_i2p_mixed settings and the i2p_torrent flag.

arvidn added 2 commits May 24, 2026 18:59
… only_i2p_peers flag on torrents, to explicitly allow/disallow non i2p peers per torrent

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors I2P torrent handling by introducing a per-torrent torrent_flags::only_i2p_peers restriction flag and moving behavior checks from a global “mixed mode” setting to this per-torrent state (with backward compatibility for TORRENT_ABI_VERSION < 4). It also updates resume data, magnet parsing, and torrent loading to “fail closed” by default for I2P torrents.

Changes:

  • Add and propagate torrent_flags::only_i2p_peers through torrent lifecycle (load, magnet, resume, runtime updates).
  • Deprecate/alias legacy i2p_torrent handling via deprecated_i2p_torrent and keep allow_i2p_mixed only for ABI < 4 with a session callback to reconcile existing torrents.
  • Update tests and tooling/docs scripts to reflect the new flag and deprecation plumbing.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/test_torrent.cpp Adds ABI<4 regression test covering allow_i2p_mixed reconciliation with only_i2p_peers.
test/test_resume.cpp Adds resume migration test for only_i2p_peers; updates legacy I2P flag references.
test/test_read_resume.cpp Updates flag masks to use deprecated_i2p_torrent.
test/test_magnet.cpp Asserts .i2p trackers set both deprecated_i2p_torrent and only_i2p_peers.
src/write_resume_data.cpp Serializes only_i2p_peers into resume data.
src/ut_pex.cpp Disables uTP PEX for i2p-only torrents via only_i2p_peers().
src/torrent.cpp Introduces m_only_i2p_peers state; switches multiple behaviors to gate on i2p-only torrents; adds compatibility shim in set_flags().
src/torrent_info.cpp Marks torrent_info as I2P based on deprecated_i2p_torrent.
src/settings_pack.cpp Introduces DEPRECATED4_SET and wires allow_i2p_mixed to a session update callback (ABI<4).
src/session_impl.cpp Implements update_allow_i2p_mixed() and uses only_i2p_peers() for LSD peer add gating.
src/read_resume_data.cpp Reads/writes deprecated_i2p_torrent and migrates missing only_i2p_peers by failing closed.
src/peer_connection.cpp Disconnects non-I2P peers when torrent is i2p-only.
src/magnet_uri.cpp Sets i2p-only on .i2p tracker detection (fail closed).
src/load_torrent.cpp Sets i2p-only on .i2p tracker detection (fail closed).
include/libtorrent/torrent_flags.hpp Deprecates i2p_torrent (ABI<4), adds deprecated_i2p_torrent alias and new only_i2p_peers flag.
include/libtorrent/settings_pack.hpp Deprecates allow_i2p_mixed for ABI<4 and hides it for ABI>=4.
include/libtorrent/aux_/torrent.hpp Adds only_i2p_peers() accessor and stores m_only_i2p_peers bit.
include/libtorrent/aux_/session_impl.hpp Declares update_allow_i2p_mixed().
docs/gen_settings_doc.py Extends ABI skip handling and strips TORRENT_DEPRECATED_ENUM markers.
bindings/c/src/settings.cpp Regenerates C settings mapping without SET_ALLOW_I2P_MIXED.
bindings/c/include/libtorrent_settings.h Regenerates C settings tags without SET_ALLOW_I2P_MIXED.
.pre-commit-config.yaml Adjusts git-clang-format hook to receive filenames and excludes generated sources.
.clang-format-ignore Adds ignore list for generated files for editor/direct clang-format runs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/gen_settings_doc.py
Comment on lines 134 to +141
line = line.strip()
if line.endswith(","):
line = line[:-1] # strip trailing comma
if "=" in line:
line = line.split("=")[0].strip()
# strip a trailing deprecation marker, e.g. "name TORRENT_DEPRECATED_ENUM"
if line.endswith("TORRENT_DEPRECATED_ENUM"):
line = line[: -len("TORRENT_DEPRECATED_ENUM")].strip()
Comment thread src/settings_pack.cpp
Comment on lines +146 to +148
DEPRECATED_SET(ignore_limits_on_local_network,
true,
&session_impl::update_ignore_rate_limits_on_local_network),
Comment thread src/torrent.cpp
Comment on lines +993 to +994
{
m_only_i2p_peers = bool(flags & torrent_flags::only_i2p_peers);
Comment thread src/torrent.cpp
Comment on lines +973 to +977
if (mask & torrent_flags::deprecated_i2p_torrent)
{
m_i2p = bool(flags & torrent_flags::i2p_torrent);
bool const new_i2p = bool(flags & torrent_flags::deprecated_i2p_torrent);
m_i2p = new_i2p;
// backward compatibility: toggling the i2p_torrent flag also
@kiragakiyumi

Copy link
Copy Markdown

It would be great if these changes could still make it into 2.1.x, if you think that’s feasible. I understand you mentioned that this might be better targeted at master, though.

@glassez

glassez commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

The idea is to simplify the control of i2p torrents with a single flag allow_i2p_peers, instead of the allow_i2p_mixed settings and the i2p_torrent flag.

It seems that this goes against users’ expectations regarding the use of I2P. Rather, they may or may not need to prohibit regular peers when using I2P.

@kiragakiyumi

Copy link
Copy Markdown

@glassez, do you mean two modes for I2P torrents: Mixed Mode, where both I2P and regular peers are allowed through the I2P network, and I2P-only mode, where only I2P peers are allowed to connect through the I2P network?

If so, that does indeed seem like a more correct approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants