Interface Binding on Mac (New App!)

Feature requests for the Mac OS X version of Transmission
hbwhite
Posts: 16
Joined: Tue Feb 27, 2018 10:55 pm

Interface Binding on Mac (New App!)

Post by hbwhite »

Hi guys, for several years I've been using this horrible app called Vuze because it was the only app for Mac that offered "connection binding," where I could send traffic over my VPN connection only.

I finally wrote an app called Clutch to add this feature to Transmission! It is a separate app so you don't have to worry about patching, and it will continue to work when new updates to Transmission are released.

How does it work?

Transmission has a hidden option in its preferences file called "BindAddressIPv4" (and IPv6), which allows you to bind Transmission to an IP address. This is a nice feature, but it's a major inconvenience to have to update this address every time you start a new VPN connection. Clutch takes care of this for you!

The app has 2 parts:
  • Clutch is the GUI part of the app and allows you to select the interface you want to bind Transmission to.
  • Clutch Agent runs in the background (it has an icon in the menu bar) and monitors the IP address of the binding interface. When the IP address changes, it will update the binding IP address in Transmission's preferences and restart Transmission if it was running. There is also an option to start Clutch Agent automatically when you log in.
Changelog

v1.4:
- Clutch can now restart Transmission gracefully without using force-quit. This prevents you from losing your progress or torrent settings when Clutch has to restart Transmission. Enable this feature in Clutch for setup instructions.
- Added regex support for interface names. Be sure to use real regex and not shell glob. For example, enter utun.* instead of utun* if you want to use regex.
- Added a nice loading animation while Transmission is binding/unbinding
- Clutch now updates the list of interfaces each time you open the dropdown
- Fixed a bug where Transmission wouldn't restart if the bar menu was open
- Clutch now uses the new Mac OS hardened runtime
- Other minor bug fixes and performance improvements

v1.3:
- This version automatically checks for updates and allows you to update Clutch automatically within the app!
- It also fixes the issue found by @davids: Clutch now restarts Transmission if your binding interface disappears and reappears without changing its IP. This fixes an issue where Transmission would fail to bind to your VPN if it started before the interface was online (this could happen on boot if Transmission opened before your VPN started)

v1.2:
- Support for Dark Mode (colors have been adjusted to work in both Light and Dark Mode)
- You can now resize the window (uses AutoLayout so the UI is perfect)
- Other UI improvements

v1.1:
- Clutch now treats interfaces with the same name but different IPv4/IPv6 statuses as separate interfaces, preventing any traffic from accidentally being sent in the clear if a VPN doesn't support IPv6.

v1.0:
- Initial release

Download

You can download the app here (move it to your Applications folder):

https://github.com/hbwhite/Clutch/relea ... h-v1.4.zip

Source Code

Clutch is fully open-source, so you can inspect the code yourself. I have licensed it under the BSD license and posted the full source code here:

https://github.com/hbwhite/Clutch

Like the app?

If you like the Clutch app, post a message here so more people can find it! Thanks!
Last edited by hbwhite on Sun Feb 02, 2020 10:41 pm, edited 9 times in total.
fuori
Posts: 2
Joined: Fri Jul 13, 2018 12:25 pm

Re: Interface Binding on Mac (New App!)

Post by fuori »

Hi Harrison,

I'm surprised nobody has replied to your thread yet, so I decided to make an account to thank you for your efforts! I'm glad I don't have to switch to Vuze or qBitTorrent because of this "missing" feature in Transmission (I understand the reasoning behind why it's not being implemented, yet I feel this is actually a must-have nowadays).
Just installed Clutch and tested it - working brilliantly so far!

Thanks again for your great work, keep it up!

Best,
Matt
hbwhite
Posts: 16
Joined: Tue Feb 27, 2018 10:55 pm

Re: Interface Binding on Mac (New App!)

Post by hbwhite »

Thanks Matt! I was beginning to wonder if I was the only one who cared about this feature.

Glad to hear Clutch is working well for you. Hopefully other people who need interface binding will be able to find this thread!
hbwhite
Posts: 16
Joined: Tue Feb 27, 2018 10:55 pm

Re: Interface Binding on Mac (New App!)

Post by hbwhite »

Clutch version 1.1 available now.

