feat: bind torrent client to a network adapter#2405
Open
Moyasee wants to merge 5 commits into
Open
Conversation
Adds a setting to bind the torrent client to a specific network adapter, so torrent traffic only flows through it (e.g. a VPN). The binding acts as a kill switch: if the selected adapter goes down, torrents stop instead of leaking through the default connection. The chosen adapter is applied to the libtorrent session via listen_interfaces and outgoing_interfaces, persisted as a user preference, and re-applied on RPC startup. A new IPC handler enumerates the available adapters for the settings dropdown. Closes #2023
Contributor
Contributor
Author
|
@greptile review |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



When submitting this pull request, I confirm the following (please check the boxes):
Fill in the PR content:
Closes #2023.
Adds a setting to bind the torrent client to a specific network adapter, so torrent traffic only goes through it. The main use case is forcing torrents through a VPN.
It works as a kill switch: while bound to an adapter, torrents only connect through that adapter, and downloads stop if it goes down instead of falling back to your regular connection and leaking traffic.
How it works
listen_interfacesandoutgoing_interfaces, the same approach qBittorrent uses, so we bind by device name and it stays stable across VPN reconnects.torrentNetworkInterface), applied live when changed, and re-applied on RPC startup before any torrent is added.getNetworkInterfacesIPC handler lists the available adapters (viaos.networkInterfaces()) for the dropdown. Loopback is filtered out.Notes
Device-name binding works across platforms with libtorrent 2.0. On Windows the adapter friendly names from
os.networkInterfaces()are used, which match what libtorrent expects, but it would be good to get a Windows test in.Testing