Skip to content

Instantly share code, notes, and snippets.

@lg0
Created August 27, 2012 16:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lg0/3490009 to your computer and use it in GitHub Desktop.
Save lg0/3490009 to your computer and use it in GitHub Desktop.
Toggle VPN on/off and add/clean vpn routes
on vpnToggle(vpnName)
tell application "System Events"
tell current location of network preferences
set VPNservice to service vpnName
set isConnected to connected of current configuration of VPNservice
if isConnected then
disconnect VPNservice
do shell script "./ip-down" with administrator privileges
else
do shell script "./ip-up" with administrator privileges
connect VPNservice
end if
end tell
end tell
do shell script "dscacheutil -flushcache"
end vpnToggle
@yuanfeiz
Copy link

请教如果我只是把这两个文件cp到ppp下边,不每次执行ip-up/ip-down有什么影响么?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment