Viscosity/Transmission Port Forwarding Applescript on Mac OS 10.12

@MacAir said:
@moo
1) (If you haven't done this already... also do this once and once only as it won't open the ports with a different clientID) open terminal and copy/paste the following and press enter:

head -n 100 /dev/urandom | md5 > ~/.pia_WHATEVERyouWANTtoNAMEthis

2) Open AppleScript Editor. Only replace what is highlighted. Copy/Paste exactly as it is written only replacing w/the variables above. Also, I don't think you can put special characters like & and ! in you PW, change your PW if that's true(not sure).

set Username to "USERNAME"
set PW to "PASSWORD"

set vpn_ip to do shell script "ifconfig tun0 | grep inet | awk '{print $2}'" # get current ip of vpn interface

set vpn_port to do shell script "curl -d \"user=" & Username & "&pass=" & PW & "&client_id=$(cat ~/.pia_IDname)&local_ip=" & vpn_ip & "\" https://www.privateinternetaccess.com/vpninfo/port_forward_assignment 2>/dev/null|grep -oE \"[0-9]+\""

do shell script "defaults delete org.m0k.transmission BindPort" # delete previous port value

do shell script "defaults write org.m0k.transmission BindPort " & vpn_port & ""

do shell script "defaults delete org.m0k.transmission BindAddressIPv4" #delete previously written ipv4binding value

do shell script "defaults write org.m0k.transmission BindAddressIPv4 " & vpn_ip & "" #write current vpn ip into transmission.plistUsername

3a)If the end result isn't """ and you still have errors. Open Terminal and copy/paste/enter this:

defaults write org.m0k.transmission BindPort "45678"

3b) More copy/pasta:

defaults write org.m0k.transmission BindAddressIPv4 "192.168.0.123"

4) Run the script from Step 2 again. you shouldn't get the 'error "The command exited with a non-zero status." number 1'. you should be good at this point

5) if you get get something along the lines of Domain (org.m0k.transmission) could not be found; do an application Reset aka delete the following file/folders:

a. ~/Library/Caches/org.m0k.transmission
b. ~/Library/Saved Application State/org.m0k.transmission.savedState
c. ~/Library/Preferences/org.m0k.transmission.plist
d. ~/Library/Preferences/org.m0k.transmission.LSSharedFileList.plist

6) Open Transmission then quit Transmission and follow steps 2-3a+b. If it still shows an error then there's probably a typo or too many spaces. I've tested myself copy/pasting from the format it displays when I submit this and it works perfectly if you only replace what's highlighted, nothing more and nothing less.

7) This is how you set it up to run though Viscosity after the connection to the VPN has been made. image
 
8) After you click save make sure transmission is not running and disconnect and reconnect to the PIA server you just modified.
Has anyone been able to get this to work on Mac OS Sierra/Transmission/Viscosity? I always get an error, so I had to revert back to El Capitan.

Comments

Sign In or Register to comment.