Skip to content

Instantly share code, notes, and snippets.

@madssj
Created June 6, 2013 08:15
Show Gist options
  • Save madssj/5720068 to your computer and use it in GitHub Desktop.
Save madssj/5720068 to your computer and use it in GitHub Desktop.
property FLUSH_TEXT : "Quit and flush"
property SET_TEXT : "Set speed"
-- be damn carefull what you input here, it will run as root
on ipfwLimit(bandwidth)
my ipfwFlush()
do shell script "ipfw pipe 1 config bw " & bandwidth & "KB" with administrator privileges
do shell script "ipfw add 10 pipe 1 tcp from any 80 to me" with administrator privileges
do shell script "ipfw add 11 pipe 1 tcp from me to any 80" with administrator privileges
end ipfwLimit
-- flush any ipfw rules
on ipfwFlush()
do shell script "ipfw -f flush" with administrator privileges
end ipfwFlush
on main()
set question to display dialog "Control your http traffic speed" buttons {FLUSH_TEXT, SET_TEXT} default button 2
set answer to button returned of question
if answer is equal to FLUSH_TEXT then
my ipfwFlush()
end if
if answer is equal to SET_TEXT then
set bandwidth_question to display dialog "Enter bandwidth in KB/s (don't do something stupid like entering "; rm -rf /)" default answer "56"
set bandwidth to text returned of bandwidth_question
my ipfwLimit(bandwidth)
my main()
end if
end main
my main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment