diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/per-user-bandwidth-distribution.xml | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/packages/per-user-bandwidth-distribution.xml b/packages/per-user-bandwidth-distribution.xml new file mode 100644 index 00000000..c58c8b00 --- /dev/null +++ b/packages/per-user-bandwidth-distribution.xml @@ -0,0 +1,55 @@ +<packagegui> + <name>per-user-bandwidth-distribution</name> + <version>1.0.1</version> + <title>Services: Per User Bandwidth</title> + <aftersaveredirect>pkg_edit.php?xml=per-user-bandwidth-distribution.xml&id=0</aftersaveredirect> + <menu> + <name>Per User Bandwidth</name> + <tooltiptext>Enforce a fair use bandwidth policy</tooltiptext> + <section>Services</section> + <configfile>per-user-bandwidth-distribution.xml</configfile> + </menu> + <service> + <name>PerUserBandwidth</name> + <rcfile>per_user_bandwidth_distribution.sh</rcfile> + </service> + <configpath>installedpackages->package->$packagename->configuration->settings</configpath> + <fields> + <field> + <fielddescr>Bandwidth</fielddescr> + <fieldname>bandwidth</fieldname> + <description>Enter the bandwidth you would like to distribute:</description> + <type>input</type> + </field> + <field> + <fielddescr>Bandwidth Type</fielddescr> + <fieldname>bandwidthtype</fieldname> + <type>select</type> + <options> + <option> + <value>Byte/s</value> + <name>Byte/s</name> + </option> + <option> + <value>KByte/s</value> + <name>KByte/s</name> + </option> + <option> + <value>MByte/s</value> + <name>MByte/s</name> + </option> + </options> + </field> + </fields> + <custom_add_php_command> + $fd = fopen("/usr/local/etc/rc.d/per_user_bandwidth_distribution.sh","w"); + fwrite($fd, "/sbin/kldload dummynet"); + fwrite($fd, "/sbin/ipfw add 10 pipe 1 ip from any to any out via {$wanif}"); + fwrite($fd, "/sbin/ipfw add 10 pipe 2 ip from any to any in via {$wanif}"); + fwrite($fd, "/sbin/ipfw add allow all from any to any"); + fwrite($fd, "/sbin/ipfw pipe 1 config mask src-ip 0x000000ff bw {$_POST['bandwidth']}{$_POST['bandwidthtype']}"); + fwrite($fd, "/sbin/ipfw pipe 2 config mask dst-ip 0x000000ff bw {$_POST['bandwidth']}{$_POST['bandwidthtype']}"); + fclose($fd); + mwexec("chmod a+rx /usr/local/etc/rc.d/per_user_bandwidth_distribution.sh"); + </custom_add_php_command> +</packagegui> |