Skip to content

feat(torrent): advertise uTP and encryption, and find LAN peers over IPv6 - #513

Merged
linroid merged 2 commits into
mainfrom
feat/torrent-capabilities-and-ipv6-lsd
Oct 11, 2026
Merged

linroid merged 2 commits into
mainfrom
feat/torrent-capabilities-and-ipv6-lsd

Conversation

@linroid

@linroid linroid commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Capabilities: the torrent controller now lists utp and mse-pe (TorrentCapability.UTP and ENCRYPTION). They describe what the engine can speak, so they stay listed when the utp setting is off or encryption is off; those settings change live without the backend gaining or losing the protocol. seeding still follows the live upload policy. REST (/api/torrents/capabilities) and RemoteTorrentController pass the names through unchanged.
  • IPv6 local service discovery (BEP 14): JvmLsdTransport joins [ff15::efc0:988f]:6771 on the same dual-stack socket as the IPv4 group, on every non-point-to-point interface with a link-local or unique local IPv6 address. LsdTransport.send now takes the LsdAnnounce and writes each group's Host header (LSD_HOST_IPV4 / LSD_HOST_IPV6). IPv6 announces go to the group scoped to each interface, because macOS reports "No route to host" for ff15:: without a zone even with the multicast interface set. isCurrent compares both families' interfaces. It compares IPv4 addresses and link-local/ULA IPv6 addresses, never rotating global ones.
  • Senders: unique local (fc00::/7) IPv6 senders are delivered to v1 swarms and v2/hybrid sessions. IPv6 link-local senders are heard but dropped (lsdPeerDialable), because PeerEndpoint carries no zone id to dial them.

Tests

  • TorrentDownloadSourceTest: exact capability set, and both names stay listed with uTP and encryption off.
  • TorrentLocalDiscoveryTest: IPv6 Host encoding, sender filtering (ULA delivered; link-local, global and loopback not).
  • TorrentLocalDiscoveryEngineTest: a ULA LAN peer is dialed by a v1 swarm and by a hybrid's v2 swarm.
  • JvmLsdTransportTest: real IPv6 multicast between two transports (skipped where the system refuses). It ran and passed locally on macOS, as did IPv4.
  • Ran :library:torrent:jvmTest, :library:torrent:compileTestKotlinIosSimulatorArm64, :library:torrent-api:jvmTest, :library:server:test and :library:remote:jvmTest.

The engine speaks uTP (BEP 29) and MSE/PE, so the controller lists both
whatever the live utp and encryption settings say: capabilities describe
the backend.
Join the BEP 14 IPv6 group [ff15::efc0:988f]:6771 on interfaces with a
link-local or unique local address, on the same socket as the IPv4
group, and announce to both with each group's Host header. IPv6
announces go to the group scoped to each interface, as macOS finds no
route to it otherwise. Unique local senders are dialed; link-local ones
are not, as peer endpoints carry no zone. The network-change check
covers both families.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T10:41:13.788665Z d821557 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Oct 11, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 1 855 files  ± 0   1 882 suites  ±0   20m 27s ⏱️ - 1m 33s
12 437 tests +13  12 195 ✅ +13  242 💤 ±0  0 ❌ ±0 
14 870 runs  +23  14 628 ✅ +23  242 💤 ±0  0 ❌ ±0 

Results for commit d821557. ± Comparison against base commit ffad2f1.

This pull request removes 1 and adds 14 tests. Note that renamed tests count towards both.
com.linroid.ketch.torrent.lsd.JvmLsdTransportTest ‑ twoTransportsOnOnePort_hearEachOther[jvm]
com.linroid.ketch.torrent.TorrentDownloadSourceTest ‑ torrentCapabilities_utpAndEncryptionOff_stillListsEngineProtocols
com.linroid.ketch.torrent.TorrentDownloadSourceTest ‑ torrentCapabilities_utpAndEncryptionOff_stillListsEngineProtocols[jvm]
com.linroid.ketch.torrent.lsd.JvmLsdTransportTest ‑ ipv4_twoTransportsOnOnePort_hearEachOther[jvm]
com.linroid.ketch.torrent.lsd.JvmLsdTransportTest ‑ ipv6_twoTransportsOnOnePort_hearEachOther[jvm]
com.linroid.ketch.torrent.lsd.TorrentLocalDiscoveryTest ‑ accept_ipv6_deliversUniqueLocalSendersOnly
com.linroid.ketch.torrent.lsd.TorrentLocalDiscoveryTest ‑ accept_ipv6_deliversUniqueLocalSendersOnly[jvm]
com.linroid.ketch.torrent.lsd.TorrentLocalDiscoveryTest ‑ encode_forTheIpv6Group_namesItsHost
com.linroid.ketch.torrent.lsd.TorrentLocalDiscoveryTest ‑ encode_forTheIpv6Group_namesItsHost[jvm]
com.linroid.ketch.torrent.lsd.TorrentLocalDiscoveryTest ‑ lsdSenderAllowed_ipv6LinkLocalAndUniqueLocalOnly
com.linroid.ketch.torrent.lsd.TorrentLocalDiscoveryTest ‑ lsdSenderAllowed_ipv6LinkLocalAndUniqueLocalOnly[jvm]
…

@linroid
linroid merged commit 99a3608 into main Oct 11, 2026
15 checks passed
@linroid
linroid deleted the feat/torrent-capabilities-and-ipv6-lsd branch October 11, 2026 10:49
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.

1 participant