Page 1 of 1

Port Forwarding with Viscosity + PIA

Posted: Fri Apr 27, 2018 2:42 pm
by beatstreet
Greetings. I’m running PIA through Viscosity and want to have port forwarding enabled to help my torrent client, Transmission, seed more effectively.

Here’s what I’ve been able to do (with admittedly little understanding of what I’m doing).

1. In Viscosity I’m running PIA’s Toronto connection, which allows port forwarding
2. I downloaded the port forwarding shell script from PIA
2. I ran the command line in my terminal: chmod u+x /Users/iMac/Desktop/port_forwarding.sh
3. I opened Script Editor and ran the line I was instructed by Viscosity to enter: do shell script "/Users/iMac/Desktop/port_forwarding.sh"

The result I get in Script Editor is:

"Loading port forward assignment information...
{\"port\":23422}"

I’m psyched to have gotten this far. With the port number, I can go into Transmission, enter 23422 into the Peer listening port, and I see the Port is open.

The next step, however, is to get this running more seamlessly in Viscosity. What I like about Viscosity is that it’s way more stable than PIA’s client. It’s a real plug and play. It comes on automatically and my browsers work great with it (not always the case with PIA’s client).

But, the functionality of Viscosity will be seriously limited if each time I start my computer and Viscosity loads I have to run the Script Editor to connect to port forwarding and find the peer listing number, then enter it into Transmission anew.

So, here're my questions.

1. How do I set up Viscosity to interact with this script so that it loads automatically?
2. What's the most efficient way to get Transmission to play well with the port forwarding number?

I see that under the connection in the Advanced tab I can point the app to “Before Connect Script” or “Connected Script.” I’m assuming I could use one of these to point to the script I saved in Script Editor.

But, I'm not sure how to get this set up. And I’m not sure how to locate to find the port number if it's set up to connect to port forwarding automatically.

Any advice would be great.

Re: Port Forwarding with Viscosity + PIA

Posted: Tue May 01, 2018 2:59 pm
by James
Hi beatstreet,
1. How do I set up Viscosity to interact with this script so that it loads automatically?
You'll want to set your script as a Connected script. When making changes to your original script be sure to Clear and Set the Connected script again (Viscosity maintains its own copy, as so changes to the original won't be used without setting it again).

2. What's the most efficient way to get Transmission to play well with the port forwarding number?
I'm afraid I'm not familiar enough with Transmission's AppleScript support to offer any firm suggestions, however typically what you'll want to do is have your AppleScript script parse the port number output from the shell script to get the port number (in the example above this is 23422), and then tell Transmission to use this as the port number for incoming connections.

I recommend checking with Transmission's developers to see if it has an AppleScript command for setting the port number. If not, you could probably try running a shell script like:
Code: Select all
defaults write org.m0k.transmission BindPort 12345
Where 12345 is replaced with the port number output from your port forwarding script.

Cheers,
James