Sitemap
Jsonzhang

Jsonzhang

如今常存的有信,有望,有爱,这三样,其中最大的是爱 。-- 歌林多前書 13:13

Something about toggle proxy

2 min readApr 21, 2015

It origins from my working by my own macbook.

For safety , we should surf the Internet through a proxy in company, the proxy maybe looks like “proxy.xxx.com:8080”.

And in “ great” China , in order to visit every website like quote , twitter , I must use another proxy at home.

Something trouble was happening,when I toggle the proxy I have to click “network setting”,then “advance”,then “proxy setting”,then checked the “auto proxy”, and fill the input with a location of the pac file. I finished this repeated and boring work twice a day before I find some way to figure it out.

At the first time I chose workflow of Alfred to solve this problem. It is normal to work some repeated problem out by trying workflow.

Get Jsonzhang’s stories in your inbox

Join Medium for free to get updates from this writer.

1 . Active the “Workflow” tab on Alfred Preference and add a blank workflow by clicking the “+” button.

I used keyword to trigger the semi-automatic action of toggling proxy , and I programmed several pieces of applescript to set different proxies when I input different keywords.It looks like that:

tell application “GoAgentX” toggle proxy mode to standalone
end tell
do shell script “/usr/sbin/networksetup -setautoproxyurl ‘wi-fi’ ‘
http://txp-01.xxx.com/proxy.pac'" with administrator privileges
do shell script “/usr/local/bin/npm config set proxy
http://proxy.xxx.com:8080/" with administrator privileges
do shell script “/usr/sbin/networksetup -setwebproxystate ‘wi-fi’ on” with administrator privileges
do shell script “/usr/sbin/networksetup -setwebproxy ‘wi-fi’ web-proxy.oa.com 8080” with administrator privileges
display notification (“toggle success”)

I had completed the most of the toggling work automatic with program so far, which had satisfied me until I find a software named controlPlane.

ControlPlane(http://controlplaneapp.com) allows you to execute some action when it catches the signal from its listening. It can listen to the change of power , screen , network situation includes wifi , router , DNS and so on.

Now I can toggle my proxy setting totally automatic when I connect to different wifi no matter where I am.

more info about how to use control Plane : http://computers.tutsplus.com/tutorials/take-control-with-controlplane--cms-20516

--

--

Jsonzhang
Jsonzhang

Written by Jsonzhang

如今常存的有信,有望,有爱,这三样,其中最大的是爱 。-- 歌林多前書 13:13