(In Version 1.1, Clutch now treats interfaces with the same name but different IPv4/IPv6 statuses as separate interfaces, preventing any traffic from accidentally being sent in the clear if a VPN doesn't support IPv6.)

Updated code on GitHub.
Last edited by hbwhite on Sun Feb 02, 2020 10:42 pm, edited 1 time in total.
zymverb
Posts: 1
Joined: Fri Dec 28, 2018 6:32 am

Re: Interface Binding on Mac (New App!)

Post by zymverb »

newbie:
Clutch info says: "Clutch Agent runs in the background (it has an icon in the menu bar) and monitors the IP address of the binding interface. When the IP address changes, it will update the binding IP address in Transmission's preferences and restart Transmission if it was running. There is also an option to start Clutch Agent automatically when you log in."

But yet Clutch requests: "Binding interface?" AND THEN ASKS ME TO SPECIFY -what I do not know.

What am I missing?

Thanks ahead of time
hbwhite
Posts: 16
Joined: Tue Feb 27, 2018 10:55 pm

Re: Interface Binding on Mac (New App!)

Post by hbwhite »

Yes, Clutch needs to know the name of the interface (for example, "utun0"). The interface IP address may change, but the name will stay the same. Clutch will bind Transmission to the interface's IP address and will automatically re-bind it if the IP address changes (which may happen if your connection drops or your VPN IP address changes).

This way, no packets are leaked outside of your VPN connection, and Transmission continues to work when your IP address changes.

To find out the name of your interface, open the dropdown menu in Clutch and take note of the interface names (you may have to scroll down to see them all). Then connect to your VPN, close and re-open Clutch, and look at the dropdown menu again. A new interface should show up that wasn't there the first time. This new interface is the one you want to bind to. Select it in the menu, click "Bind Transmission to Interface," and Clutch will do the rest. Let me know if this helps!
tikilab
Posts: 1
Joined: Sat Jan 26, 2019 8:59 am

Re: Interface Binding on Mac (New App!)

Post by tikilab »

A new interface should show up that wasn't there the first time. This new interface is the one you want to bind to.
What if three new lines show up? They all have the same "en2" bit at the beginning. Does it matter which one I choose?
Marc31
Posts: 47
Joined: Thu Dec 06, 2007 12:01 am

Re: Interface Binding on Mac (New App!)

Post by Marc31 »

Not to rain on anyone’s parade, Transmission Interface Binder serves the purpose since virtually forever (apparently all to inconspicuously).
*∞ since 1984
rrossorr
Posts: 2
Joined: Tue Feb 19, 2019 11:28 pm

Re: Interface Binding on Mac (New App!)

Post by rrossorr »

Harrison, Thanks. I've been looking for this functionality for quite some time, I poke around every year or so to see if this was added to Transmission and saw your post ;-). Installed and working perfectly. @tikilab, The "en" interfaces are the builtin Mac network interfaces (in Terminal, Run "/usr/sbin/networksetup -listallhardwareports" to list them with a description). VPN interfaces usually start with "utun" and will be the one associated with a IP (in Terminal run "ifconfig") ... That's the one you want to choose in Clutch.

Again .. Thanks for the app
Richard
hbwhite
Posts: 16
Joined: Tue Feb 27, 2018 10:55 pm

Re: Interface Binding on Mac (New App!)

Post by hbwhite »

Clutch v1.2 is now available.

Version 1.2 adds support for Dark Mode in macOS Mojave and includes other improvements.
Last edited by hbwhite on Sun Feb 02, 2020 10:42 pm, edited 1 time in total.
hbwhite
Posts: 16
Joined: Tue Feb 27, 2018 10:55 pm

Re: Interface Binding on Mac (New App!)

Post by hbwhite »

Clutch v1.3 is now available!

This version automatically checks for updates and allows you to update Clutch automatically within the app!

• It also fixes the issue found by @davids: Clutch now restarts Transmission if your binding interface disappears and reappears without changing its IP. This fixes an issue where Transmission would fail to bind to your VPN if it started before the interface was online (this could happen on boot if Transmission opened before your VPN started)
Last edited by hbwhite on Sun Feb 02, 2020 10:42 pm, edited 1 time in total.
deltaman8
Posts: 4
Joined: Sat Feb 01, 2020 1:57 am

Re: Interface Binding on Mac (New App!)

Post by deltaman8 »

Hi,
thanks for your work!

A major problem though:
- I bound Transmission to my VPN (utun1) with your app.
- I started Transmission.
- I added a torrent.
- I set download and upload limits (for that specific torrent) and started it.
- Wait a few minutes while download and upload progresses.
- For testing purposes I changed the VPN server.
- Transmission immediately quit and reopened (as advertised).
- BUT: All progress of my torrent was gone, all download and upload limits were gone. It seemed like your app does a FORCE-QUIT on Transmission.

So basically: A change in my VPN server will cause me to loose all torrent progress?
Why aren't you giving Transmission time to save the torrent settings and resume information first? Why Force-Quit?

Unfortunately I can't use this.
hbwhite
Posts: 16
Joined: Tue Feb 27, 2018 10:55 pm

Re: Interface Binding on Mac (New App!)

Post by hbwhite »

Hi, the reason for the force quit is that quitting the app normally will cause Transmission to display a dialog that says "Are you sure you want to quit Transmission?" -- Clutch cannot automatically respond to this dialog, so it has to force quit and reopen the app. Other connection-binding scripts for Transmission also force-quit because of the dialog.

You can try saving your torrent settings by setting them first and quitting the app normally, then opening the app and using Clutch. However, it may be more convenient to set global torrent settings in the preferences.
deltaman8
Posts: 4
Joined: Sat Feb 01, 2020 1:57 am

Re: Interface Binding on Mac (New App!)

Post by deltaman8 »

Wow, that's a quick response ;-) *thumbs up*

Your app's main purpose is to manipulate the preferences file of Transmission.
You should also be able to manipulate the "CheckQuit" property in that very same preference file. (which - as you probably know - is responsible for that dialog)

At first startup your app could check, if "CheckQuit" ( = the dialog) is enabled, then inform the user that he can choose to let your app turn that dialog off. Because otherwise you are forced to force-quit Transmission. Which would lead to Data loss. Which is bad. So most users will agree to letting your app turning that dialog off.

Could that work?
deltaman8
Posts: 4
Joined: Sat Feb 01, 2020 1:57 am

Re: Interface Binding on Mac (New App!)

Post by deltaman8 »

Another possibility would be to have a small AppleScript that brings Transmission to the front and simulates first the keystroke of CMD+Q and then simulates the RETURN keystroke, which would deal with the dialog.
Post Reply