Dijhammond Posted April 16, 2010 Report Share Posted April 16, 2010 I have been looking for a solution for this but have not been able to find one as of yet. I connect to a VPN and then my torrent client starts. However, since i am using a campus network, my VPN frequently disconnects and earn torrent is running when my VPN isn't, it kind of defeats the purpose. I was wondering if there was a way to prevent torrent from connecting when my VPN is down or force all traffic through the VPN so that when it goes down, utorrent thinks its been disconnected form the internet. .Btw, all of this is done on a Mac mini used as a HTPC so I am not constantly monitoring the status foe the VPN connection and as a result I need an "automated" solution. Any help would be greatly appreciated. Thanks. Link to comment Share on other sites More sharing options...
mains.voltage Posted April 16, 2010 Report Share Posted April 16, 2010 I use an applescript to check the vpn, and activate it if it goes downon idle tell application "System Events" tell current location of network preferences set myConnection to the service "VPN" if current configuration of myConnection is not connected then connect myConnection end if end tell return 120 end tellend idleSave it as an application with the check box stay open, and then set it to start at login.VPN is the name of you vpn, and the 120 checks every 2 minutes. Link to comment Share on other sites More sharing options...
StevenMichaelSmith86 Posted July 17, 2010 Report Share Posted July 17, 2010 a Link to comment Share on other sites More sharing options...
sprocketeer Posted August 6, 2011 Report Share Posted August 6, 2011 I've posted a solution on my blog using Vuze (formerly Azureus) which is a terrible piece of bloatware, but highly configurable:http://continentalroast.blogspot.com/2011/08/macos-force-torrents-to-use-only-your.htmlIf you find a better way that does not require a script, let me know. Link to comment Share on other sites More sharing options...
Jack0817 Posted April 17, 2012 Report Share Posted April 17, 2012 Here is a script I've created that will get the job done until uTorrent (for Mac) can bind to a VPN service. SImply update the "Scrip Variables" section with your corresponding values, save the script AS AN APP, and add it to your Login Startup Items.The Gist: This script will monitor your VPN connection, if it detects it is no longer connected it will gracefully shutdown uTorrent (keeping all DL progress intact). Also, when the VPN is down, it will continue to try to re-establish a connection and upon successful re-connecting, it will then re-launch uTorrent to resume where it left off.Hope this helps!--------------------------------------------------Main Routine------------------------------------------------on idle --Script Variables set appName to "uTorrent" set vpnName to "IPredator" set waitTIme to 60 as integer --Main Script Logic if isVPNConnected(vpnName) then startApplication(appName) else stopApplication(appName) connectVPNConnection(vpnName) end if return waitTImeend idle--------------------------------------------------Sub Routine - Determines if specified vpn is connected------------------------------------------------on isVPNConnected(vpnName) --Init return value to default set isConnected to false tell application "System Events" tell current location of network preferences set vpnConnection to the service vpnName set isConnected to current configuration of vpnConnection is connected end tell end tell return isConnectedend isVPNConnected--------------------------------------------------Sub Routine - Attempts to connect to the specified VPN------------------------------------------------on connectVPNConnection(vpnName) tell application "System Events" tell current location of network preferences set vpnConnection to the service vpnName if vpnConnection is not null then connect vpnConnection end if end tell end tellend connectVPNConnection--------------------------------------------------Sub Routine - Starts an application if it is not already running------------------------------------------------on startApplication(appName) if appIsRunning(appName) is false then tell application appName to activate end ifend startApplication--------------------------------------------------Sub Routine - Stop an application if it is running------------------------------------------------on stopApplication(appName) if appIsRunning(appName) then tell application appName to quit end ifend stopApplication--------------------------------------------------Sub Routine - Determines if specified app is currently running------------------------------------------------on appIsRunning(appName) set isRunning to false tell application "System Events" set isRunning to (name of processes) contains appName end tell return isRunningend appIsRunning Link to comment Share on other sites More sharing options...
g3nius Posted May 6, 2012 Report Share Posted May 6, 2012 Hey so like the topic says I am working on a script that will stop all the transfers when my VPN goes down. Currently the program is set to quit (but this takes a while) This is not my code and was changed from https://forum.transmissionbt.com/viewtopic.php?f=4&t=12330&p=56986&hilit=script+to+quit+vpn#p56986on idle set activeInterfaces to do shell script "ifconfig -lu" if activeInterfaces = "lo0 en0 en1 fw0 utun0" then tell application "uTorrent" to quit tell application "Growl" notify with name ¬ "VPN Down" title ¬ "VPN Down" description ¬ "I have quit uTorrent." application name "Drop BitTorrent" end tell end if return 5 -- 30 is default value, but it doesn't hurt to include it hereend idleDoes any one know what command I could substitute for the line: ??tell application "uTorrent" to quitstop doesn't seem to work and I can't really guess. I also can't seem to find a key command to start/stop transfersAlso what would I add to reenable the transfers? something like:if activeInterfaces = "lo0 en0 en1 fw0 utun0 tun0"tell application "uTorrent" to start (or something to that effect)if activeInterfaces = "lo0 en0 en1 fw0 tun0 utun0"tell application "uTorrent" to start (or something to that effect) Link to comment Share on other sites More sharing options...
cl0r Posted May 25, 2012 Report Share Posted May 25, 2012 any good ways of testing whether the scripts are working?before relying on them completely, that is. Link to comment Share on other sites More sharing options...
g3nius Posted May 25, 2012 Report Share Posted May 25, 2012 any good ways of testing whether the scripts are working?before relying on them completely, that is.sure, pause torrents. disconnect vpn... see if the program quits. rinse repeat until satisfied Link to comment Share on other sites More sharing options...
g3nius Posted June 11, 2012 Report Share Posted June 11, 2012 this what I settled on, seems to work better and will not drop with a simple reordering of interface typeson idle set activeInterfaces to do shell script "ifconfig -lu" if activeInterfaces is "lo0 en0 en1 fw0 tun0 utun0" then return else if activeInterfaces is "lo0 en0 en1 fw0 utun0 tun0" then return else tell application "uTorrent" to quit tell application "Growl" notify with name ¬ "VPN Down" title ¬ "VPN Down" description ¬ "I have quit uTorrent." application name "Drop BitTorrent" end tell end if return 5 -- 30 is default value, but it doesn't hurt to include it hereend idle Link to comment Share on other sites More sharing options...
g3nius Posted August 26, 2012 Report Share Posted August 26, 2012 I recently upgraded my computer and because the interfaces list is different I modified the code above to this. Should produce more consistency.on idle set activeInterfaces to do shell script "ifconfig -lu" set activeInterfacesString to (activeInterfaces) as string set AppleScript's text item delimiters to " " set the activeInterfacesList to every text item of the activeInterfacesString set AppleScript's text item delimiters to "" if activeInterfacesList does not contain "tun0" then tell application "uTorrent" to quit tell application "Growl" notify with name ¬ "VPN Down" title ¬ "VPN Down" description ¬ "I have quit uTorrent." application name "Drop BitTorrent" end tell end if return 5 -- 30 is default value, but it doesn't hurt to include it hereend idle Link to comment Share on other sites More sharing options...
Alex-007- Posted October 16, 2012 Report Share Posted October 16, 2012 The answers are: VPN Lifeguard, VPNetMon, VPNCheck and others.Some good night reading on this subject here: http://torrentfreak.com/how-to-make-vpns-even-more-secure-120419/Enjoy.. ;-) Link to comment Share on other sites More sharing options...
g3nius Posted October 16, 2012 Report Share Posted October 16, 2012 The answers are: VPN Lifeguard, VPNetMon, VPNCheck and others.Some good night reading on this subject here: http://torrentfreak.com/how-to-make-vpns-even-more-secure-120419/Enjoy.. ;-) good solutions.... For windows users. Seeing that we are in the general (Mac) forum however these are not viable solutions... Link to comment Share on other sites More sharing options...
JunkBox Posted February 18, 2013 Report Share Posted February 18, 2013 Before: I left my computer downloading movies via uTorrent, and came home to find my vpn disconnected, uTorrent still running, and my IP being sprayed all over the place. After: The script first connects my vpn of choice and opens uTorrent. Then it repeats the following indefinitely: watches the Tunnelblick connection every 1 second. If it is connected, it just keeps checking every second until it detects a disconnect. Upon disconnect, it quits uTorrent, reconnects the vpn connection via tunnelblick, and restarts uTorrent. Please find the applescript below:tell application "Tunnelblick" connect "config" get state of first configuration where name = "config" repeat until result = "CONNECTED" delay 1 get state of first configuration where name = "config" end repeat if result = "connected" then run application "uTorrent"end tellrepeat tell application "Tunnelblick" get state of configuration 1 whose name = "config" if result = "connected" then repeat until result = "exiting" delay 1 get state of configuration 1 whose name = "config" end repeat if result = "exiting" then quit application "uTorrent" tell application "Tunnelblick" connect "config" get state of first configuration where name = "config" repeat until result = "CONNECTED" delay 1 get state of first configuration where name = "config" end repeat run application "uTorrent" end tell end tellend repeat"config" is replaced with my vpn of choice as it appears in the tunnelblick drop down menu. I was so excited that it worked, I had to share it.You should be able to copy the script into applescript editor and just replace that which does not apply to your set up with the relevant info. Link to comment Share on other sites More sharing options...
steiney Posted March 14, 2013 Report Share Posted March 14, 2013 JunkBox,I just started using a VPN, and although I'm pretty proficient with OS X, AppleScript is a skill that I lack. Would you be so kind as to tell me which parts of that code need to be switched out, as you mentioned?I'm using tunnelblick and uTorrent on 10.6.8. I can't see anything else in the code that stands out as something that would need to be changed.Thanks in advance for helping out a noob!steiney Link to comment Share on other sites More sharing options...
lukekjones Posted April 1, 2013 Report Share Posted April 1, 2013 Sorry to bump an old post to the top but another answer to only torrenting while your vpn is active is detailed here:http://superuser.com/questions/468919/prevent-outgoing-traffic-unless-openvpn-connection-is-active-using-pf-conf-on-maI have set it up and tested it with positive results. Link to comment Share on other sites More sharing options...
alastairandrew Posted April 11, 2013 Report Share Posted April 11, 2013 I have been looking for a solution for this but have not been able to find one as of yet. I connect to a VPN and then my torrent client starts. However, since i am using a campus network, my VPN frequently disconnects and earn torrent is running when my VPN isn't, it kind of defeats the purpose. I was wondering if there was a way to prevent torrent from connecting when my VPN is down or force all traffic through the VPN so that when it goes down, utorrent thinks its been disconnected form the internet. .Btw, all of this is done on a Mac mini used as a HTPC so I am not constantly monitoring the status foe the VPN connection and as a result I need an "automated" solution. Any help would be greatly appreciated. Thanks.I have tried a few VPN provider before and i would say Torguard VPN is the most stable to use since they have quite a number of server location worldwide.But the package is quite pricey compared to other VPN provider.Here is the list of Best P2P and top Torrent VPN Service Providers that help you to download via torrent and share p2p files anonymously. Now you can Access to any Internet resource without restrictions and bandwidth limitation safe, secure and fast with Torrent VPN accounts. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.