Skip to content

Network Connectivity Improvements (Add Announce Port Override And ipv4-only Mode)#531

Merged
ikatson merged 8 commits intoikatson:mainfrom
alexmichaelkeith:feat/network-connectivity
Jan 17, 2026
Merged

Network Connectivity Improvements (Add Announce Port Override And ipv4-only Mode)#531
ikatson merged 8 commits intoikatson:mainfrom
alexmichaelkeith:feat/network-connectivity

Conversation

@alexmichaelkeith
Copy link
Copy Markdown
Contributor

I think this project is fantastic! To optimize my own experience, I implemented these changes in my fork, but I believe others could benefit from them as well (and quite frankly, I'd love to avoid maintaining a permanent fork 😅).

This PR addresses connectivity issues encountered when running rqbit behind certain VPN providers (in my case ProtonVPN on macOS) and in environments lacking IPv6 support.

1. Announce Port Override: (Most Important to me)

Many VPN services, including ProtonVPN, assign an external port for port forwarding that differs from the internal listening port. For example, rqbit might bind locally to port 4240, but the VPN provider forwards external traffic from port 55555 to 4240. Without the ability to manually specify the announce port, rqbit advertises its local port (4240) to trackers and the DHT. External peers attempt to connect to that port and fail because the VPN is only forwarding traffic on the assigned external port (55555).

2. IPv4-Only Mode (Moderately important to me)

Some network configurations, including the ProtonVPN GUI client (at least on macOS), often lack full IPv6 support or have inconsistent IPv6 connectivity. In these cases:

  • The client may waste resources attempting to connect to IPv6 peers that are unreachable.
  • The client might erroneously announce an invalid or unreachable IPv6 address to trackers.
  • Logs become flooded with connection errors related to IPv6 reachability.

3. Port 0 Filtering (Least Important to me)

Added explicit filtering to reject peers advertising port 0, which is technically invalid and often indicative of "junk" data or bad NAT mappings, further improving connection stability.

Changes

  • Announce Port Override: Added an announce_port option to ListenerOptions and exposed it via the --announce-port CLI flag. This allows users to correctly advertise their external (VPN-assigned) port to the swarm while keeping the local bind port unchanged.
  • IPv4-Only Mode: Added an ipv4_only mode (via --ipv4-only CLI flag). When enabled:
    • The listener strictly binds to IPv4 interfaces.
    • IPv6 peer addresses are filtered out during connection attempts.
    • The DHT explicitly patches the listen address to 0.0.0.0 instead of [::] to ensure consistent behavior.
  • Port 0 Filtering: Added explicit filtering to reject peers advertising port 0, which is technically invalid and often indicative of "junk" data or bad NAT mappings, further improving connection stability.

@ikatson
Copy link
Copy Markdown
Owner

ikatson commented Jan 17, 2026

Hi, thanks a lot for this PR, looks great, and all the features are welcome! I'd merge right away just please fix cargo fmt

@alexmichaelkeith
Copy link
Copy Markdown
Contributor Author

Sweet! Should be formatted and up to date with main. If there is anything else needed to merge, just let me know. Thanks!

@alexmichaelkeith
Copy link
Copy Markdown
Contributor Author

Tests should pass now

@ikatson ikatson merged commit 82151de into ikatson:main Jan 17, 2026
4 checks passed
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.

2 participants