Skip to content

Allow torrents to use a forwarded incoming port #78

Description

@InvalidPandaa

Problem

A torrent that cannot accept incoming connections only ever talks to peers that reach out first, which costs both speed and the ability to seed usefully. Users behind a router, and VPN users in particular, can forward a port to their Mac, but Harbor has no way to tell aria2 to use it, so it keeps picking from its default 6881-6999 range and the forwarded port goes unused.

This matters most together with #72: Proton VPN, Mullvad, AirVPN and others offer port forwarding specifically for P2P, and binding torrents to the VPN interface without also using its forwarded port leaves most of the benefit on the table.

Goal

Let the user set the port incoming peers should reach Harbor on.

Expected behavior

  • Settings › Torrents takes an optional incoming port, off by default.
  • When off, aria2 keeps its own default range, so nothing changes for existing users.
  • When set, torrents accept peers on that port, and DHT and UDP trackers use it too, since a forwarded port is opened for TCP and UDP alike.
  • The value is limited to what aria2 accepts, 1024-65535.
  • Changing it restarts the torrent engine, because aria2 fixes its listening ports at launch and neither port is changeable over RPC.

Edge cases worth considering

  • The port only commits once editing ends. Writing every keystroke through clamps partial numbers up to the minimum, so typing 49152 arrives as 65535, and each digit would restart the engine.
  • A VPN usually hands out a new forwarded port on every connection, so the value goes stale after reconnecting. Discovering it automatically would need a NAT-PMP client with a 60-second lease renewal, which is a separate feature; the manual field already covers a router forward and a long-lived VPN session.

Reference

qBittorrent exposes the same setting as "Port used for incoming connections".

I have this implemented on top of #72 and will open a PR once that one lands.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions