From 38d0994307d6e1fbc5a1c102930c85310408070a Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Thu, 9 Jul 2009 23:48:49 -0400 Subject: Define and use queue when available. Submitted-by: jim-p --- usr/local/pkg/miniupnpd.inc | 19 +++++++++++++++++++ usr/local/pkg/miniupnpd.xml | 5 +++++ 2 files changed, 24 insertions(+) (limited to 'usr/local/pkg') diff --git a/usr/local/pkg/miniupnpd.inc b/usr/local/pkg/miniupnpd.inc index 0d80700..344f404 100644 --- a/usr/local/pkg/miniupnpd.inc +++ b/usr/local/pkg/miniupnpd.inc @@ -30,6 +30,15 @@ return substr($uuid,0,8).'-'.substr($uuid,9,4).'-'.substr($uuid,13,4).'-'.substr($uuid,17,4).'-'.substr($uuid,21,12); } + function upnp_validate_queue($qname) { + global $config; + $qlist = array(); + foreach ($config['shaper']['queue'] as $q) { + $qlist[] = $q['name']; + } + return in_array($qname, $qlist); + } + function upnp_validate_ip($ip, $check_cdir) { /* validate cdir */ if($check_cdir) { @@ -90,6 +99,8 @@ $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'; + if($post['upnpqueue'] && !upnp_validate_queue($post['upnpqueue'])) + $input_errors[] = 'You must specify a valid traffic shaping queue.'; /* user permissions validation */ for($i=1; $i<=4; $i++) { @@ -208,6 +219,14 @@ if($upnp_config['permdefault']) $config_text .= "deny 0-65535 0.0.0.0/0 0-65535\n"; + /* Recheck if queue is valid */ + if (!upnp_validate_queue($upnp_config['upnpqueue'])) + unset($upnp_config['upnpqueue']); + + /* Add shaper queue */ + if($upnp_config['upnpqueue']) + $config_text .= "queue={$upnp_config['upnpqueue']}\n"; + /* write out the configuration */ upnp_write_config($config_file, $config_text); diff --git a/usr/local/pkg/miniupnpd.xml b/usr/local/pkg/miniupnpd.xml index dc3b057..23a0cdf 100644 --- a/usr/local/pkg/miniupnpd.xml +++ b/usr/local/pkg/miniupnpd.xml @@ -70,6 +70,11 @@ input + Traffic Shaping Queue + upnpqueue + input + + Log packets handled by UPnP rules? logpackets checkbox -- cgit v1.1