1 |
21d40ff9
|
Ermal Lu?i
|
<?php
|
2 |
|
|
/* $Id$ */
|
3 |
|
|
/*
|
4 |
|
|
firewall_shaper_layer7.php
|
5 |
1d7ba683
|
ayvis
|
Copyright (C) 2008 Helder Pereira, André Ribeiro
|
6 |
6317d31d
|
Phil Davis
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
7 |
21d40ff9
|
Ermal Lu?i
|
All rights reserved.
|
8 |
|
|
|
9 |
|
|
Redistribution and use in source and binary forms, with or without
|
10 |
|
|
modification, are permitted provided that the following conditions are met:
|
11 |
|
|
|
12 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
13 |
|
|
this list of conditions and the following disclaimer.
|
14 |
|
|
|
15 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
16 |
|
|
notice, this list of conditions and the following disclaimer in the
|
17 |
|
|
documentation and/or other materials provided with the distribution.
|
18 |
|
|
|
19 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
20 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
21 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
22 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
23 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
29 |
|
|
*/
|
30 |
|
|
/*
|
31 |
|
|
pfSense_BUILDER_BINARIES: /usr/bin/killall
|
32 |
|
|
pfSense_MODULE: shaper
|
33 |
|
|
*/
|
34 |
|
|
|
35 |
|
|
##|+PRIV
|
36 |
|
|
##|*IDENT=page-firewall-trafficshaper-layer7
|
37 |
|
|
##|*NAME=Firewall: Traffic Shaper: Layer7 page
|
38 |
|
|
##|*DESCR=Allow access to the 'Firewall: Traffic Shaper: Layer7' page.
|
39 |
|
|
##|*MATCH=firewall_shaper_layer7.php*
|
40 |
|
|
##|-PRIV
|
41 |
|
|
|
42 |
|
|
require("guiconfig.inc");
|
43 |
7a927e67
|
Scott Ullrich
|
require_once("functions.inc");
|
44 |
|
|
require_once("filter.inc");
|
45 |
|
|
require_once("shaper.inc");
|
46 |
21d40ff9
|
Ermal Lu?i
|
|
47 |
|
|
// Variables protocols (dynamic) and structures (static)
|
48 |
|
|
$avail_protos =& generate_protocols_array();
|
49 |
|
|
$avail_structures = array("action","queue","limiter");
|
50 |
|
|
|
51 |
|
|
// Available behaviours
|
52 |
|
|
$avail_behaviours_action = array("block");
|
53 |
|
|
read_altq_config();
|
54 |
|
|
$avail_behaviours_altq = get_altq_name_list();
|
55 |
|
|
read_dummynet_config();
|
56 |
|
|
$avail_behaviours_limiter = get_dummynet_name_list();
|
57 |
|
|
$show_proto_form = false;
|
58 |
|
|
|
59 |
|
|
//More variables
|
60 |
bb78a6fe
|
Vinicius Coque
|
$pgtitle = array(gettext("Firewall"),gettext("Traffic Shaper"), gettext("Layer7"));
|
61 |
b32dd0a6
|
jim-p
|
$shortcut_section = "trafficshaper";
|
62 |
21d40ff9
|
Ermal Lu?i
|
|
63 |
|
|
$output_form = "";
|
64 |
|
|
|
65 |
|
|
$default_layer7shaper_msg = "<tr><td colspan=\"4\">";
|
66 |
1d7ba683
|
ayvis
|
$default_layer7shaper_msg .= "<span class=\"vexpl\"><span class=\"red\"><strong>" . gettext("Note") . ":<br />";
|
67 |
|
|
$default_layer7shaper_msg .= "</strong></span>" . gettext("You can add new layer7 protocol patterns by simply uploading the file") . " <a href=\"diag_patterns.php\">" . gettext("here") . ".</a></span><br />";
|
68 |
21d40ff9
|
Ermal Lu?i
|
$default_layer7shaper_msg .= "</td></tr>";
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
read_layer7_config();
|
72 |
|
|
|
73 |
|
|
if($_GET['reset'] <> "") {
|
74 |
|
|
// kill all ipfw-classifyd processes
|
75 |
b11cdf92
|
Renato Botelho
|
mwexec("killall -9 ipfw-classifyd");
|
76 |
21d40ff9
|
Ermal Lu?i
|
exit;
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
if ($_GET) {
|
80 |
|
|
if ($_GET['container'])
|
81 |
dd5bf424
|
Scott Ullrich
|
$name = htmlspecialchars(trim($_GET['container']));
|
82 |
21d40ff9
|
Ermal Lu?i
|
if ($_GET['action'])
|
83 |
dd5bf424
|
Scott Ullrich
|
$action = htmlspecialchars($_GET['action']);
|
84 |
21d40ff9
|
Ermal Lu?i
|
}
|
85 |
|
|
|
86 |
|
|
if($_POST) {
|
87 |
|
|
if ($_POST['container']) {
|
88 |
dd5bf424
|
Scott Ullrich
|
$name = htmlspecialchars(trim($_POST['container']));
|
89 |
21d40ff9
|
Ermal Lu?i
|
}
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
if ($name) {
|
93 |
|
|
//Get the object from the 7rules list
|
94 |
|
|
$container = $layer7_rules_list[$name];
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
if ($_GET) {
|
98 |
|
|
switch ($action) {
|
99 |
|
|
case "add":
|
100 |
|
|
$show_proto_form = true;
|
101 |
|
|
$container = new layer7();
|
102 |
|
|
$output_form .= $container->build_form(); //constructs the graphical interface on the right side
|
103 |
|
|
unset($container);
|
104 |
|
|
break;
|
105 |
|
|
case "show":
|
106 |
|
|
$show_proto_form = true;
|
107 |
|
|
if($container) {
|
108 |
|
|
$output_form .= $container->build_form();
|
109 |
|
|
}
|
110 |
|
|
else {
|
111 |
|
|
$show_proto_form = false;
|
112 |
813a3ef6
|
Neriberto C.Prado
|
$input_errors[] = gettext("Layer7 Rules Container not found!");
|
113 |
21d40ff9
|
Ermal Lu?i
|
}
|
114 |
|
|
break;
|
115 |
|
|
default:
|
116 |
|
|
echo log_error("Get default");
|
117 |
|
|
$show_proto_form = false;
|
118 |
e573ee95
|
Colin Fleming
|
$output_form .= $dn_default_shaper_msg . $default_layer7shaper_msg;
|
119 |
21d40ff9
|
Ermal Lu?i
|
break;
|
120 |
|
|
}
|
121 |
|
|
}
|
122 |
|
|
|
123 |
|
|
//add a new l7rules container
|
124 |
|
|
else if ($_POST) {
|
125 |
|
|
$show_proto_form = true;
|
126 |
|
|
unset($input_errors);
|
127 |
b11cdf92
|
Renato Botelho
|
|
128 |
21d40ff9
|
Ermal Lu?i
|
if($_POST['submit']) {
|
129 |
51b14faa
|
Ermal Lu?i
|
if (isset($layer7_rules_list[$name])) {
|
130 |
|
|
$l7r = $layer7_rules_list[$name];
|
131 |
|
|
$_POST['divert_port'] = $l7r->GetRPort();
|
132 |
|
|
} else {
|
133 |
0515117e
|
Chris Buechler
|
$l7r =& new layer7();
|
134 |
51b14faa
|
Ermal Lu?i
|
$_POST['divert_port'] = $l7r->gen_divert_port();
|
135 |
|
|
}
|
136 |
21d40ff9
|
Ermal Lu?i
|
for($i=0; $_POST['protocol'][$i] <> ""; $i++) {
|
137 |
|
|
$_POST['l7rules'][$i]['protocol'] = $_POST['protocol'][$i];
|
138 |
|
|
$_POST['l7rules'][$i]['structure'] = $_POST['structure'][$i];
|
139 |
|
|
$_POST['l7rules'][$i]['behaviour'] = $_POST['behaviour'][$i];
|
140 |
|
|
}
|
141 |
ea51e9f8
|
Renato Botelho
|
$l7r->validate_input($_POST,$input_errors);
|
142 |
21d40ff9
|
Ermal Lu?i
|
$l7r->ReadConfig($_POST['container'], $_POST);
|
143 |
|
|
//Before writing the results, we need to test for repeated protocols
|
144 |
|
|
$non_dupes = array();
|
145 |
|
|
$dupes = array();
|
146 |
|
|
for($j=0; $j<$i; $j++) {
|
147 |
|
|
if(!$non_dupes[$_POST['protocol'][$j]])
|
148 |
|
|
$non_dupes[$_POST['protocol'][$j]] = true;
|
149 |
|
|
else
|
150 |
|
|
$dupes[] = $_POST['protocol'][$j];
|
151 |
|
|
}
|
152 |
|
|
unset($non_dupes);
|
153 |
|
|
if(sizeof($dupes) == 0 && !$input_errors) {
|
154 |
|
|
$l7r->wconfig();
|
155 |
3a343d73
|
jim-p
|
if (write_config())
|
156 |
|
|
mark_subsystem_dirty('shaper');
|
157 |
21d40ff9
|
Ermal Lu?i
|
|
158 |
|
|
read_layer7_config();
|
159 |
|
|
}
|
160 |
|
|
else {
|
161 |
|
|
if(sizeof($dupes) > 0) {
|
162 |
bb78a6fe
|
Vinicius Coque
|
$dupe_error = gettext("Found the following repeated protocol definitions") . ": ";
|
163 |
21d40ff9
|
Ermal Lu?i
|
foreach($dupes as $dupe)
|
164 |
|
|
$dupe_error .= "$dupe ";
|
165 |
|
|
$input_errors[] .= $dupe_error;
|
166 |
|
|
}
|
167 |
|
|
}
|
168 |
|
|
unset($dupes);
|
169 |
|
|
unset($dupe_error);
|
170 |
b450c94e
|
jim-p
|
//Even if there are repeated protocols, we won't lose any previous values
|
171 |
21d40ff9
|
Ermal Lu?i
|
//The user will be able to solve the situation
|
172 |
|
|
$output_form .= $l7r->build_form();
|
173 |
|
|
//Necessary to correctly build the proto form
|
174 |
|
|
$container = $layer7_rules_list[$name];
|
175 |
|
|
if($input_errors)
|
176 |
|
|
$container =& $l7r;
|
177 |
|
|
} else if($_POST['apply']) {
|
178 |
|
|
write_config();
|
179 |
|
|
|
180 |
|
|
$retval = 0;
|
181 |
|
|
$retval = filter_configure();
|
182 |
|
|
$savemsg = get_std_save_message($retval);
|
183 |
|
|
|
184 |
|
|
if(stristr($retval, "error") <> true)
|
185 |
|
|
$savemsg = get_std_save_message($retval);
|
186 |
|
|
else
|
187 |
|
|
$savemsg = $retval;
|
188 |
|
|
|
189 |
|
|
clear_subsystem_dirty('shaper');
|
190 |
|
|
|
191 |
|
|
if($container) {
|
192 |
|
|
$output_form .= $container->build_form();
|
193 |
|
|
} else {
|
194 |
|
|
$show_proto_form = false;
|
195 |
e573ee95
|
Colin Fleming
|
$output_form .= $dn_default_shaper_msg . $default_layer7shaper_msg;
|
196 |
21d40ff9
|
Ermal Lu?i
|
}
|
197 |
|
|
} else if ($_POST['delete']) {
|
198 |
|
|
$container->delete_l7c();
|
199 |
3a343d73
|
jim-p
|
if (write_config())
|
200 |
|
|
mark_subsystem_dirty('shaper');
|
201 |
21d40ff9
|
Ermal Lu?i
|
unset($container);
|
202 |
b11cdf92
|
Renato Botelho
|
|
203 |
21d40ff9
|
Ermal Lu?i
|
header("Location: firewall_shaper_layer7.php");
|
204 |
|
|
exit;
|
205 |
|
|
}
|
206 |
|
|
else {
|
207 |
|
|
$show_proto_form = false;
|
208 |
|
|
}
|
209 |
|
|
}
|
210 |
|
|
else {
|
211 |
|
|
$show_proto_form = false;
|
212 |
e573ee95
|
Colin Fleming
|
$output_form .= $dn_default_shaper_msg . $default_layer7shaper_msg;
|
213 |
21d40ff9
|
Ermal Lu?i
|
}
|
214 |
|
|
|
215 |
|
|
// Builds the left tree
|
216 |
|
|
$tree = "<ul class=\"tree\" >";
|
217 |
|
|
if (is_array($layer7_rules_list)) {
|
218 |
|
|
foreach ($layer7_rules_list as $tmpl7) {
|
219 |
|
|
$tree .= $tmpl7->build_tree();
|
220 |
|
|
}
|
221 |
|
|
}
|
222 |
|
|
$tree .= "</ul>";
|
223 |
|
|
|
224 |
e573ee95
|
Colin Fleming
|
$output = "<table summary=\"output form\">";
|
225 |
21d40ff9
|
Ermal Lu?i
|
$output .= $output_form;
|
226 |
e750c0af
|
Colin Fleming
|
$closehead = false;
|
227 |
21d40ff9
|
Ermal Lu?i
|
include("head.inc");
|
228 |
|
|
?>
|
229 |
|
|
<link rel="stylesheet" type="text/css" media="all" href="./tree/tree.css" />
|
230 |
|
|
<script type="text/javascript" src="./tree/tree.js"></script>
|
231 |
b11cdf92
|
Renato Botelho
|
|
232 |
e750c0af
|
Colin Fleming
|
<script type="text/javascript">
|
233 |
|
|
//<![CDATA[
|
234 |
21d40ff9
|
Ermal Lu?i
|
var initial_count = new Array();
|
235 |
|
|
var rows_limit = 0; // Set to 0 to disable limitation
|
236 |
|
|
|
237 |
|
|
|
238 |
|
|
/* Build the behaviours arrays in javascript */
|
239 |
|
|
var js_behaviours_action = ['block']; //static
|
240 |
|
|
|
241 |
|
|
var js_behaviours_altq = new Array();
|
242 |
|
|
js_behaviours_altq = array_altq(js_behaviours_altq);
|
243 |
|
|
|
244 |
|
|
var js_behaviours_limiter = new Array();
|
245 |
|
|
js_behaviours_limiter = array_limiter(js_behaviours_limiter);
|
246 |
|
|
|
247 |
|
|
function array_altq(a_behav) {
|
248 |
|
|
var index;
|
249 |
b11cdf92
|
Renato Botelho
|
<?php if (!empty($avail_behaviours_altq)) {
|
250 |
21d40ff9
|
Ermal Lu?i
|
foreach ($avail_behaviours_altq as $key => $queue) { ?>
|
251 |
|
|
name = "<?= $queue; ?>";
|
252 |
b11cdf92
|
Renato Botelho
|
index = <?= $key; ?>;
|
253 |
21d40ff9
|
Ermal Lu?i
|
a_behav[index] = name;
|
254 |
b11cdf92
|
Renato Botelho
|
<?php }
|
255 |
21d40ff9
|
Ermal Lu?i
|
} ?>
|
256 |
|
|
return a_behav;
|
257 |
|
|
}
|
258 |
|
|
|
259 |
|
|
function array_limiter(a_behav) {
|
260 |
|
|
var index;
|
261 |
b11cdf92
|
Renato Botelho
|
<?php if (!empty($avail_behaviours_limiter)) {
|
262 |
21d40ff9
|
Ermal Lu?i
|
foreach ($avail_behaviours_limiter as $key => $limiter) { ?>
|
263 |
|
|
name = "<?= $limiter; ?>";
|
264 |
b11cdf92
|
Renato Botelho
|
index = <?= $key; ?>;
|
265 |
21d40ff9
|
Ermal Lu?i
|
a_behav[index] = name;
|
266 |
b11cdf92
|
Renato Botelho
|
<?php }
|
267 |
21d40ff9
|
Ermal Lu?i
|
} ?>
|
268 |
|
|
return a_behav;
|
269 |
|
|
}
|
270 |
|
|
|
271 |
|
|
/* Fill the variables with available protocols, structures and behaviours */
|
272 |
|
|
function fillProtocol() {
|
273 |
e573ee95
|
Colin Fleming
|
var protocol = '<select name="protocol[]" style="font-size:8pt">';
|
274 |
21d40ff9
|
Ermal Lu?i
|
var name;
|
275 |
|
|
|
276 |
b11cdf92
|
Renato Botelho
|
<?php foreach ($avail_protos as $key => $proto) { ?>
|
277 |
21d40ff9
|
Ermal Lu?i
|
name = "<?= $proto; ?>";
|
278 |
e573ee95
|
Colin Fleming
|
protocol += "<option value=" + name + ">" + name + "<\/option>";
|
279 |
b11cdf92
|
Renato Botelho
|
<?php } ?>
|
280 |
e573ee95
|
Colin Fleming
|
protocol += "<\/select>";
|
281 |
b11cdf92
|
Renato Botelho
|
|
282 |
21d40ff9
|
Ermal Lu?i
|
return protocol;
|
283 |
|
|
}
|
284 |
|
|
|
285 |
|
|
function fillStructure() {
|
286 |
e573ee95
|
Colin Fleming
|
var structure = '<select name="structure[]" style="font-size:8pt" onchange="changeBehaviourValues(this.parentNode.parentNode);">';
|
287 |
21d40ff9
|
Ermal Lu?i
|
var name;
|
288 |
b11cdf92
|
Renato Botelho
|
<?php foreach ($avail_structures as $key => $struct) { ?>
|
289 |
21d40ff9
|
Ermal Lu?i
|
name = "<?= $struct; ?>";
|
290 |
|
|
if(name == "queue") {
|
291 |
e573ee95
|
Colin Fleming
|
if(js_behaviours_altq != "") { structure += "<option value=" + name + ">" + name + "<\/option>";}
|
292 |
21d40ff9
|
Ermal Lu?i
|
}
|
293 |
|
|
else {
|
294 |
|
|
if(name == "limiter") {
|
295 |
e573ee95
|
Colin Fleming
|
if(js_behaviours_limiter != "") { structure += "<option value=" + name + ">" + name + "<\/option>";}
|
296 |
21d40ff9
|
Ermal Lu?i
|
}
|
297 |
e573ee95
|
Colin Fleming
|
else structure += "<option value=" + name + ">" + name + "<\/option>"; //action
|
298 |
b11cdf92
|
Renato Botelho
|
}
|
299 |
|
|
<?php } ?>
|
300 |
e573ee95
|
Colin Fleming
|
structure += "<\/select>";
|
301 |
b11cdf92
|
Renato Botelho
|
|
302 |
21d40ff9
|
Ermal Lu?i
|
return structure;
|
303 |
|
|
}
|
304 |
b11cdf92
|
Renato Botelho
|
|
305 |
21d40ff9
|
Ermal Lu?i
|
//Used by default to fill the values when inserting a new row.
|
306 |
|
|
function fillBehaviour() {
|
307 |
e573ee95
|
Colin Fleming
|
var behaviour = '<select name="behaviour[]" style="width:80px; font-size:8pt">';
|
308 |
21d40ff9
|
Ermal Lu?i
|
var name;
|
309 |
b11cdf92
|
Renato Botelho
|
<?php foreach ($avail_behaviours_action as $key => $behav) { ?>
|
310 |
21d40ff9
|
Ermal Lu?i
|
name = "<?= $behav; ?>";
|
311 |
e573ee95
|
Colin Fleming
|
behaviour += "<option value=" + name + ">" + name + "<\/option>";
|
312 |
b11cdf92
|
Renato Botelho
|
<?php } ?>
|
313 |
e573ee95
|
Colin Fleming
|
behaviour += "<\/select>";
|
314 |
b11cdf92
|
Renato Botelho
|
|
315 |
21d40ff9
|
Ermal Lu?i
|
return behaviour;
|
316 |
|
|
}
|
317 |
|
|
|
318 |
|
|
/* Change the values on behaviours select when changing the structure row */
|
319 |
|
|
function changeBehaviourValues(row) {
|
320 |
|
|
var selectedRow = row.rowIndex - 2; //because row.rowIndex returns 2, not 0
|
321 |
b11cdf92
|
Renato Botelho
|
var structureSelected = document.getElementsByName("structure[]")[selectedRow].value;
|
322 |
|
|
|
323 |
21d40ff9
|
Ermal Lu?i
|
//Select the behaviours values to array a_behav
|
324 |
b11cdf92
|
Renato Botelho
|
var a_behav = new Array();
|
325 |
21d40ff9
|
Ermal Lu?i
|
if (structureSelected == "action") {
|
326 |
|
|
a_behav = js_behaviours_action; //static
|
327 |
|
|
}
|
328 |
|
|
else {
|
329 |
b11cdf92
|
Renato Botelho
|
if (structureSelected == "queue") {
|
330 |
21d40ff9
|
Ermal Lu?i
|
a_behav = js_behaviours_altq;
|
331 |
|
|
}
|
332 |
b11cdf92
|
Renato Botelho
|
else {
|
333 |
21d40ff9
|
Ermal Lu?i
|
a_behav = js_behaviours_limiter;
|
334 |
b11cdf92
|
Renato Botelho
|
}
|
335 |
|
|
}
|
336 |
|
|
|
337 |
21d40ff9
|
Ermal Lu?i
|
//Build the html statement with the array values previously selected
|
338 |
|
|
var new_behav;
|
339 |
|
|
var name;
|
340 |
|
|
for(i=0; i<a_behav.length; i++) {
|
341 |
e573ee95
|
Colin Fleming
|
new_behav += "<option value=" + a_behav[i] + ">" + a_behav[i] + "<\/option>";
|
342 |
21d40ff9
|
Ermal Lu?i
|
}
|
343 |
b11cdf92
|
Renato Botelho
|
|
344 |
|
|
document.getElementsByName("behaviour[]")[selectedRow].innerHTML = new_behav;
|
345 |
21d40ff9
|
Ermal Lu?i
|
}
|
346 |
|
|
|
347 |
|
|
/* Add row to the table */
|
348 |
|
|
function addRow(table_id) {
|
349 |
|
|
var tbl = document.getElementById(table_id);
|
350 |
|
|
// counting rows in table
|
351 |
|
|
var rows_count = tbl.rows.length;
|
352 |
|
|
if (initial_count[table_id] == undefined) {
|
353 |
|
|
// if it is first adding in this table setting initial rows count
|
354 |
|
|
initial_count[table_id] = rows_count;
|
355 |
|
|
}
|
356 |
|
|
// determining real count of added fields
|
357 |
|
|
var tFielsNum = rows_count - initial_count[table_id];
|
358 |
|
|
if (rows_limit!=0 && tFielsNum >= rows_limit) return false;
|
359 |
b11cdf92
|
Renato Botelho
|
|
360 |
e573ee95
|
Colin Fleming
|
var remove = '<a onclick="removeRow(\''+table_id+'\',this.parentNode.parentNode)" href="#"><img border="0" src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" alt="x" /><\/a>';
|
361 |
b11cdf92
|
Renato Botelho
|
|
362 |
21d40ff9
|
Ermal Lu?i
|
try {
|
363 |
|
|
var newRow = tbl.insertRow(rows_count);
|
364 |
|
|
var newCell = newRow.insertCell(0);
|
365 |
|
|
newCell.innerHTML = fillProtocol();
|
366 |
|
|
var newCell = newRow.insertCell(1);
|
367 |
|
|
newCell.innerHTML = fillStructure();
|
368 |
|
|
var newCell = newRow.insertCell(2);
|
369 |
|
|
newCell.innerHTML = fillBehaviour();
|
370 |
|
|
var newCell = newRow.insertCell(3);
|
371 |
|
|
newCell.innerHTML = remove;
|
372 |
b11cdf92
|
Renato Botelho
|
}
|
373 |
21d40ff9
|
Ermal Lu?i
|
catch (ex) {
|
374 |
|
|
//if exception occurs
|
375 |
|
|
alert(ex);
|
376 |
b11cdf92
|
Renato Botelho
|
}
|
377 |
21d40ff9
|
Ermal Lu?i
|
}
|
378 |
|
|
|
379 |
|
|
/* Remove row from the table */
|
380 |
|
|
function removeRow(tbl,row) {
|
381 |
|
|
var table = document.getElementById(tbl);
|
382 |
|
|
try {
|
383 |
|
|
table.deleteRow(row.rowIndex);
|
384 |
|
|
} catch (ex) {
|
385 |
|
|
alert(ex);
|
386 |
|
|
}
|
387 |
|
|
}
|
388 |
e750c0af
|
Colin Fleming
|
//]]>
|
389 |
21d40ff9
|
Ermal Lu?i
|
</script>
|
390 |
e750c0af
|
Colin Fleming
|
</head>
|
391 |
21d40ff9
|
Ermal Lu?i
|
|
392 |
e750c0af
|
Colin Fleming
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
393 |
|
|
|
394 |
|
|
<?php include("fbegin.inc"); ?>
|
395 |
21d40ff9
|
Ermal Lu?i
|
<div id="inputerrors"></div>
|
396 |
|
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
397 |
|
|
|
398 |
|
|
<form action="firewall_shaper_layer7.php" method="post" id="iform" name="iform">
|
399 |
|
|
|
400 |
|
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
401 |
|
|
<?php if (is_subsystem_dirty('shaper')): ?><p>
|
402 |
1d7ba683
|
ayvis
|
<?php print_info_box_np(gettext("The traffic shaper configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));?><br /></p>
|
403 |
21d40ff9
|
Ermal Lu?i
|
<?php endif; ?>
|
404 |
e750c0af
|
Colin Fleming
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="traffic shaper layer7">
|
405 |
21d40ff9
|
Ermal Lu?i
|
<tr><td>
|
406 |
|
|
<?php
|
407 |
|
|
$tab_array = array();
|
408 |
813a3ef6
|
Neriberto C.Prado
|
$tab_array[0] = array(gettext("By Interface"), false, "firewall_shaper.php");
|
409 |
|
|
$tab_array[1] = array(gettext("By Queue"), false, "firewall_shaper_queues.php");
|
410 |
|
|
$tab_array[2] = array(gettext("Limiter"), false, "firewall_shaper_vinterface.php");
|
411 |
|
|
$tab_array[3] = array(gettext("Layer7"), true, "firewall_shaper_layer7.php");
|
412 |
|
|
$tab_array[4] = array(gettext("Wizards"), false, "firewall_shaper_wizards.php");
|
413 |
21d40ff9
|
Ermal Lu?i
|
display_top_tabs($tab_array);
|
414 |
|
|
?>
|
415 |
|
|
</td></tr>
|
416 |
|
|
<tr>
|
417 |
|
|
<td>
|
418 |
|
|
<div id="mainarea">
|
419 |
e750c0af
|
Colin Fleming
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
|
420 |
b11cdf92
|
Renato Botelho
|
|
421 |
21d40ff9
|
Ermal Lu?i
|
<?php if (count($layer7_rules_list) > 0): ?>
|
422 |
|
|
<tr class="tabcont"><td width="25%" align="left">
|
423 |
|
|
</td><td width="75%"> </td></tr>
|
424 |
b11cdf92
|
Renato Botelho
|
|
425 |
|
|
<?php endif; ?>
|
426 |
21d40ff9
|
Ermal Lu?i
|
<tr>
|
427 |
e750c0af
|
Colin Fleming
|
<td width="25%" valign="top" align="left">
|
428 |
21d40ff9
|
Ermal Lu?i
|
<?php
|
429 |
b11cdf92
|
Renato Botelho
|
echo $tree;
|
430 |
21d40ff9
|
Ermal Lu?i
|
?>
|
431 |
1d7ba683
|
ayvis
|
<br /><br />
|
432 |
21d40ff9
|
Ermal Lu?i
|
<a href="firewall_shaper_layer7.php?action=add">
|
433 |
e750c0af
|
Colin Fleming
|
<img src="./themes/<?=$g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("Create new l7 rules group"); ?>" width="17" height="17" border="0" alt="add" /> <?=gettext("Create new l7 rules group"); ?>
|
434 |
1d7ba683
|
ayvis
|
</a><br />
|
435 |
21d40ff9
|
Ermal Lu?i
|
</td>
|
436 |
|
|
<td width="75%" valign="top" align="center">
|
437 |
e573ee95
|
Colin Fleming
|
<div id="shaperarea" style="position:relative">
|
438 |
e750c0af
|
Colin Fleming
|
<?php
|
439 |
21d40ff9
|
Ermal Lu?i
|
echo $output;
|
440 |
|
|
?>
|
441 |
b11cdf92
|
Renato Botelho
|
|
442 |
21d40ff9
|
Ermal Lu?i
|
<!-- Layer 7 rules form -->
|
443 |
|
|
<?php if($show_proto_form): ?>
|
444 |
e573ee95
|
Colin Fleming
|
<tr><td width="22%" valign="top" class="vncellreq">
|
445 |
e750c0af
|
Colin Fleming
|
<div id="addressnetworkport">
|
446 |
813a3ef6
|
Neriberto C.Prado
|
<?=gettext("Rule(s)"); ?>
|
447 |
21d40ff9
|
Ermal Lu?i
|
</div>
|
448 |
|
|
</td>
|
449 |
|
|
|
450 |
e750c0af
|
Colin Fleming
|
<td width="78%" class="vtable">
|
451 |
|
|
<table width="236" id="maintable" summary="main table">
|
452 |
21d40ff9
|
Ermal Lu?i
|
<tbody>
|
453 |
b11cdf92
|
Renato Botelho
|
|
454 |
21d40ff9
|
Ermal Lu?i
|
<tr>
|
455 |
e750c0af
|
Colin Fleming
|
<td colspan="4">
|
456 |
|
|
<div style="font-size: 8pt; padding:5px; margin-top: 16px; margin-bottom: 16px; border:1px dashed #000066;"
|
457 |
|
|
id="itemhelp">
|
458 |
813a3ef6
|
Neriberto C.Prado
|
<?=gettext("Add one or more rules"); ?>
|
459 |
21d40ff9
|
Ermal Lu?i
|
</div>
|
460 |
|
|
</td>
|
461 |
|
|
</tr>
|
462 |
|
|
|
463 |
|
|
<tr>
|
464 |
|
|
<td>
|
465 |
e750c0af
|
Colin Fleming
|
<div style="font-size: 8pt; padding:5px;"
|
466 |
|
|
id="onecolumn">
|
467 |
813a3ef6
|
Neriberto C.Prado
|
<?=gettext("Protocol"); ?>
|
468 |
21d40ff9
|
Ermal Lu?i
|
</div>
|
469 |
|
|
</td>
|
470 |
|
|
|
471 |
|
|
<td>
|
472 |
e750c0af
|
Colin Fleming
|
<div style="font-size: 8pt; padding:5px;"
|
473 |
|
|
id="twocolumn">
|
474 |
813a3ef6
|
Neriberto C.Prado
|
<?=gettext("Structure"); ?>
|
475 |
21d40ff9
|
Ermal Lu?i
|
</div>
|
476 |
|
|
</td>
|
477 |
|
|
|
478 |
|
|
<td>
|
479 |
e750c0af
|
Colin Fleming
|
<div style="font-size: 8pt; padding:5px;"
|
480 |
|
|
id="threecolumn">
|
481 |
813a3ef6
|
Neriberto C.Prado
|
<?=gettext("Behaviour"); ?>
|
482 |
21d40ff9
|
Ermal Lu?i
|
</div>
|
483 |
|
|
</td>
|
484 |
b11cdf92
|
Renato Botelho
|
</tr>
|
485 |
21d40ff9
|
Ermal Lu?i
|
<!-- PHP Code to generate the existing rules -->
|
486 |
|
|
<?php
|
487 |
|
|
if($container) {
|
488 |
|
|
foreach($container->rsets as $l7rule) {
|
489 |
|
|
?>
|
490 |
|
|
<tr>
|
491 |
|
|
<td>
|
492 |
e573ee95
|
Colin Fleming
|
<select name="protocol[]" class="formselect" style="font-size:8pt">
|
493 |
21d40ff9
|
Ermal Lu?i
|
<?php foreach($avail_protos as $proto): ?>
|
494 |
e750c0af
|
Colin Fleming
|
<option value="<?=$proto;?>" <?php if ($proto == $l7rule->GetRProtocol()) echo "selected=\"selected\""; ?>><?=$proto;?></option>
|
495 |
b11cdf92
|
Renato Botelho
|
<?php endforeach; ?>
|
496 |
21d40ff9
|
Ermal Lu?i
|
</select>
|
497 |
|
|
</td>
|
498 |
|
|
<td>
|
499 |
e573ee95
|
Colin Fleming
|
<select name="structure[]" class="formselect" style="font-size:8pt" onchange="changeBehaviourValues(this.parentNode.parentNode);">
|
500 |
21d40ff9
|
Ermal Lu?i
|
<?php foreach($avail_structures as $struct) {
|
501 |
|
|
if($struct == "queue") {
|
502 |
|
|
if(!empty($avail_behaviours_altq)) { ?>
|
503 |
e750c0af
|
Colin Fleming
|
<option value="<?=$struct ?>" <?php if ($struct == $l7rule->GetRStructure()) echo "selected=\"selected\""; ?>><?=$struct;?></option>
|
504 |
21d40ff9
|
Ermal Lu?i
|
<?php }
|
505 |
|
|
}
|
506 |
|
|
else {
|
507 |
|
|
if($struct == "limiter") {
|
508 |
|
|
if(!empty($avail_behaviours_limiter)) { ?>
|
509 |
e750c0af
|
Colin Fleming
|
<option value="<?=$struct ?>" <?php if ($struct == $l7rule->GetRStructure()) echo "selected=\"selected\""; ?>><?=$struct;?></option>
|
510 |
21d40ff9
|
Ermal Lu?i
|
<?php }
|
511 |
|
|
}
|
512 |
|
|
else {
|
513 |
|
|
if($struct == "action") { ?>
|
514 |
e750c0af
|
Colin Fleming
|
<option value="<?=$struct ?>" <?php if ($struct == $l7rule->GetRStructure()) echo "selected=\"selected\""; ?>><?=$struct;?></option>
|
515 |
b11cdf92
|
Renato Botelho
|
<?php }
|
516 |
21d40ff9
|
Ermal Lu?i
|
}
|
517 |
|
|
}
|
518 |
|
|
} ?>
|
519 |
|
|
</select>
|
520 |
|
|
</td>
|
521 |
|
|
<td>
|
522 |
e573ee95
|
Colin Fleming
|
<select name="behaviour[]" class="formselect" style="width:80px; font-size:8pt">
|
523 |
21d40ff9
|
Ermal Lu?i
|
<?php if($l7rule->GetRStructure() == "action"): ?>
|
524 |
|
|
<?php foreach($avail_behaviours_action as $behaviour): ?>
|
525 |
e750c0af
|
Colin Fleming
|
<option value="<?=$behaviour ?>" <?php if ($behaviour == $l7rule->GetRBehaviour()) echo "selected=\"selected\""; ?>><?=$behaviour;?></option>
|
526 |
b11cdf92
|
Renato Botelho
|
<?php endforeach; ?>
|
527 |
21d40ff9
|
Ermal Lu?i
|
</select>
|
528 |
b11cdf92
|
Renato Botelho
|
<?php endif; ?>
|
529 |
21d40ff9
|
Ermal Lu?i
|
<?php if($l7rule->GetRStructure() == "queue"): ?>
|
530 |
|
|
<?php foreach($avail_behaviours_altq as $behaviour): ?>
|
531 |
e750c0af
|
Colin Fleming
|
<option value="<?=$behaviour ?>" <?php if ($behaviour == $l7rule->GetRBehaviour()) echo "selected=\"selected\""; ?>><?=$behaviour;?></option>
|
532 |
b11cdf92
|
Renato Botelho
|
<?php endforeach; ?>
|
533 |
21d40ff9
|
Ermal Lu?i
|
</select>
|
534 |
b11cdf92
|
Renato Botelho
|
<?php endif; ?>
|
535 |
21d40ff9
|
Ermal Lu?i
|
<?php if($l7rule->GetRStructure() == "limiter"): ?>
|
536 |
|
|
<?php foreach($avail_behaviours_limiter as $behaviour): ?>
|
537 |
e750c0af
|
Colin Fleming
|
<option value="<?=$behaviour ?>" <?php if ($behaviour == $l7rule->GetRBehaviour()) echo "selected=\"selected\""; ?>><?=$behaviour;?></option>
|
538 |
b11cdf92
|
Renato Botelho
|
<?php endforeach; ?>
|
539 |
21d40ff9
|
Ermal Lu?i
|
</select>
|
540 |
b11cdf92
|
Renato Botelho
|
<?php endif; ?>
|
541 |
21d40ff9
|
Ermal Lu?i
|
</td>
|
542 |
|
|
<td>
|
543 |
e750c0af
|
Colin Fleming
|
<a onclick="removeRow('maintable',this.parentNode.parentNode); return false;" href="#"><img border="0" src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" alt="x" /></a>
|
544 |
21d40ff9
|
Ermal Lu?i
|
</td>
|
545 |
|
|
</tr>
|
546 |
b11cdf92
|
Renato Botelho
|
|
547 |
21d40ff9
|
Ermal Lu?i
|
<?php
|
548 |
|
|
} //end foreach
|
549 |
|
|
} //end if
|
550 |
b11cdf92
|
Renato Botelho
|
?>
|
551 |
21d40ff9
|
Ermal Lu?i
|
</tbody>
|
552 |
|
|
</table>
|
553 |
|
|
|
554 |
e750c0af
|
Colin Fleming
|
<a onclick="javascript:addRow('maintable'); return false;" href="#"> <img border="0"
|
555 |
|
|
src="/themes/<?=$g['theme']; ?>/images/icons/icon_plus.gif"
|
556 |
|
|
alt="" title="<?=gettext("add another entry"); ?>" /> </a>
|
557 |
21d40ff9
|
Ermal Lu?i
|
</td>
|
558 |
|
|
</tr>
|
559 |
|
|
|
560 |
|
|
<tr>
|
561 |
e750c0af
|
Colin Fleming
|
<td width="22%" valign="top">
|
562 |
21d40ff9
|
Ermal Lu?i
|
|
563 |
|
|
</td>
|
564 |
|
|
|
565 |
e750c0af
|
Colin Fleming
|
<td width="78%">
|
566 |
e573ee95
|
Colin Fleming
|
<input id="submit" name="submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
|
567 |
21d40ff9
|
Ermal Lu?i
|
|
568 |
e750c0af
|
Colin Fleming
|
<a href="firewall_shaper_layer7.php">
|
569 |
e573ee95
|
Colin Fleming
|
<input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" />
|
570 |
b11cdf92
|
Renato Botelho
|
|
571 |
21d40ff9
|
Ermal Lu?i
|
<?php if($container): ?>
|
572 |
e573ee95
|
Colin Fleming
|
<input id="delete" type="submit" class="formbtn" name="delete" value="<?=gettext("Delete"); ?>" />
|
573 |
b11cdf92
|
Renato Botelho
|
<?php endif ?>
|
574 |
e573ee95
|
Colin Fleming
|
</a>
|
575 |
21d40ff9
|
Ermal Lu?i
|
</td>
|
576 |
|
|
</tr>
|
577 |
b11cdf92
|
Renato Botelho
|
<?php endif; ?>
|
578 |
21d40ff9
|
Ermal Lu?i
|
<!-- End of layer7 rules form -->
|
579 |
|
|
</table>
|
580 |
e573ee95
|
Colin Fleming
|
</div><!-- end of div:shape area -->
|
581 |
21d40ff9
|
Ermal Lu?i
|
|
582 |
|
|
</td></tr>
|
583 |
|
|
</table>
|
584 |
|
|
</div>
|
585 |
|
|
</td>
|
586 |
|
|
</tr>
|
587 |
|
|
</table>
|
588 |
|
|
</form>
|
589 |
|
|
|
590 |
e750c0af
|
Colin Fleming
|
<?php include("fend.inc"); ?>
|
591 |
21d40ff9
|
Ermal Lu?i
|
</body>
|
592 |
|
|
</html>
|