diff options
Diffstat (limited to 'config/per-user-bandwidth-distribution.xml')
-rw-r--r-- | config/per-user-bandwidth-distribution.xml | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/config/per-user-bandwidth-distribution.xml b/config/per-user-bandwidth-distribution.xml new file mode 100644 index 00000000..08728380 --- /dev/null +++ b/config/per-user-bandwidth-distribution.xml @@ -0,0 +1,145 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> +<packagegui> + <copyright> + <![CDATA[ +/* $Id$ */ +/* ========================================================================== */ +/* + authng.xml + part of pfSense (http://www.pfSense.com) + Copyright (C) 2007 to whom it may belong + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + ]]> + </copyright> + <description>Describe your package here</description> + <requirements>Describe your package requirements here</requirements> + <faq>Currently there are no FAQ items provided.</faq> + <name>peruserbw</name> + <version>1.0.2</version> + <title>Services: Per User Bandwidth</title> + <aftersaveredirect>pkg_edit.php?xml=per-user-bandwidth-distribution.xml&id=0</aftersaveredirect> + <menu> + <name>PerUserBW</name> + <tooltiptext>Enforce a fair use bandwidth policy</tooltiptext> + <section>Services</section> + <url>pkg_edit.php?xml=per-user-bandwidth-distribution.xml&id=0</url> + </menu> + <service> + <name>PerUserBW</name> + <rcfile>per_user_bandwidth_distribution.sh</rcfile> + </service> + <fields> + <field> + <fielddescr>Incoming Bandwidth</fielddescr> + <fieldname>incoming_bandwidth</fieldname> + <description>Enter the bandwidth you would like to distribute fairly among the clients:</description> + <type>input</type> + </field> + <field> + <fielddescr>Incoming Bandwidth Type</fielddescr> + <fieldname>incoming_bandwidthtype</fieldname> + <type>select</type> + <options> + <option> + <name>Kbit/s</name> + <value>Kbit/s</value> + </option> + <option> + <name>Kbyte/s</name> + <value>Kbyte/s</value> + </option> + <option> + <name>Mbit/s</name> + <value>Mbit/s</value> + </option> + </options> + </field> + <field> + <fielddescr>Outgoing Bandwidth</fielddescr> + <fieldname>outgoing_bandwidth</fieldname> + <description>Enter the bandwidth you would like to distribute fairly among the clients:</description> + <type>input</type> + </field> + <field> + <fielddescr>Outgoing Bandwidth Type</fielddescr> + <fieldname>outgoing_bandwidthtype</fieldname> + <type>select</type> + <options> + <option> + <name>Kbit/s</name> + <value>Kbit/s</value> + </option> + <option> + <name>Kbyte/s</name> + <value>Kbyte/s</value> + </option> + <option> + <name>Mbit/s</name> + <value>Mbit/s</value> + </option> + </options> + </field> + </fields> + <custom_add_php_command> + conf_mount_rw(); + $wanif = get_real_wan_interface(); + $fd = fopen("/usr/local/etc/rc.d/per_user_bandwidth_distribution.sh","w"); + fwrite($fd, "# This file was automatically generated by the pfSense\n"); + fwrite($fd, "# package manager system\n\n"); + fwrite($fd, "/sbin/kldload ipfw\n"); + fwrite($fd, "/sbin/kldload dummynet\n"); + fwrite($fd, "/sbin/ipfw delete 10\n"); + fwrite($fd, "/sbin/ipfw pipe 101 config mask src-ip 0x000000ff bw {$_POST['incoming_bandwidth']}{$_POST['incoming_bandwidthtype']}\n"); + fwrite($fd, "/sbin/ipfw pipe 102 config mask dst-ip 0x000000ff bw {$_POST['outgoing_bandwidth']}{$_POST['outgoing_bandwidthtype']}\n"); + fwrite($fd, "/sbin/ipfw add 10 pipe 102 ip from any to any out via {$wanif}\n"); + fwrite($fd, "/sbin/ipfw add 10 pipe 101 ip from any to any in via {$wanif}\n"); + fwrite($fd, "/sbin/ipfw add 10 allow all from any to any\n"); + fclose($fd); + mwexec("chmod a+rx /usr/local/etc/rc.d/per_user_bandwidth_distribution.sh"); + mwexec_bg("/usr/local/etc/rc.d/per_user_bandwidth_distribution.sh"); + $config['system']['dummynetshaper'] = true; + write_config(); + conf_mount_ro(); + </custom_add_php_command> + <custom_php_deinstall_command> + mwexec("/sbin/ipfw delete 10"); + mwexec("/sbin/kldunload dummynet"); + mwexec("/sbin/kldunload ipfw"); + conf_mount_rw(); + unlink_if_exists("/usr/local/etc/rc.d/per_user_bandwidth_distribution.sh"); + unset($config['system']['dummynetshaper']); + write_config(); + conf_mount_ro(); + </custom_php_deinstall_command> +</packagegui>
\ No newline at end of file |