diff options
author | Ryan Wagoner <rsw686@pfsense.org> | 2006-11-08 00:10:59 +0000 |
---|---|---|
committer | Ryan Wagoner <rsw686@pfsense.org> | 2006-11-08 00:10:59 +0000 |
commit | 69044d0d66e8802c10644267846025f5b65ba924 (patch) | |
tree | 6742e42eca6b77b666914fe468b5eece0fdac81a /packages | |
parent | 71f0b203a0018e9c7cbb88e6adb0f1c445e580f9 (diff) | |
download | pfsense-packages-69044d0d66e8802c10644267846025f5b65ba924.tar.gz pfsense-packages-69044d0d66e8802c10644267846025f5b65ba924.tar.bz2 pfsense-packages-69044d0d66e8802c10644267846025f5b65ba924.zip |
miniupnpd version bump
Diffstat (limited to 'packages')
-rw-r--r-- | packages/miniupnpd/miniupnpd.inc | 83 | ||||
-rw-r--r-- | packages/miniupnpd/miniupnpd.xml | 23 | ||||
-rwxr-xr-x | packages/miniupnpd/sbin/miniupnpd | bin | 48497 -> 51450 bytes |
3 files changed, 96 insertions, 10 deletions
diff --git a/packages/miniupnpd/miniupnpd.inc b/packages/miniupnpd/miniupnpd.inc index 7eebefd4..b27516f0 100644 --- a/packages/miniupnpd/miniupnpd.inc +++ b/packages/miniupnpd/miniupnpd.inc @@ -2,10 +2,59 @@ require_once("config.inc"); require_once("functions.inc"); + /* Miniupnp */ + function upnp_notice ($msg) { syslog(LOG_NOTICE, "miniupnpd: $msg"); return; } function upnp_warn ($msg) { syslog(LOG_WARNING, "miniupnpd: $msg"); return; } + + function upnp_config ($name) { + global $config; + if($config['installedpackages']['miniupnpd']['config'][0]["{$name}"]) + return $config['installedpackages']['miniupnpd']['config'][0]["{$name}"]; + else + return NULL; + } + + function upnp_validate_ip($ip) { + $return = TRUE; + $tmp = explode(".", $ip); + if(count($tmp) != 4) + $return = FALSE; + else + foreach($tmp AS $sub) + if($return != FALSE) + if(!eregi("^([0-9])", $sub)) + $return = FALSE; + else + $return = TRUE; + return $return; + } + + function before_form_miniupnpd($pkg) { + global $config; + + /* if shaper connection speed defined hide fields */ + if($config['ezshaper']['step2']['download'] && $config['ezshaper']['step2']['upload']) { + $i=0; + foreach ($pkg['fields']['field'] as $field) { + if ($field['fieldname'] == 'download' || $field['fieldname'] == 'upload') + unset($pkg['fields']['field'][$i]); + $i++; + } + } + } + + function validate_form_miniupnpd($post, $input_errors) { + if($post['overridewanip'] && !upnp_validate_ip($post['overridewanip'])) + $input_errors[] = 'You must specify a valid ip address in the \'Override WAN address\' field'; + if(($post['download'] && !$post['upload']) || ($post['upload'] && !$post['download'])) + $input_errors[] = 'You must fill in both \'Maximum Download Speed\' and \'Maximum Upload Speed\' fields'; + if($post['download'] && $post['download']<=0) + $input_errors[] = 'You must specify a value greater than 0 in the \'Maximum Download Speed\' field'; + if($post['upload'] && $post['upload']<=0) + $input_errors[] = 'You must specify a value greater than 0 in the \'Maximum Upload Speed\' field'; + } - /* Miniupnp */ function sync_package_miniupnpd() { global $config; global $input_errors; @@ -17,15 +66,10 @@ conf_mount_rw(); config_lock(); - /* since config is written before this file invoked we don't need to read post data */ - if($config['installedpackages']['miniupnpd']['config'][0]['overridewanip']) - $overridewanip = $config['installedpackages']['miniupnpd']['config'][0]['overridewanip']; - if($config['installedpackages']['miniupnpd']['config'][0]['logpackets']) - $logpackets = $config['installedpackages']['miniupnpd']['config'][0]['logpackets']; - if($config['installedpackages']['miniupnpd']['config'][0]['iface_array']) - $iface_array = explode(",",$config['installedpackages']['miniupnpd']['config'][0]['iface_array']); + /* since config is written before this file invoked we don't need to read post data */ + $iface_array = explode(",",upnp_config("iface_array")); - if($iface_array) { + if($iface_array) { foreach($iface_array as $iface) { $if = convert_friendly_interface_to_real_interface_name($iface); /* above function returns iface if fail */ @@ -45,6 +89,19 @@ } if($ifaces_final) { + $overridewanip = upnp_config("overridewanip"); + $logpackets = upnp_config("logpackets"); + $sysuptime = upnp_config("sysuptime"); + + /* if shaper connection speed defined use those values */ + if($config['ezshaper']['step2']['download'] && $config['ezshaper']['step2']['upload']) { + $download = $config['ezshaper']['step2']['download']*1000; + $upload = $config['ezshaper']['step2']['upload']*1000; + } else { + $download = upnp_config("download")*1000; + $upload = upnp_config("upload")*1000; + } + /* valid paramters lets create rc file and start miniupnpd */ $start = "if [ `pgrep miniupnpd | wc -l` != 0 ]; then\n"; @@ -56,6 +113,10 @@ $start .= "fi\n"; $start .= "/usr/local/sbin/miniupnpd -p 2869{$ifaces_final}"; + /* define maximum downstream and upstream bitrates */ + if($download && $upload) + $start .= " -B {$download} {$upload}"; + /* override wan ip address, common for carp, etc */ if($overridewanip) $start .= " -o {$overridewanip}"; @@ -64,6 +125,10 @@ if($logpackets) $start .= " -L"; + /* enable system uptime instead of miniupnpd uptime */ + if($sysuptime) + $start .= " -U"; + $stop = "/usr/bin/killall miniupnpd \n"; $stop .= "# Clear existing rules and rdr entries \n"; $stop .= "/sbin/pfctl -aminiupnpd -Fr 2>&1 >/dev/null\n"; diff --git a/packages/miniupnpd/miniupnpd.xml b/packages/miniupnpd/miniupnpd.xml index dd0e6b4a..5fd0ef65 100644 --- a/packages/miniupnpd/miniupnpd.xml +++ b/packages/miniupnpd/miniupnpd.xml @@ -2,7 +2,7 @@ <packagegui> <title>Services: Miniupnpd</title> <name>miniupnpd</name> - <version>20061029</version> + <version>20061107</version> <savetext>Change</savetext> <include_file>/usr/local/pkg/miniupnpd.inc</include_file> <aftersaveredirect>status_upnp.php</aftersaveredirect> @@ -53,6 +53,16 @@ <type>interfaces_selection</type> </field> <field> + <fielddescr>Maximum Download Speed (Kbits/second)</fielddescr> + <fieldname>download</fieldname> + <type>input</type> + </field> + <field> + <fielddescr>Maximum Upload Speed (Kbits/second)</fielddescr> + <fieldname>upload</fieldname> + <type>input</type> + </field> + <field> <fielddescr>Override WAN address</fielddescr> <fieldname>overridewanip</fieldname> <type>input</type> @@ -62,7 +72,18 @@ <fieldname>logpackets</fieldname> <type>checkbox</type> </field> + <field> + <fielddescr>Use system uptime instead of miniupnpd uptime?</fielddescr> + <fieldname>sysuptime</fieldname> + <type>checkbox</type> + </field> </fields> + <custom_php_command_before_form> + before_form_miniupnpd(&$pkg); + </custom_php_command_before_form> + <custom_php_validation_command> + validate_form_miniupnpd($_POST, &$input_errors); + </custom_php_validation_command> <custom_php_resync_config_command> sync_package_miniupnpd(); </custom_php_resync_config_command> diff --git a/packages/miniupnpd/sbin/miniupnpd b/packages/miniupnpd/sbin/miniupnpd Binary files differindex 9bd4590f..a46fc116 100755 --- a/packages/miniupnpd/sbin/miniupnpd +++ b/packages/miniupnpd/sbin/miniupnpd |