1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
firewall_rules_edit.php
|
5
|
part of pfSense (https://www.pfsense.org)
|
6
|
Copyright (C) 2005 Scott Ullrich (sullrich@gmail.com)
|
7
|
|
8
|
originally part of m0n0wall (http://m0n0.ch/wall)
|
9
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
10
|
All rights reserved.
|
11
|
|
12
|
Redistribution and use in source and binary forms, with or without
|
13
|
modification, are permitted provided that the following conditions are met:
|
14
|
|
15
|
1. Redistributions of source code must retain the above copyright notice,
|
16
|
this list of conditions and the following disclaimer.
|
17
|
|
18
|
2. Redistributions in binary form must reproduce the above copyright
|
19
|
notice, this list of conditions and the following disclaimer in the
|
20
|
documentation and/or other materials provided with the distribution.
|
21
|
|
22
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
23
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
24
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
25
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
26
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
27
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
28
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
29
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
31
|
POSSIBILITY OF SUCH DAMAGE.
|
32
|
*/
|
33
|
/*
|
34
|
pfSense_MODULE: filter
|
35
|
*/
|
36
|
|
37
|
##|+PRIV
|
38
|
##|*IDENT=page-firewall-rules-edit
|
39
|
##|*NAME=Firewall: Rules: Edit page
|
40
|
##|*DESCR=Allow access to the 'Firewall: Rules: Edit' page.
|
41
|
##|*MATCH=firewall_rules_edit.php*
|
42
|
##|-PRIV
|
43
|
|
44
|
require("guiconfig.inc");
|
45
|
require_once("filter.inc");
|
46
|
require("shaper.inc");
|
47
|
|
48
|
function is_posnumericint($arg) {
|
49
|
// Note that to be safe we do not allow any leading zero - "01", "007"
|
50
|
return (is_numericint($arg) && $arg[0] != '0' && $arg > 0);
|
51
|
}
|
52
|
|
53
|
function is_aoadv_used($rule_config) {
|
54
|
// Note that the user could set "tag" or "tagged" to the string "0", which is valid but empty().
|
55
|
// And if the user enters "0" in other fields, we want to present an error message, and keep the Advanced Options section open.
|
56
|
if ((isset($rule_config['allowopts'])) ||
|
57
|
(isset($rule_config['disablereplyto'])) ||
|
58
|
($rule_config['tag'] != "") ||
|
59
|
($rule_config['tagged'] != "") ||
|
60
|
($rule_config['max'] != "") ||
|
61
|
($rule_config['max-src-nodes'] != "") ||
|
62
|
($rule_config['max-src-conn'] != "") ||
|
63
|
($rule_config['max-src-states'] != "") ||
|
64
|
($rule_config['max-src-conn-rate'] != "") ||
|
65
|
($rule_config['max-src-conn-rates'] != "") ||
|
66
|
($rule_config['statetimeout'] != ""))
|
67
|
return true;
|
68
|
return false;
|
69
|
}
|
70
|
|
71
|
$ostypes = array();
|
72
|
exec('/sbin/pfctl -s osfp | /usr/bin/tr \'\t\' \' \'', $ostypes);
|
73
|
|
74
|
if (count($ostypes) > 2) {
|
75
|
// Remove header rows from pfctl output
|
76
|
array_shift($ostypes);
|
77
|
array_shift($ostypes);
|
78
|
} else {
|
79
|
// Fall back to a default list
|
80
|
$ostypes = array(
|
81
|
"AIX",
|
82
|
"Linux",
|
83
|
"FreeBSD",
|
84
|
"NetBSD",
|
85
|
"OpenBSD",
|
86
|
"Solaris",
|
87
|
"MacOS",
|
88
|
"Windows",
|
89
|
"Novell",
|
90
|
"NMAP"
|
91
|
);
|
92
|
}
|
93
|
|
94
|
$specialsrcdst = explode(" ", "any (self) pptp pppoe l2tp openvpn");
|
95
|
$ifdisp = get_configured_interface_with_descr();
|
96
|
foreach ($ifdisp as $kif => $kdescr) {
|
97
|
$specialsrcdst[] = "{$kif}";
|
98
|
$specialsrcdst[] = "{$kif}ip";
|
99
|
}
|
100
|
|
101
|
if (!is_array($config['filter']['rule'])) {
|
102
|
$config['filter']['rule'] = array();
|
103
|
}
|
104
|
filter_rules_sort();
|
105
|
$a_filter = &$config['filter']['rule'];
|
106
|
|
107
|
if (is_numericint($_GET['id']))
|
108
|
$id = $_GET['id'];
|
109
|
if (isset($_POST['id']) && is_numericint($_POST['id']))
|
110
|
$id = $_POST['id'];
|
111
|
|
112
|
if (is_numericint($_GET['after']) || $_GET['after'] == "-1")
|
113
|
$after = $_GET['after'];
|
114
|
if (isset($_POST['after']) && (is_numericint($_POST['after']) || $_POST['after'] == "-1"))
|
115
|
$after = $_POST['after'];
|
116
|
|
117
|
if (isset($_GET['dup']) && is_numericint($_GET['dup'])) {
|
118
|
$id = $_GET['dup'];
|
119
|
$after = $_GET['dup'];
|
120
|
}
|
121
|
|
122
|
if (isset($id) && $a_filter[$id]) {
|
123
|
$pconfig['interface'] = $a_filter[$id]['interface'];
|
124
|
|
125
|
if (isset($a_filter[$id]['id']))
|
126
|
$pconfig['ruleid'] = $a_filter[$id]['id'];
|
127
|
|
128
|
if ( isset($a_filter[$id]['created']) && is_array($a_filter[$id]['created']) )
|
129
|
$pconfig['created'] = $a_filter[$id]['created'];
|
130
|
|
131
|
if ( isset($a_filter[$id]['updated']) && is_array($a_filter[$id]['updated']) )
|
132
|
$pconfig['updated'] = $a_filter[$id]['updated'];
|
133
|
|
134
|
if (!isset($a_filter[$id]['type']))
|
135
|
$pconfig['type'] = "pass";
|
136
|
else
|
137
|
$pconfig['type'] = $a_filter[$id]['type'];
|
138
|
|
139
|
if (isset($a_filter[$id]['floating']) || $if == "FloatingRules") {
|
140
|
$pconfig['floating'] = $a_filter[$id]['floating'];
|
141
|
if (isset($a_filter[$id]['interface']) && $a_filter[$id]['interface'] <> "")
|
142
|
$pconfig['interface'] = $a_filter[$id]['interface'];
|
143
|
}
|
144
|
|
145
|
if (isset($a_filter['floating']))
|
146
|
$pconfig['floating'] = "yes";
|
147
|
|
148
|
if (isset($a_filter[$id]['direction']))
|
149
|
$pconfig['direction'] = $a_filter[$id]['direction'];
|
150
|
|
151
|
if (isset($a_filter[$id]['ipprotocol']))
|
152
|
$pconfig['ipprotocol'] = $a_filter[$id]['ipprotocol'];
|
153
|
|
154
|
if (isset($a_filter[$id]['protocol']))
|
155
|
$pconfig['proto'] = $a_filter[$id]['protocol'];
|
156
|
else
|
157
|
$pconfig['proto'] = "any";
|
158
|
|
159
|
if ($a_filter[$id]['protocol'] == "icmp")
|
160
|
$pconfig['icmptype'] = $a_filter[$id]['icmptype'];
|
161
|
|
162
|
address_to_pconfig($a_filter[$id]['source'], $pconfig['src'],
|
163
|
$pconfig['srcmask'], $pconfig['srcnot'],
|
164
|
$pconfig['srcbeginport'], $pconfig['srcendport']);
|
165
|
|
166
|
if($a_filter[$id]['os'] <> "")
|
167
|
$pconfig['os'] = $a_filter[$id]['os'];
|
168
|
|
169
|
address_to_pconfig($a_filter[$id]['destination'], $pconfig['dst'],
|
170
|
$pconfig['dstmask'], $pconfig['dstnot'],
|
171
|
$pconfig['dstbeginport'], $pconfig['dstendport']);
|
172
|
|
173
|
if ($a_filter[$id]['dscp'] <> "")
|
174
|
$pconfig['dscp'] = $a_filter[$id]['dscp'];
|
175
|
|
176
|
$pconfig['disabled'] = isset($a_filter[$id]['disabled']);
|
177
|
$pconfig['log'] = isset($a_filter[$id]['log']);
|
178
|
$pconfig['descr'] = $a_filter[$id]['descr'];
|
179
|
|
180
|
if (isset($a_filter[$id]['tcpflags_any']))
|
181
|
$pconfig['tcpflags_any'] = true;
|
182
|
else {
|
183
|
if (isset($a_filter[$id]['tcpflags1']) && $a_filter[$id]['tcpflags1'] <> "")
|
184
|
$pconfig['tcpflags1'] = $a_filter[$id]['tcpflags1'];
|
185
|
if (isset($a_filter[$id]['tcpflags2']) && $a_filter[$id]['tcpflags2'] <> "")
|
186
|
$pconfig['tcpflags2'] = $a_filter[$id]['tcpflags2'];
|
187
|
}
|
188
|
|
189
|
if (isset($a_filter[$id]['tag']) && $a_filter[$id]['tag'] <> "")
|
190
|
$pconfig['tag'] = $a_filter[$id]['tag'];
|
191
|
if (isset($a_filter[$id]['tagged']) && $a_filter[$id]['tagged'] <> "")
|
192
|
$pconfig['tagged'] = $a_filter[$id]['tagged'];
|
193
|
if (isset($a_filter[$id]['quick']) && $a_filter[$id]['quick'])
|
194
|
$pconfig['quick'] = $a_filter[$id]['quick'];
|
195
|
if (isset($a_filter[$id]['allowopts']))
|
196
|
$pconfig['allowopts'] = true;
|
197
|
if (isset($a_filter[$id]['disablereplyto']))
|
198
|
$pconfig['disablereplyto'] = true;
|
199
|
|
200
|
/* advanced */
|
201
|
$pconfig['max'] = $a_filter[$id]['max'];
|
202
|
$pconfig['max-src-nodes'] = $a_filter[$id]['max-src-nodes'];
|
203
|
$pconfig['max-src-conn'] = $a_filter[$id]['max-src-conn'];
|
204
|
$pconfig['max-src-states'] = $a_filter[$id]['max-src-states'];
|
205
|
$pconfig['statetype'] = $a_filter[$id]['statetype'];
|
206
|
$pconfig['statetimeout'] = $a_filter[$id]['statetimeout'];
|
207
|
$pconfig['nopfsync'] = isset($a_filter[$id]['nopfsync']);
|
208
|
|
209
|
/* advanced - nosync */
|
210
|
$pconfig['nosync'] = isset($a_filter[$id]['nosync']);
|
211
|
|
212
|
/* advanced - new connection per second banning*/
|
213
|
$pconfig['max-src-conn-rate'] = $a_filter[$id]['max-src-conn-rate'];
|
214
|
$pconfig['max-src-conn-rates'] = $a_filter[$id]['max-src-conn-rates'];
|
215
|
|
216
|
/* Multi-WAN next-hop support */
|
217
|
$pconfig['gateway'] = $a_filter[$id]['gateway'];
|
218
|
|
219
|
/* Shaper support */
|
220
|
$pconfig['defaultqueue'] = (($a_filter[$id]['ackqueue'] == "none") ? '' : $a_filter[$id]['defaultqueue']);
|
221
|
$pconfig['ackqueue'] = (($a_filter[$id]['ackqueue'] == "none") ? '' : $a_filter[$id]['ackqueue']);
|
222
|
$pconfig['dnpipe'] = (($a_filter[$id]['dnpipe'] == "none") ? '' : $a_filter[$id]['dnpipe']);
|
223
|
$pconfig['pdnpipe'] = (($a_filter[$id]['pdnpipe'] == "none") ? '' : $a_filter[$id]['pdnpipe']);
|
224
|
$pconfig['l7container'] = (($a_filter[$id]['l7container'] == "none") ? '' : $a_filter[$id]['l7container']);
|
225
|
|
226
|
//schedule support
|
227
|
$pconfig['sched'] = (($a_filter[$id]['sched'] == "none") ? '' : $a_filter[$id]['sched']);
|
228
|
$pconfig['vlanprio'] = (($a_filter[$id]['vlanprio'] == "none") ? '' : $a_filter[$id]['vlanprio']);
|
229
|
$pconfig['vlanprioset'] = (($a_filter[$id]['vlanprioset'] == "none") ? '' : $a_filter[$id]['vlanprioset']);
|
230
|
if (!isset($_GET['dup']) || !is_numericint($_GET['dup']))
|
231
|
$pconfig['associated-rule-id'] = $a_filter[$id]['associated-rule-id'];
|
232
|
|
233
|
$pconfig['tracker'] = $a_filter[$id]['tracker'];
|
234
|
|
235
|
} else {
|
236
|
/* defaults */
|
237
|
if ($_GET['if'])
|
238
|
$pconfig['interface'] = $_GET['if'];
|
239
|
$pconfig['type'] = "pass";
|
240
|
$pconfig['src'] = "any";
|
241
|
$pconfig['dst'] = "any";
|
242
|
}
|
243
|
/* Allow the FloatingRules to work */
|
244
|
$if = $pconfig['interface'];
|
245
|
|
246
|
if (isset($_GET['dup']) && is_numericint($_GET['dup']))
|
247
|
unset($id);
|
248
|
|
249
|
read_altq_config(); /* XXX: */
|
250
|
$qlist =& get_unique_queue_list();
|
251
|
read_dummynet_config(); /* XXX: */
|
252
|
$dnqlist =& get_unique_dnqueue_list();
|
253
|
read_layer7_config();
|
254
|
$l7clist =& get_l7_unique_list();
|
255
|
$a_gatewaygroups = return_gateway_groups_array();
|
256
|
|
257
|
if ($_POST) {
|
258
|
unset($input_errors);
|
259
|
|
260
|
if( isset($a_filter[$id]['associated-rule-id']) ) {
|
261
|
$_POST['proto'] = $pconfig['proto'];
|
262
|
if ($pconfig['proto'] == "icmp")
|
263
|
$_POST['icmptype'] = $pconfig['icmptype'];
|
264
|
}
|
265
|
|
266
|
if (($_POST['ipprotocol'] <> "") && ($_POST['gateway'] <> "")) {
|
267
|
if(is_array($config['gateways']['gateway_group'])) {
|
268
|
foreach($config['gateways']['gateway_group'] as $gw_group) {
|
269
|
if($gw_group['name'] == $_POST['gateway']) {
|
270
|
$family = $a_gatewaygroups[$_POST['gateway']]['ipprotocol'];
|
271
|
if($_POST['ipprotocol'] == $family) {
|
272
|
continue;
|
273
|
}
|
274
|
if(($_POST['ipprotocol'] == "inet46") && ($_POST['ipprotocol'] != $family)) {
|
275
|
$input_errors[] = gettext("You can not assign a gateway to a rule that applies to IPv4 and IPv6");
|
276
|
}
|
277
|
if(($_POST['ipprotocol'] == "inet6") && ($_POST['ipprotocol'] != $family)) {
|
278
|
$input_errors[] = gettext("You can not assign a IPv4 gateway group on IPv6 Address Family rule");
|
279
|
}
|
280
|
if(($_POST['ipprotocol'] == "inet") && ($_POST['ipprotocol'] != $family)) {
|
281
|
$input_errors[] = gettext("You can not assign a IPv6 gateway group on IPv4 Address Family rule");
|
282
|
}
|
283
|
}
|
284
|
}
|
285
|
}
|
286
|
}
|
287
|
if (($_POST['ipprotocol'] <> "") && ($_POST['gateway'] <> "") && (is_ipaddr(lookup_gateway_ip_by_name($_POST['gateway'])))) {
|
288
|
if(($_POST['ipprotocol'] == "inet46") && ($_POST['gateway'] <> "")) {
|
289
|
$input_errors[] = gettext("You can not assign a gateway to a rule that applies to IPv4 and IPv6");
|
290
|
}
|
291
|
if(($_POST['ipprotocol'] == "inet6") && (!is_ipaddrv6(lookup_gateway_ip_by_name($_POST['gateway'])))) {
|
292
|
$input_errors[] = gettext("You can not assign the IPv4 Gateway to a IPv6 Filter rule");
|
293
|
}
|
294
|
if(($_POST['ipprotocol'] == "inet") && (!is_ipaddrv4(lookup_gateway_ip_by_name($_POST['gateway'])))) {
|
295
|
$input_errors[] = gettext("You can not assign the IPv6 Gateway to a IPv4 Filter rule");
|
296
|
}
|
297
|
}
|
298
|
|
299
|
if (($_POST['proto'] != "tcp") && ($_POST['proto'] != "udp") && ($_POST['proto'] != "tcp/udp") && ($_POST['proto'] != "icmp")) {
|
300
|
if($_POST['ipprotocol'] == "inet46")
|
301
|
$input_errors[] = gettext("You can not assign a protocol other then ICMP, TCP, UDP or TCP/UDP to a rule that applies to IPv4 and IPv6");
|
302
|
}
|
303
|
if (($_POST['proto'] == "icmp") && ($_POST['icmptype'] <> "")){
|
304
|
if($_POST['ipprotocol'] == "inet46")
|
305
|
$input_errors[] = gettext("You can not assign a ICMP type to a rule that applies to IPv4 and IPv6");
|
306
|
}
|
307
|
|
308
|
if (($_POST['proto'] != "tcp") && ($_POST['proto'] != "udp") && ($_POST['proto'] != "tcp/udp")) {
|
309
|
$_POST['srcbeginport'] = 0;
|
310
|
$_POST['srcendport'] = 0;
|
311
|
$_POST['dstbeginport'] = 0;
|
312
|
$_POST['dstendport'] = 0;
|
313
|
} else {
|
314
|
if ($_POST['srcbeginport_cust'] && !$_POST['srcbeginport'])
|
315
|
$_POST['srcbeginport'] = trim($_POST['srcbeginport_cust']);
|
316
|
if ($_POST['srcendport_cust'] && !$_POST['srcendport'])
|
317
|
$_POST['srcendport'] = trim($_POST['srcendport_cust']);
|
318
|
if ($_POST['srcbeginport'] == "any") {
|
319
|
$_POST['srcbeginport'] = 0;
|
320
|
$_POST['srcendport'] = 0;
|
321
|
} else {
|
322
|
if (!$_POST['srcendport'])
|
323
|
$_POST['srcendport'] = $_POST['srcbeginport'];
|
324
|
}
|
325
|
if ($_POST['srcendport'] == "any")
|
326
|
$_POST['srcendport'] = $_POST['srcbeginport'];
|
327
|
|
328
|
if ($_POST['dstbeginport_cust'] && !$_POST['dstbeginport'])
|
329
|
$_POST['dstbeginport'] = trim($_POST['dstbeginport_cust']);
|
330
|
if ($_POST['dstendport_cust'] && !$_POST['dstendport'])
|
331
|
$_POST['dstendport'] = trim($_POST['dstendport_cust']);
|
332
|
|
333
|
if ($_POST['dstbeginport'] == "any") {
|
334
|
$_POST['dstbeginport'] = 0;
|
335
|
$_POST['dstendport'] = 0;
|
336
|
} else {
|
337
|
if (!$_POST['dstendport'])
|
338
|
$_POST['dstendport'] = $_POST['dstbeginport'];
|
339
|
}
|
340
|
if ($_POST['dstendport'] == "any")
|
341
|
$_POST['dstendport'] = $_POST['dstbeginport'];
|
342
|
}
|
343
|
|
344
|
if (is_specialnet($_POST['srctype'])) {
|
345
|
$_POST['src'] = $_POST['srctype'];
|
346
|
$_POST['srcmask'] = 0;
|
347
|
} else if ($_POST['srctype'] == "single") {
|
348
|
if (is_ipaddrv6($_POST['src']))
|
349
|
$_POST['srcmask'] = 128;
|
350
|
else
|
351
|
$_POST['srcmask'] = 32;
|
352
|
}
|
353
|
if (is_specialnet($_POST['dsttype'])) {
|
354
|
$_POST['dst'] = $_POST['dsttype'];
|
355
|
$_POST['dstmask'] = 0;
|
356
|
} else if ($_POST['dsttype'] == "single") {
|
357
|
if (is_ipaddrv6($_POST['dst']))
|
358
|
$_POST['dstmask'] = 128;
|
359
|
else
|
360
|
$_POST['dstmask'] = 32;
|
361
|
}
|
362
|
|
363
|
$pconfig = $_POST;
|
364
|
|
365
|
/* input validation */
|
366
|
$reqdfields = explode(" ", "type proto");
|
367
|
if ( isset($a_filter[$id]['associated-rule-id'])===false ) {
|
368
|
$reqdfields[] = "src";
|
369
|
$reqdfields[] = "dst";
|
370
|
}
|
371
|
$reqdfieldsn = explode(",", "Type,Protocol");
|
372
|
if ( isset($a_filter[$id]['associated-rule-id'])===false ) {
|
373
|
$reqdfieldsn[] = "Source";
|
374
|
$reqdfieldsn[] = "Destination";
|
375
|
}
|
376
|
|
377
|
if($_POST['statetype'] == "modulate state" or $_POST['statetype'] == "synproxy state") {
|
378
|
if( $_POST['proto'] != "tcp" )
|
379
|
$input_errors[] = sprintf(gettext("%s is only valid with protocol tcp."),$_POST['statetype']);
|
380
|
if(($_POST['statetype'] == "synproxy state") && ($_POST['gateway'] != ""))
|
381
|
$input_errors[] = sprintf(gettext("%s is only valid if the gateway is set to 'default'."),$_POST['statetype']);
|
382
|
}
|
383
|
|
384
|
if ( isset($a_filter[$id]['associated-rule-id'])===false &&
|
385
|
(!(is_specialnet($_POST['srctype']) || ($_POST['srctype'] == "single"))) ) {
|
386
|
$reqdfields[] = "srcmask";
|
387
|
$reqdfieldsn[] = "Source bit count";
|
388
|
}
|
389
|
if ( isset($a_filter[$id]['associated-rule-id'])===false &&
|
390
|
(!(is_specialnet($_POST['dsttype']) || ($_POST['dsttype'] == "single"))) ) {
|
391
|
$reqdfields[] = "dstmask";
|
392
|
$reqdfieldsn[] = gettext("Destination bit count");
|
393
|
}
|
394
|
|
395
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
|
396
|
|
397
|
if (!$_POST['srcbeginport']) {
|
398
|
$_POST['srcbeginport'] = 0;
|
399
|
$_POST['srcendport'] = 0;
|
400
|
}
|
401
|
if (!$_POST['dstbeginport']) {
|
402
|
$_POST['dstbeginport'] = 0;
|
403
|
$_POST['dstendport'] = 0;
|
404
|
}
|
405
|
|
406
|
if ($_POST['srcbeginport'] && !is_portoralias($_POST['srcbeginport']))
|
407
|
$input_errors[] = sprintf(gettext("%s is not a valid start source port. It must be a port alias or integer between 1 and 65535."),$_POST['srcbeginposrt']);
|
408
|
if ($_POST['srcendport'] && !is_portoralias($_POST['srcendport']))
|
409
|
$input_errors[] = sprintf(gettext("%s is not a valid end source port. It must be a port alias or integer between 1 and 65535."),$_POST['srcendport']);
|
410
|
if ($_POST['dstbeginport'] && !is_portoralias($_POST['dstbeginport']))
|
411
|
$input_errors[] = sprintf(gettext("%s is not a valid start destination port. It must be a port alias or integer between 1 and 65535."),$_POST['dstbeginport']);
|
412
|
if ($_POST['dstendport'] && !is_portoralias($_POST['dstendport']))
|
413
|
$input_errors[] = sprintf(gettext("%s is not a valid end destination port. It must be a port alias or integer between 1 and 65535."),$_POST['dstendport']);
|
414
|
if ( !$_POST['srcbeginport_cust'] && $_POST['srcendport_cust'])
|
415
|
if (is_alias($_POST['srcendport_cust']))
|
416
|
$input_errors[] = 'If you put port alias in Source port range to: field you must put the same port alias in from: field';
|
417
|
if ( $_POST['srcbeginport_cust'] && $_POST['srcendport_cust']){
|
418
|
if (is_alias($_POST['srcendport_cust']) && is_alias($_POST['srcendport_cust']) && $_POST['srcbeginport_cust'] != $_POST['srcendport_cust'])
|
419
|
$input_errors[] = 'The same port alias must be used in Source port range from: and to: fields';
|
420
|
if ((is_alias($_POST['srcbeginport_cust']) && (!is_alias($_POST['srcendport_cust']) && $_POST['srcendport_cust']!='')) ||
|
421
|
((!is_alias($_POST['srcbeginport_cust']) && $_POST['srcbeginport_cust']!='') && is_alias($_POST['srcendport_cust'])))
|
422
|
$input_errors[] = 'You cannot specify numbers and port aliases at the same time in Source port range from: and to: field';
|
423
|
}
|
424
|
if ( !$_POST['dstbeginport_cust'] && $_POST['dstendport_cust'])
|
425
|
if (is_alias($_POST['dstendport_cust']))
|
426
|
$input_errors[] = 'If you put port alias in Destination port range to: field you must put the same port alias in from: field';
|
427
|
if ( $_POST['dstbeginport_cust'] && $_POST['dstendport_cust']){
|
428
|
if (is_alias($_POST['dstendport_cust']) && is_alias($_POST['dstendport_cust']) && $_POST['dstbeginport_cust'] != $_POST['dstendport_cust'])
|
429
|
$input_errors[] = 'The same port alias must be used in Destination port range from: and to: fields';
|
430
|
if ((is_alias($_POST['dstbeginport_cust']) && (!is_alias($_POST['dstendport_cust']) && $_POST['dstendport_cust']!='')) ||
|
431
|
((!is_alias($_POST['dstbeginport_cust']) && $_POST['dstbeginport_cust']!='') && is_alias($_POST['dstendport_cust'])))
|
432
|
$input_errors[] = 'You cannot specify numbers and port aliases at the same time in Destination port range from: and to: field';
|
433
|
}
|
434
|
|
435
|
if ($_POST['src'])
|
436
|
$_POST['src'] = trim($_POST['src']);
|
437
|
if ($_POST['dst'])
|
438
|
$_POST['dst'] = trim($_POST['dst']);
|
439
|
|
440
|
/* if user enters an alias and selects "network" then disallow. */
|
441
|
if($_POST['srctype'] == "network") {
|
442
|
if(is_alias($_POST['src']))
|
443
|
$input_errors[] = gettext("You must specify single host or alias for alias entries.");
|
444
|
}
|
445
|
if($_POST['dsttype'] == "network") {
|
446
|
if(is_alias($_POST['dst']))
|
447
|
$input_errors[] = gettext("You must specify single host or alias for alias entries.");
|
448
|
}
|
449
|
|
450
|
if (!is_specialnet($_POST['srctype'])) {
|
451
|
if (($_POST['src'] && !is_ipaddroralias($_POST['src']))) {
|
452
|
$input_errors[] = sprintf(gettext("%s is not a valid source IP address or alias."),$_POST['src']);
|
453
|
}
|
454
|
if (($_POST['srcmask'] && !is_numericint($_POST['srcmask']))) {
|
455
|
$input_errors[] = gettext("A valid source bit count must be specified.");
|
456
|
}
|
457
|
}
|
458
|
if (!is_specialnet($_POST['dsttype'])) {
|
459
|
if (($_POST['dst'] && !is_ipaddroralias($_POST['dst']))) {
|
460
|
$input_errors[] = sprintf(gettext("%s is not a valid destination IP address or alias."),$_POST['dst']);
|
461
|
}
|
462
|
if (($_POST['dstmask'] && !is_numericint($_POST['dstmask']))) {
|
463
|
$input_errors[] = gettext("A valid destination bit count must be specified.");
|
464
|
}
|
465
|
}
|
466
|
if((is_ipaddr($_POST['src']) && is_ipaddr($_POST['dst']))) {
|
467
|
if(!validate_address_family($_POST['src'], $_POST['dst']))
|
468
|
$input_errors[] = sprintf(gettext("The Source IP address %s Address Family differs from the destination %s."), $_POST['src'], $_POST['dst']);
|
469
|
if((is_ipaddrv6($_POST['src']) || is_ipaddrv6($_POST['dst'])) && ($_POST['ipprotocol'] == "inet"))
|
470
|
$input_errors[] = gettext("You can not use IPv6 addresses in IPv4 rules.");
|
471
|
if((is_ipaddrv4($_POST['src']) || is_ipaddrv4($_POST['dst'])) && ($_POST['ipprotocol'] == "inet6"))
|
472
|
$input_errors[] = gettext("You can not use IPv4 addresses in IPv6 rules.");
|
473
|
}
|
474
|
|
475
|
if((is_ipaddr($_POST['src']) || is_ipaddr($_POST['dst'])) && ($_POST['ipprotocol'] == "inet46"))
|
476
|
$input_errors[] = gettext("You can not use a IPv4 or IPv6 address in combined IPv4 + IPv6 rules.");
|
477
|
|
478
|
if ($_POST['srcbeginport'] > $_POST['srcendport']) {
|
479
|
/* swap */
|
480
|
$tmp = $_POST['srcendport'];
|
481
|
$_POST['srcendport'] = $_POST['srcbeginport'];
|
482
|
$_POST['srcbeginport'] = $tmp;
|
483
|
}
|
484
|
if ($_POST['dstbeginport'] > $_POST['dstendport']) {
|
485
|
/* swap */
|
486
|
$tmp = $_POST['dstendport'];
|
487
|
$_POST['dstendport'] = $_POST['dstbeginport'];
|
488
|
$_POST['dstbeginport'] = $tmp;
|
489
|
}
|
490
|
if ($_POST['os']) {
|
491
|
if( $_POST['proto'] != "tcp" )
|
492
|
$input_errors[] = gettext("OS detection is only valid with protocol tcp.");
|
493
|
if (!in_array($_POST['os'], $ostypes))
|
494
|
$input_errors[] = gettext("Invalid OS detection selection. Please select a valid OS.");
|
495
|
}
|
496
|
|
497
|
if ($_POST['ackqueue'] != "") {
|
498
|
if ($_POST['defaultqueue'] == "" )
|
499
|
$input_errors[] = gettext("You have to select a queue when you select an acknowledge queue too.");
|
500
|
else if ($_POST['ackqueue'] == $_POST['defaultqueue'])
|
501
|
$input_errors[] = gettext("Acknowledge queue and Queue cannot be the same.");
|
502
|
}
|
503
|
if (isset($_POST['floating']) && $_POST['pdnpipe'] != "" && (empty($_POST['direction']) || $_POST['direction'] == "any"))
|
504
|
$input_errors[] = gettext("You can not use limiters in Floating rules without choosing a direction.");
|
505
|
if (isset($_POST['floating']) && $_POST['gateway'] != "" && (empty($_POST['direction']) || $_POST['direction'] == "any"))
|
506
|
$input_errors[] = gettext("You can not use gateways in Floating rules without choosing a direction.");
|
507
|
if ($_POST['pdnpipe'] && $_POST['pdnpipe'] != "") {
|
508
|
if ($_POST['dnpipe'] == "" )
|
509
|
$input_errors[] = gettext("You must select a queue for the In direction before selecting one for Out too.");
|
510
|
else if ($_POST['pdnpipe'] == $_POST['dnpipe'])
|
511
|
$input_errors[] = gettext("In and Out Queue cannot be the same.");
|
512
|
else if ($dnqlist[$_POST['pdnpipe']][0] == "?" && $dnqlist[$_POST['dnpipe']][0] <> "?")
|
513
|
$input_errors[] = gettext("You cannot select one queue and one virtual interface for IN and Out. both must be from the same type.");
|
514
|
else if ($dnqlist[$_POST['dnpipe']][0] == "?" && $dnqlist[$_POST['pdnpipe']][0] <> "?")
|
515
|
$input_errors[] = gettext("You cannot select one queue and one virtual interface for IN and Out. both must be from the same type.");
|
516
|
if ($_POST['direction'] == "out" && empty($_POST['gateway']))
|
517
|
$input_errors[] = gettext("Please select a gateway, normaly the interface selected gateway, so the limiters work correctly");
|
518
|
}
|
519
|
if( !empty($_POST['ruleid']) && !ctype_digit($_POST['ruleid']))
|
520
|
$input_errors[] = gettext('ID must be an integer');
|
521
|
if($_POST['l7container'] && $_POST['l7container'] != "") {
|
522
|
if(!($_POST['proto'] == "tcp" || $_POST['proto'] == "udp" || $_POST['proto'] == "tcp/udp"))
|
523
|
$input_errors[] = gettext("You can only select a layer7 container for TCP and/or UDP protocols");
|
524
|
if ($_POST['type'] <> "pass")
|
525
|
$input_errors[] = gettext("You can only select a layer7 container for Pass type rules.");
|
526
|
}
|
527
|
|
528
|
if (!in_array($_POST['proto'], array("tcp","tcp/udp"))) {
|
529
|
if (!empty($_POST['max-src-conn']))
|
530
|
$input_errors[] = gettext("You can only specify the maximum number of established connections per host (advanced option) for TCP protocol.");
|
531
|
if (!empty($_POST['max-src-conn-rate']) || !empty($_POST['max-src-conn-rates']))
|
532
|
$input_errors[] = gettext("You can only specify the maximum new connections per host / per second(s) (advanced option) for TCP protocol.");
|
533
|
if (!empty($_POST['statetimeout']))
|
534
|
$input_errors[] = gettext("You can only specify the state timeout (advanced option) for TCP protocol.");
|
535
|
}
|
536
|
|
537
|
if ($_POST['type'] <> "pass") {
|
538
|
if (!empty($_POST['max']))
|
539
|
$input_errors[] = gettext("You can only specify the maximum state entries (advanced option) for Pass type rules.");
|
540
|
if (!empty($_POST['max-src-nodes']))
|
541
|
$input_errors[] = gettext("You can only specify the maximum number of unique source hosts (advanced option) for Pass type rules.");
|
542
|
if (!empty($_POST['max-src-conn']))
|
543
|
$input_errors[] = gettext("You can only specify the maximum number of established connections per host (advanced option) for Pass type rules.");
|
544
|
if (!empty($_POST['max-src-states']))
|
545
|
$input_errors[] = gettext("You can only specify the maximum state entries per host (advanced option) for Pass type rules.");
|
546
|
if (!empty($_POST['max-src-conn-rate']) || !empty($_POST['max-src-conn-rates']))
|
547
|
$input_errors[] = gettext("You can only specify the maximum new connections per host / per second(s) (advanced option) for Pass type rules.");
|
548
|
if (!empty($_POST['statetimeout']))
|
549
|
$input_errors[] = gettext("You can only specify the state timeout (advanced option) for Pass type rules.");
|
550
|
}
|
551
|
|
552
|
if (($_POST['statetype'] == "none") && (empty($_POST['l7container']))) {
|
553
|
if (!empty($_POST['max']))
|
554
|
$input_errors[] = gettext("You cannot specify the maximum state entries (advanced option) if statetype is none and no L7 container is selected.");
|
555
|
if (!empty($_POST['max-src-nodes']))
|
556
|
$input_errors[] = gettext("You cannot specify the maximum number of unique source hosts (advanced option) if statetype is none and no L7 container is selected.");
|
557
|
if (!empty($_POST['max-src-conn']))
|
558
|
$input_errors[] = gettext("You cannot specify the maximum number of established connections per host (advanced option) if statetype is none and no L7 container is selected.");
|
559
|
if (!empty($_POST['max-src-states']))
|
560
|
$input_errors[] = gettext("You cannot specify the maximum state entries per host (advanced option) if statetype is none and no L7 container is selected.");
|
561
|
if (!empty($_POST['max-src-conn-rate']) || !empty($_POST['max-src-conn-rates']))
|
562
|
$input_errors[] = gettext("You cannot specify the maximum new connections per host / per second(s) (advanced option) if statetype is none and no L7 container is selected.");
|
563
|
if (!empty($_POST['statetimeout']))
|
564
|
$input_errors[] = gettext("You cannot specify the state timeout (advanced option) if statetype is none and no L7 container is selected.");
|
565
|
}
|
566
|
|
567
|
if (($_POST['max'] != "") && !is_posnumericint($_POST['max']))
|
568
|
$input_errors[] = gettext("Maximum state entries (advanced option) must be a positive integer");
|
569
|
|
570
|
if (($_POST['max-src-nodes'] != "") && !is_posnumericint($_POST['max-src-nodes']))
|
571
|
$input_errors[] = gettext("Maximum number of unique source hosts (advanced option) must be a positive integer");
|
572
|
|
573
|
if (($_POST['max-src-conn'] != "") && !is_posnumericint($_POST['max-src-conn']))
|
574
|
$input_errors[] = gettext("Maximum number of established connections per host (advanced option) must be a positive integer");
|
575
|
|
576
|
if (($_POST['max-src-states'] != "") && !is_posnumericint($_POST['max-src-states']))
|
577
|
$input_errors[] = gettext("Maximum state entries per host (advanced option) must be a positive integer");
|
578
|
|
579
|
if (($_POST['max-src-conn-rate'] != "") && !is_posnumericint($_POST['max-src-conn-rate']))
|
580
|
$input_errors[] = gettext("Maximum new connections per host / per second(s) (advanced option) must be a positive integer");
|
581
|
|
582
|
if (($_POST['statetimeout'] != "") && !is_posnumericint($_POST['statetimeout']))
|
583
|
$input_errors[] = gettext("State timeout (advanced option) must be a positive integer");
|
584
|
|
585
|
if ((($_POST['max-src-conn-rate'] <> "" and $_POST['max-src-conn-rates'] == "")) ||
|
586
|
(($_POST['max-src-conn-rate'] == "" and $_POST['max-src-conn-rates'] <> "")))
|
587
|
$input_errors[] = gettext("Both maximum new connections per host and the interval (per second(s)) must be specified");
|
588
|
|
589
|
if (!$_POST['tcpflags_any']) {
|
590
|
$settcpflags = array();
|
591
|
$outoftcpflags = array();
|
592
|
foreach ($tcpflags as $tcpflag) {
|
593
|
if ($_POST['tcpflags1_' . $tcpflag] == "on")
|
594
|
$settcpflags[] = $tcpflag;
|
595
|
if ($_POST['tcpflags2_' . $tcpflag] == "on")
|
596
|
$outoftcpflags[] = $tcpflag;
|
597
|
}
|
598
|
if (empty($outoftcpflags) && !empty($settcpflags))
|
599
|
$input_errors[] = gettext("If you specify TCP flags that should be set you should specify out of which flags as well.");
|
600
|
}
|
601
|
|
602
|
// Allow extending of the firewall edit page and include custom input validation
|
603
|
pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/input_validation");
|
604
|
|
605
|
if (!$input_errors) {
|
606
|
$filterent = array();
|
607
|
$filterent['id'] = $_POST['ruleid']>0?$_POST['ruleid']:'';
|
608
|
|
609
|
$filterent['tracker'] = empty($_POST['tracker']) ? (int)microtime(true) : $_POST['tracker'];
|
610
|
|
611
|
$filterent['type'] = $_POST['type'];
|
612
|
if (isset($_POST['interface'] ))
|
613
|
$filterent['interface'] = $_POST['interface'];
|
614
|
|
615
|
if (isset($_POST['ipprotocol'] ))
|
616
|
$filterent['ipprotocol'] = $_POST['ipprotocol'];
|
617
|
|
618
|
if ($_POST['tcpflags_any']) {
|
619
|
$filterent['tcpflags_any'] = true;
|
620
|
} else {
|
621
|
$settcpflags = array();
|
622
|
$outoftcpflags = array();
|
623
|
foreach ($tcpflags as $tcpflag) {
|
624
|
if ($_POST['tcpflags1_' . $tcpflag] == "on")
|
625
|
$settcpflags[] = $tcpflag;
|
626
|
if ($_POST['tcpflags2_' . $tcpflag] == "on")
|
627
|
$outoftcpflags[] = $tcpflag;
|
628
|
}
|
629
|
if (!empty($outoftcpflags)) {
|
630
|
$filterent['tcpflags2'] = join(",", $outoftcpflags);
|
631
|
if (!empty($settcpflags))
|
632
|
$filterent['tcpflags1'] = join(",", $settcpflags);
|
633
|
}
|
634
|
}
|
635
|
|
636
|
if (isset($_POST['tag']))
|
637
|
$filterent['tag'] = $_POST['tag'];
|
638
|
if (isset($_POST['tagged']))
|
639
|
$filterent['tagged'] = $_POST['tagged'];
|
640
|
if ($if == "FloatingRules" || isset($_POST['floating'])) {
|
641
|
$filterent['direction'] = $_POST['direction'];
|
642
|
if (isset($_POST['quick']) && $_POST['quick'] <> "")
|
643
|
$filterent['quick'] = $_POST['quick'];
|
644
|
$filterent['floating'] = "yes";
|
645
|
if (isset($_POST['interface']) && count($_POST['interface']) > 0) {
|
646
|
$filterent['interface'] = implode(",", $_POST['interface']);
|
647
|
}
|
648
|
}
|
649
|
|
650
|
/* Advanced options */
|
651
|
if ($_POST['allowopts'] == "yes")
|
652
|
$filterent['allowopts'] = true;
|
653
|
else
|
654
|
unset($filterent['allowopts']);
|
655
|
if ($_POST['disablereplyto'] == "yes")
|
656
|
$filterent['disablereplyto'] = true;
|
657
|
else
|
658
|
unset($filterent['disablereplyto']);
|
659
|
$filterent['max'] = $_POST['max'];
|
660
|
$filterent['max-src-nodes'] = $_POST['max-src-nodes'];
|
661
|
$filterent['max-src-conn'] = $_POST['max-src-conn'];
|
662
|
$filterent['max-src-states'] = $_POST['max-src-states'];
|
663
|
$filterent['statetimeout'] = $_POST['statetimeout'];
|
664
|
$filterent['statetype'] = $_POST['statetype'];
|
665
|
$filterent['os'] = $_POST['os'];
|
666
|
if($_POST['nopfsync'] <> "")
|
667
|
$filterent['nopfsync'] = true;
|
668
|
else
|
669
|
unset($filterent['nopfsync']);
|
670
|
|
671
|
/* Nosync directive - do not xmlrpc sync this item */
|
672
|
if($_POST['nosync'] <> "")
|
673
|
$filterent['nosync'] = true;
|
674
|
else
|
675
|
unset($filterent['nosync']);
|
676
|
|
677
|
/* unless both values are provided, unset the values - ticket #650 */
|
678
|
if($_POST['max-src-conn-rate'] <> "" and $_POST['max-src-conn-rates'] <> "") {
|
679
|
$filterent['max-src-conn-rate'] = $_POST['max-src-conn-rate'];
|
680
|
$filterent['max-src-conn-rates'] = $_POST['max-src-conn-rates'];
|
681
|
} else {
|
682
|
unset($filterent['max-src-conn-rate']);
|
683
|
unset($filterent['max-src-conn-rates']);
|
684
|
}
|
685
|
|
686
|
if ($_POST['proto'] != "any")
|
687
|
$filterent['protocol'] = $_POST['proto'];
|
688
|
else
|
689
|
unset($filterent['protocol']);
|
690
|
|
691
|
if ($_POST['proto'] == "icmp" && $_POST['icmptype'])
|
692
|
$filterent['icmptype'] = $_POST['icmptype'];
|
693
|
else
|
694
|
unset($filterent['icmptype']);
|
695
|
|
696
|
pconfig_to_address($filterent['source'], $_POST['src'],
|
697
|
$_POST['srcmask'], $_POST['srcnot'],
|
698
|
$_POST['srcbeginport'], $_POST['srcendport']);
|
699
|
|
700
|
pconfig_to_address($filterent['destination'], $_POST['dst'],
|
701
|
$_POST['dstmask'], $_POST['dstnot'],
|
702
|
$_POST['dstbeginport'], $_POST['dstendport']);
|
703
|
|
704
|
if ($_POST['disabled'])
|
705
|
$filterent['disabled'] = true;
|
706
|
else
|
707
|
unset($filterent['disabled']);
|
708
|
|
709
|
if ($_POST['dscp'])
|
710
|
$filterent['dscp'] = $_POST['dscp'];
|
711
|
|
712
|
if ($_POST['log'])
|
713
|
$filterent['log'] = true;
|
714
|
else
|
715
|
unset($filterent['log']);
|
716
|
strncpy($filterent['descr'], $_POST['descr'], 52);
|
717
|
|
718
|
if ($_POST['gateway'] != "") {
|
719
|
$filterent['gateway'] = $_POST['gateway'];
|
720
|
}
|
721
|
|
722
|
if ($_POST['defaultqueue'] != "") {
|
723
|
$filterent['defaultqueue'] = $_POST['defaultqueue'];
|
724
|
if ($_POST['ackqueue'] != "")
|
725
|
$filterent['ackqueue'] = $_POST['ackqueue'];
|
726
|
}
|
727
|
|
728
|
if ($_POST['dnpipe'] != "") {
|
729
|
$filterent['dnpipe'] = $_POST['dnpipe'];
|
730
|
if ($_POST['pdnpipe'] != "")
|
731
|
$filterent['pdnpipe'] = $_POST['pdnpipe'];
|
732
|
}
|
733
|
|
734
|
if ($_POST['l7container'] != "") {
|
735
|
$filterent['l7container'] = $_POST['l7container'];
|
736
|
}
|
737
|
|
738
|
if ($_POST['sched'] != "") {
|
739
|
$filterent['sched'] = $_POST['sched'];
|
740
|
}
|
741
|
|
742
|
if ($_POST['vlanprio'] != "") {
|
743
|
$filterent['vlanprio'] = $_POST['vlanprio'];
|
744
|
}
|
745
|
if ($_POST['vlanprioset'] != "") {
|
746
|
$filterent['vlanprioset'] = $_POST['vlanprioset'];
|
747
|
}
|
748
|
|
749
|
// If we have an associated nat rule, make sure the source and destination doesn't change
|
750
|
if( isset($a_filter[$id]['associated-rule-id']) ) {
|
751
|
$filterent['interface'] = $a_filter[$id]['interface'];
|
752
|
if (isset($a_filter[$id]['protocol']))
|
753
|
$filterent['protocol'] = $a_filter[$id]['protocol'];
|
754
|
else if (isset($filterent['protocol']))
|
755
|
unset($filterent['protocol']);
|
756
|
if ($a_filter[$id]['protocol'] == "icmp" && $a_filter[$id]['icmptype'])
|
757
|
$filterent['icmptype'] = $a_filter[$id]['icmptype'];
|
758
|
else if (isset($filterent['icmptype']))
|
759
|
unset($filterent['icmptype']);
|
760
|
|
761
|
$filterent['source'] = $a_filter[$id]['source'];
|
762
|
$filterent['destination'] = $a_filter[$id]['destination'];
|
763
|
$filterent['associated-rule-id'] = $a_filter[$id]['associated-rule-id'];
|
764
|
}
|
765
|
|
766
|
if ( isset($a_filter[$id]['created']) && is_array($a_filter[$id]['created']) )
|
767
|
$filterent['created'] = $a_filter[$id]['created'];
|
768
|
|
769
|
$filterent['updated'] = make_config_revision_entry();
|
770
|
|
771
|
// Allow extending of the firewall edit page and include custom input validation
|
772
|
pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_write_config");
|
773
|
|
774
|
if (isset($id) && $a_filter[$id])
|
775
|
$a_filter[$id] = $filterent;
|
776
|
else {
|
777
|
$filterent['created'] = make_config_revision_entry();
|
778
|
if (is_numeric($after))
|
779
|
array_splice($a_filter, $after+1, 0, array($filterent));
|
780
|
else
|
781
|
$a_filter[] = $filterent;
|
782
|
}
|
783
|
|
784
|
filter_rules_sort();
|
785
|
|
786
|
if (write_config())
|
787
|
mark_subsystem_dirty('filter');
|
788
|
|
789
|
if (isset($_POST['floating']))
|
790
|
header("Location: firewall_rules.php?if=FloatingRules");
|
791
|
else
|
792
|
header("Location: firewall_rules.php?if=" . htmlspecialchars($_POST['interface']));
|
793
|
exit;
|
794
|
}
|
795
|
}
|
796
|
|
797
|
$pgtitle = array(gettext("Firewall"),gettext("Rules"),gettext("Edit"));
|
798
|
$shortcut_section = "firewall";
|
799
|
|
800
|
$closehead = false;
|
801
|
|
802
|
$page_filename = "firewall_rules_edit.php";
|
803
|
include("head.inc");
|
804
|
|
805
|
?>
|
806
|
<link rel="stylesheet" href="/javascript/chosen/chosen.css" />
|
807
|
</head>
|
808
|
|
809
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
810
|
<script type="text/javascript" src="/javascript/jquery.ipv4v6ify.js"></script>
|
811
|
<script src="/javascript/chosen/chosen.jquery.js" type="text/javascript"></script>
|
812
|
<?php include("fbegin.inc"); ?>
|
813
|
<?php pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_input_errors"); ?>
|
814
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
815
|
|
816
|
<form action="firewall_rules_edit.php" method="post" name="iform" id="iform">
|
817
|
<input type='hidden' name="ruleid" value="<?=(isset($pconfig['ruleid'])&&$pconfig['ruleid']>0)?htmlspecialchars($pconfig['ruleid']):''?>" />
|
818
|
|
819
|
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="firewall rules edit">
|
820
|
<tr>
|
821
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit Firewall rule");?></td>
|
822
|
</tr>
|
823
|
<?php
|
824
|
// Allow extending of the firewall edit page and include custom input validation
|
825
|
pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/htmlphpearly");
|
826
|
?>
|
827
|
<tr>
|
828
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Action");?></td>
|
829
|
<td width="78%" class="vtable">
|
830
|
<select name="type" class="formselect">
|
831
|
<?php $types = explode(" ", "Pass Block Reject"); foreach ($types as $type): ?>
|
832
|
<option value="<?=strtolower($type);?>" <?php if (strtolower($type) == strtolower($pconfig['type'])) echo "selected=\"selected\""; ?>>
|
833
|
<?=htmlspecialchars($type);?>
|
834
|
</option>
|
835
|
<?php endforeach; ?>
|
836
|
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
|
837
|
<option value="match" <?php if ("match" == strtolower($pconfig['type'])) echo "selected=\"selected\""; ?>>Match</option>
|
838
|
<?php endif; ?>
|
839
|
</select>
|
840
|
<br />
|
841
|
<span class="vexpl">
|
842
|
<?=gettext("Choose what to do with packets that match the criteria specified below.");?> <br />
|
843
|
<?=gettext("Hint: the difference between block and reject is that with reject, a packet (TCP RST or ICMP port unreachable for UDP) is returned to the sender, whereas with block the packet is dropped silently. In either case, the original packet is discarded.");?>
|
844
|
</span>
|
845
|
</td>
|
846
|
</tr>
|
847
|
<tr>
|
848
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled");?></td>
|
849
|
<td width="78%" class="vtable">
|
850
|
<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked=\"checked\""; ?> />
|
851
|
<strong><?=gettext("Disable this rule");?></strong><br />
|
852
|
<span class="vexpl"><?=gettext("Set this option to disable this rule without removing it from the list.");?></span>
|
853
|
</td>
|
854
|
</tr>
|
855
|
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
|
856
|
<tr>
|
857
|
<td width="22%" valign="top" class="vncellreq">
|
858
|
<?=gettext("Quick");?>
|
859
|
</td>
|
860
|
<td width="78%" class="vtable">
|
861
|
<input name="quick" type="checkbox" id="quick" value="yes" <?php if ($pconfig['quick']) echo "checked=\"checked\""; ?> />
|
862
|
<strong><?=gettext("Apply the action immediately on match.");?></strong><br />
|
863
|
<span class="vexpl"><?=gettext("Set this option if you need to apply this action to traffic that matches this rule immediately.");?></span>
|
864
|
</td>
|
865
|
</tr>
|
866
|
<?php endif; ?>
|
867
|
<?php $edit_disabled = ""; ?>
|
868
|
<?php if( isset($pconfig['associated-rule-id']) ): ?>
|
869
|
<tr>
|
870
|
<td width="22%" valign="top" class="vncell"><?=gettext("Associated filter rule");?></td>
|
871
|
<td width="78%" class="vtable">
|
872
|
<span class="red"><strong><?=gettext("Note: ");?></strong></span><?=gettext("This is associated to a NAT rule.");?><br />
|
873
|
<?=gettext("You cannot edit the interface, protocol, source, or destination of associated filter rules.");?><br />
|
874
|
<br />
|
875
|
<?php
|
876
|
$edit_disabled = "disabled";
|
877
|
if (is_array($config['nat']['rule'])) {
|
878
|
foreach( $config['nat']['rule'] as $index => $nat_rule ) {
|
879
|
if( isset($nat_rule['associated-rule-id']) && $nat_rule['associated-rule-id']==$pconfig['associated-rule-id'] ) {
|
880
|
echo "<a href=\"firewall_nat_edit.php?id={$index}\">" . gettext("View the NAT rule") . "</a><br />";
|
881
|
break;
|
882
|
}
|
883
|
}
|
884
|
}
|
885
|
echo "<input name='associated-rule-id' id='associated-rule-id' type='hidden' value='{$pconfig['associated-rule-id']}' />";
|
886
|
if (!empty($pconfig['interface']))
|
887
|
echo "<input name='interface' id='interface' type='hidden' value='{$pconfig['interface']}' />";
|
888
|
?>
|
889
|
<script type="text/javascript">
|
890
|
//<![CDATA[
|
891
|
editenabled = 0;
|
892
|
//]]>
|
893
|
</script>
|
894
|
</td>
|
895
|
</tr>
|
896
|
<?php endif; ?>
|
897
|
<tr>
|
898
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface");?></td>
|
899
|
<td width="78%" class="vtable">
|
900
|
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
|
901
|
<select name="interface[]" title="Select interfaces..." multiple="multiple" style="width:350px;" class="chzn-select" tabindex="2" <?=$edit_disabled;?>>
|
902
|
<?php else: ?>
|
903
|
<select name="interface" class="formselect" <?=$edit_disabled;?>>
|
904
|
<?php endif;
|
905
|
/* add group interfaces */
|
906
|
if (is_array($config['ifgroups']['ifgroupentry']))
|
907
|
foreach($config['ifgroups']['ifgroupentry'] as $ifgen)
|
908
|
if (have_ruleint_access($ifgen['ifname']))
|
909
|
$interfaces[$ifgen['ifname']] = $ifgen['ifname'];
|
910
|
$ifdescs = get_configured_interface_with_descr();
|
911
|
// Allow extending of the firewall edit page and include custom input validation
|
912
|
pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_interfaces_edit");
|
913
|
foreach ($ifdescs as $ifent => $ifdesc)
|
914
|
if(have_ruleint_access($ifent))
|
915
|
$interfaces[$ifent] = $ifdesc;
|
916
|
if ($config['l2tp']['mode'] == "server")
|
917
|
if(have_ruleint_access("l2tp"))
|
918
|
$interfaces['l2tp'] = "L2TP VPN";
|
919
|
if ($config['pptpd']['mode'] == "server")
|
920
|
if(have_ruleint_access("pptp"))
|
921
|
$interfaces['pptp'] = "PPTP VPN";
|
922
|
|
923
|
if (is_pppoe_server_enabled() && have_ruleint_access("pppoe"))
|
924
|
$interfaces['pppoe'] = "PPPoE VPN";
|
925
|
/* add ipsec interfaces */
|
926
|
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable']))
|
927
|
if(have_ruleint_access("enc0"))
|
928
|
$interfaces["enc0"] = "IPsec";
|
929
|
/* add openvpn/tun interfaces */
|
930
|
if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
|
931
|
$interfaces["openvpn"] = "OpenVPN";
|
932
|
if (is_array($pconfig['interface']))
|
933
|
$pconfig['interface'] = implode(",", $pconfig['interface']);
|
934
|
$selected_interfaces = explode(",", $pconfig['interface']);
|
935
|
foreach ($interfaces as $iface => $ifacename): ?>
|
936
|
<option value="<?=$iface;?>" <?php if ($pconfig['interface'] <> "" && ( strcasecmp($pconfig['interface'], $iface) == 0 || in_array($iface, $selected_interfaces) )) echo "selected=\"selected\""; ?>><?=$ifacename?></option>
|
937
|
<?php endforeach; ?>
|
938
|
</select>
|
939
|
<br />
|
940
|
<span class="vexpl"><?=gettext("Choose on which interface packets must come in to match this rule.");?></span>
|
941
|
</td>
|
942
|
</tr>
|
943
|
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
|
944
|
<tr>
|
945
|
<td width="22%" valign="top" class="vncellreq">
|
946
|
<?=gettext("Direction");?>
|
947
|
</td>
|
948
|
<td width="78%" class="vtable">
|
949
|
<select name="direction" class="formselect">
|
950
|
<?php $directions = array('any','in','out');
|
951
|
foreach ($directions as $direction): ?>
|
952
|
<option value="<?=$direction;?>"
|
953
|
<?php if ($direction == $pconfig['direction']): ?>
|
954
|
selected="selected"
|
955
|
<?php endif; ?>
|
956
|
><?=$direction;?></option>
|
957
|
<?php endforeach; ?>
|
958
|
</select>
|
959
|
<input type="hidden" id="floating" name="floating" value="floating" />
|
960
|
</td>
|
961
|
<tr>
|
962
|
<?php endif; ?>
|
963
|
<tr>
|
964
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("TCP/IP Version");?></td>
|
965
|
<td width="78%" class="vtable">
|
966
|
<select name="ipprotocol" class="formselect">
|
967
|
<?php $ipproto = array('inet' => 'IPv4','inet6' => 'IPv6', 'inet46' => 'IPv4+IPv6' );
|
968
|
foreach ($ipproto as $proto => $name): ?>
|
969
|
<option value="<?=$proto;?>"
|
970
|
<?php if ($proto == $pconfig['ipprotocol']): ?>
|
971
|
selected="selected"
|
972
|
<?php endif; ?>
|
973
|
><?=$name;?></option>
|
974
|
<?php endforeach; ?>
|
975
|
</select>
|
976
|
<strong><?=gettext("Select the Internet Protocol version this rule applies to");?></strong><br />
|
977
|
</td>
|
978
|
</tr>
|
979
|
<tr>
|
980
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
|
981
|
<td width="78%" class="vtable">
|
982
|
<select <?=$edit_disabled;?> name="proto" class="formselect" onchange="proto_change()">
|
983
|
<?php
|
984
|
$protocols = explode(" ", "TCP UDP TCP/UDP ICMP ESP AH GRE IPV6 IGMP PIM OSPF any carp pfsync");
|
985
|
foreach ($protocols as $proto): ?>
|
986
|
<option value="<?=strtolower($proto);?>" <?php if (strtolower($proto) == $pconfig['proto']) echo "selected=\"selected\""; ?>><?=htmlspecialchars($proto);?></option>
|
987
|
<?php endforeach; ?>
|
988
|
</select>
|
989
|
<br />
|
990
|
<span class="vexpl"><?=gettext("Choose which IP protocol this rule should match.");?> <br /> <?=gettext("Hint: in most cases, you should specify ");?><em>TCP</em> <?=gettext("here.");?></span>
|
991
|
</td>
|
992
|
</tr>
|
993
|
<tr id="icmpbox">
|
994
|
<td valign="top" class="vncell"><?=gettext("ICMP type");?></td>
|
995
|
<td class="vtable">
|
996
|
<select <?=$edit_disabled;?> name="icmptype" class="formselect">
|
997
|
<?php
|
998
|
$icmptypes = array(
|
999
|
"" => gettext("any"),
|
1000
|
"echoreq" => gettext("Echo request"),
|
1001
|
"echorep" => gettext("Echo reply"),
|
1002
|
"unreach" => gettext("Destination unreachable"),
|
1003
|
"squench" => gettext("Source quench"),
|
1004
|
"redir" => gettext("Redirect"),
|
1005
|
"althost" => gettext("Alternate Host"),
|
1006
|
"routeradv" => gettext("Router advertisement"),
|
1007
|
"routersol" => gettext("Router solicitation"),
|
1008
|
"timex" => gettext("Time exceeded"),
|
1009
|
"paramprob" => gettext("Invalid IP header"),
|
1010
|
"timereq" => gettext("Timestamp"),
|
1011
|
"timerep" => gettext("Timestamp reply"),
|
1012
|
"inforeq" => gettext("Information request"),
|
1013
|
"inforep" => gettext("Information reply"),
|
1014
|
"maskreq" => gettext("Address mask request"),
|
1015
|
"maskrep" => gettext("Address mask reply")
|
1016
|
);
|
1017
|
|
1018
|
foreach ($icmptypes as $icmptype => $descr): ?>
|
1019
|
<option value="<?=$icmptype;?>" <?php if ($icmptype == $pconfig['icmptype']) echo "selected=\"selected\""; ?>><?=htmlspecialchars($descr);?></option>
|
1020
|
<?php endforeach; ?>
|
1021
|
</select>
|
1022
|
<br />
|
1023
|
<span class="vexpl"><?=gettext("If you selected ICMP for the protocol above, you may specify an ICMP type here.");?></span>
|
1024
|
</td>
|
1025
|
</tr>
|
1026
|
<tr>
|
1027
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Source");?></td>
|
1028
|
<td width="78%" class="vtable">
|
1029
|
<input <?=$edit_disabled;?> name="srcnot" type="checkbox" id="srcnot" value="yes" <?php if ($pconfig['srcnot']) echo "checked=\"checked\""; ?> />
|
1030
|
<strong><?=gettext("not");?></strong>
|
1031
|
<br />
|
1032
|
<?=gettext("Use this option to invert the sense of the match.");?>
|
1033
|
<br />
|
1034
|
<br />
|
1035
|
<table border="0" cellspacing="0" cellpadding="0">
|
1036
|
<tr>
|
1037
|
<td><?=gettext("Type:");?> </td>
|
1038
|
<td>
|
1039
|
<select <?=$edit_disabled;?> name="srctype" class="formselect" onchange="typesel_change()">
|
1040
|
<?php
|
1041
|
$sel = is_specialnet($pconfig['src']); ?>
|
1042
|
<option value="any" <?php if ($pconfig['src'] == "any") { echo "selected=\"selected\""; } ?>><?=gettext("any");?></option>
|
1043
|
<option value="single"
|
1044
|
<?php if (!$sel &&
|
1045
|
((is_ipaddrv6($pconfig['src']) && $pconfig['srcmask'] == 128) ||
|
1046
|
(is_ipaddrv4($pconfig['src']) && $pconfig['srcmask'] == 32) || is_alias($pconfig['src'])))
|
1047
|
{ echo "selected=\"selected\""; $sel = 1; }
|
1048
|
?>
|
1049
|
> <?=gettext("Single host or alias");?></option>
|
1050
|
<option value="network" <?php if (!$sel) echo "selected=\"selected\""; ?>><?=gettext("Network");?></option>
|
1051
|
<?PHP if (isset($a_filter[$id]['floating']) || $if == "FloatingRules"): ?>
|
1052
|
<option value="(self)" <?PHP if ($pconfig['src'] == "(self)") echo "selected=\"selected\""; ?>><?=gettext("This Firewall (self)");?></option>
|
1053
|
<?PHP endif;?>
|
1054
|
<?php if(have_ruleint_access("pptp")): ?>
|
1055
|
<option value="pptp" <?php if ($pconfig['src'] == "pptp") { echo "selected=\"selected\""; } ?>><?=gettext("PPTP clients");?></option>
|
1056
|
<?php endif; ?>
|
1057
|
<?php if(have_ruleint_access("pppoe")): ?>
|
1058
|
<option value="pppoe" <?php if ($pconfig['src'] == "pppoe") { echo "selected=\"selected\""; } ?>><?=gettext("PPPoE clients");?></option>
|
1059
|
<?php endif; ?>
|
1060
|
<?php if(have_ruleint_access("l2tp")): ?>
|
1061
|
<option value="l2tp" <?php if ($pconfig['src'] == "l2tp") { echo "selected=\"selected\""; } ?>><?=gettext("L2TP clients");?></option>
|
1062
|
<?php endif; ?>
|
1063
|
<?php
|
1064
|
foreach ($ifdisp as $ifent => $ifdesc): ?>
|
1065
|
<?php if(have_ruleint_access($ifent)): ?>
|
1066
|
<option value="<?=$ifent;?>" <?php if ($pconfig['src'] == $ifent) { echo "selected=\"selected\""; } ?>><?=htmlspecialchars($ifdesc);?> <?=gettext("net");?></option>
|
1067
|
<option value="<?=$ifent;?>ip"<?php if ($pconfig['src'] == $ifent . "ip") { echo "selected=\"selected\""; } ?>>
|
1068
|
<?=$ifdesc?> <?=gettext("address");?>
|
1069
|
</option>
|
1070
|
<?php endif; ?>
|
1071
|
<?php endforeach; ?>
|
1072
|
</select>
|
1073
|
</td>
|
1074
|
</tr>
|
1075
|
<tr>
|
1076
|
<td><?=gettext("Address:");?> </td>
|
1077
|
<td>
|
1078
|
<input <?=$edit_disabled;?> autocomplete='off' name="src" type="text" class="formfldalias ipv4v6" id="src" size="20" value="<?php if (!is_specialnet($pconfig['src'])) echo htmlspecialchars($pconfig['src']);?>" /> /
|
1079
|
<select <?=$edit_disabled;?> name="srcmask" class="formselect ipv4v6" id="srcmask">
|
1080
|
<?php for ($i = 127; $i > 0; $i--): ?>
|
1081
|
<option value="<?=$i;?>" <?php if ($i == $pconfig['srcmask']) echo "selected=\"selected\""; ?>><?=$i;?></option>
|
1082
|
<?php endfor; ?>
|
1083
|
</select>
|
1084
|
</td>
|
1085
|
</tr>
|
1086
|
</table>
|
1087
|
<div id="showadvancedboxspr">
|
1088
|
<p>
|
1089
|
<input <?=$edit_disabled;?> type="button" onclick="show_source_port_range()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show source port range");?>
|
1090
|
</p>
|
1091
|
</div>
|
1092
|
</td>
|
1093
|
</tr>
|
1094
|
<tr style="display:none" id="sprtable">
|
1095
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Source port range");?></td>
|
1096
|
<td width="78%" class="vtable">
|
1097
|
<table border="0" cellspacing="0" cellpadding="0">
|
1098
|
<tr>
|
1099
|
<td><?=gettext("from:");?> </td>
|
1100
|
<td>
|
1101
|
<select <?=$edit_disabled;?> name="srcbeginport" class="formselect" onchange="src_rep_change();ext_change()">
|
1102
|
<option value="">(<?=gettext("other"); ?>)</option>
|
1103
|
<option value="any" <?php $bfound = 0; if ($pconfig['srcbeginport'] == "any") { echo "selected=\"selected\""; $bfound = 1; } ?>><?=gettext("any");?></option>
|
1104
|
<?php foreach ($wkports as $wkport => $wkportdesc): ?>
|
1105
|
<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcbeginport']) { echo "selected=\"selected\""; $bfound = 1; } ?>><?=htmlspecialchars("{$wkportdesc} ({$wkport})");?></option>
|
1106
|
<?php endforeach; ?>
|
1107
|
</select>
|
1108
|
<input <?=$edit_disabled;?> autocomplete='off' class="formfldalias" name="srcbeginport_cust" id="srcbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcbeginport']) echo htmlspecialchars($pconfig['srcbeginport']); ?>" />
|
1109
|
</td>
|
1110
|
</tr>
|
1111
|
<tr>
|
1112
|
<td><?=gettext("to:");?></td>
|
1113
|
<td>
|
1114
|
<select <?=$edit_disabled;?> name="srcendport" class="formselect" onchange="ext_change()">
|
1115
|
<option value="">(<?=gettext("other"); ?>)</option>
|
1116
|
<option value="any" <?php $bfound = 0; if ($pconfig['srcendport'] == "any") { echo "selected=\"selected\""; $bfound = 1; } ?>><?=gettext("any");?></option>
|
1117
|
<?php foreach ($wkports as $wkport => $wkportdesc): ?>
|
1118
|
<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcendport']) { echo "selected=\"selected\""; $bfound = 1; } ?>><?=htmlspecialchars("{$wkportdesc} ({$wkport})");?></option>
|
1119
|
<?php endforeach; ?>
|
1120
|
</select>
|
1121
|
<input <?=$edit_disabled;?> autocomplete='off' class="formfldalias" name="srcendport_cust" id="srcendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcendport']) echo htmlspecialchars($pconfig['srcendport']); ?>" />
|
1122
|
</td>
|
1123
|
</tr>
|
1124
|
</table>
|
1125
|
<br />
|
1126
|
<span class="vexpl"><?=gettext("Specify the source port or port range for this rule."); ?> <b><?=gettext("This is usually"); ?> <em><?=gettext("random"); ?></em> <?=gettext("and almost never equal to the destination port range (and should usually be"); ?> "<?=gettext("any"); ?>").</b><br /><?=gettext("Hint: you can leave the"); ?> <em><?=gettext("'to'"); ?></em> <?=gettext("field empty if you only want to filter a single port.");?></span><br />
|
1127
|
</td>
|
1128
|
</tr>
|
1129
|
<tr>
|
1130
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Destination");?></td>
|
1131
|
<td width="78%" class="vtable">
|
1132
|
<input <?=$edit_disabled;?> name="dstnot" type="checkbox" id="dstnot" value="yes" <?php if ($pconfig['dstnot']) echo "checked=\"checked\""; ?> />
|
1133
|
<strong><?=gettext("not");?></strong>
|
1134
|
<br />
|
1135
|
<?=gettext("Use this option to invert the sense of the match.");?>
|
1136
|
<br />
|
1137
|
<br />
|
1138
|
<table border="0" cellspacing="0" cellpadding="0">
|
1139
|
<tr>
|
1140
|
<td><?=gettext("Type:");?> </td>
|
1141
|
<td>
|
1142
|
<select <?=$edit_disabled;?> name="dsttype" class="formselect" onchange="typesel_change()">
|
1143
|
<?php
|
1144
|
$sel = is_specialnet($pconfig['dst']); ?>
|
1145
|
<option value="any" <?php if ($pconfig['dst'] == "any") { echo "selected=\"selected\""; } ?>><?=gettext("any");?></option>
|
1146
|
<option value="single"
|
1147
|
<?php if (!$sel &&
|
1148
|
((is_ipaddrv6($pconfig['dst']) && $pconfig['dstmask'] == 128) ||
|
1149
|
(is_ipaddrv4($pconfig['dst']) && $pconfig['dstmask'] == 32) || is_alias($pconfig['dst'])))
|
1150
|
{ echo "selected=\"selected\""; $sel = 1; }
|
1151
|
?>
|
1152
|
><?=gettext("Single host or alias");?></option>
|
1153
|
<option value="network" <?php if (!$sel) echo "selected=\"selected\""; ?>><?=gettext("Network");?></option>
|
1154
|
<option value="(self)" <?PHP if ($pconfig['dst'] == "(self)") echo "selected=\"selected\""; ?>><?=gettext("This Firewall (self)");?></option>
|
1155
|
<?php if(have_ruleint_access("pptp")): ?>
|
1156
|
<option value="pptp" <?php if ($pconfig['dst'] == "pptp") { echo "selected=\"selected\""; } ?>><?=gettext("PPTP clients");?></option>
|
1157
|
<?php endif; ?>
|
1158
|
<?php if(have_ruleint_access("pppoe")): ?>
|
1159
|
<option value="pppoe" <?php if ($pconfig['dst'] == "pppoe") { echo "selected=\"selected\""; } ?>><?=gettext("PPPoE clients");?></option>
|
1160
|
<?php endif; ?>
|
1161
|
<?php if(have_ruleint_access("l2tp")): ?>
|
1162
|
<option value="l2tp" <?php if ($pconfig['dst'] == "l2tp") { echo "selected=\"selected\""; } ?>><?=gettext("L2TP clients");?></option>
|
1163
|
<?php endif; ?>
|
1164
|
|
1165
|
<?php foreach ($ifdisp as $if => $ifdesc): ?>
|
1166
|
<?php if(have_ruleint_access($if)): ?>
|
1167
|
<option value="<?=$if;?>" <?php if ($pconfig['dst'] == $if) { echo "selected=\"selected\""; } ?>><?=htmlspecialchars($ifdesc);?> <?=gettext("net");?></option>
|
1168
|
<option value="<?=$if;?>ip"<?php if ($pconfig['dst'] == $if . "ip") { echo "selected=\"selected\""; } ?>>
|
1169
|
<?=$ifdesc;?> <?=gettext("address");?>
|
1170
|
</option>
|
1171
|
<?php endif; ?>
|
1172
|
<?php endforeach; ?>
|
1173
|
</select>
|
1174
|
</td>
|
1175
|
</tr>
|
1176
|
<tr>
|
1177
|
<td><?=gettext("Address:");?> </td>
|
1178
|
<td>
|
1179
|
<input <?=$edit_disabled;?> autocomplete='off' name="dst" type="text" class="formfldalias ipv4v6" id="dst" size="20" value="<?php if (!is_specialnet($pconfig['dst'])) echo htmlspecialchars($pconfig['dst']);?>" />
|
1180
|
/
|
1181
|
<select <?=$edit_disabled;?> name="dstmask" class="formselect ipv4v6" id="dstmask">
|
1182
|
<?php
|
1183
|
for ($i = 127; $i > 0;
|
1184
|
$i--): ?>
|
1185
|
<option value="<?=$i;?>" <?php if ($i == $pconfig['dstmask']) echo "selected=\"selected\""; ?>><?=$i;?></option>
|
1186
|
<?php endfor; ?>
|
1187
|
</select>
|
1188
|
</td>
|
1189
|
</tr>
|
1190
|
</table>
|
1191
|
</td>
|
1192
|
</tr>
|
1193
|
<tr id="dprtr">
|
1194
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Destination port range ");?></td>
|
1195
|
<td width="78%" class="vtable">
|
1196
|
<table border="0" cellspacing="0" cellpadding="0">
|
1197
|
<tr>
|
1198
|
<td><?=gettext("from:");?> </td>
|
1199
|
<td>
|
1200
|
<select <?=$edit_disabled;?> name="dstbeginport" class="formselect" onchange="dst_rep_change();ext_change()">
|
1201
|
<option value="">(<?=gettext("other"); ?>)</option>
|
1202
|
<option value="any" <?php $bfound = 0; if ($pconfig['dstbeginport'] == "any") { echo "selected=\"selected\""; $bfound = 1; } ?>><?=gettext("any");?></option>
|
1203
|
<?php foreach ($wkports as $wkport => $wkportdesc): ?>
|
1204
|
<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstbeginport']) { echo "selected=\"selected\""; $bfound = 1; }?>><?=htmlspecialchars("{$wkportdesc} ({$wkport})");?></option>
|
1205
|
<?php endforeach; ?>
|
1206
|
</select>
|
1207
|
<input <?=$edit_disabled;?> autocomplete='off' class="formfldalias" name="dstbeginport_cust" id="dstbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstbeginport']) echo htmlspecialchars($pconfig['dstbeginport']); ?>" />
|
1208
|
</td>
|
1209
|
</tr>
|
1210
|
<tr>
|
1211
|
<td><?=gettext("to:");?></td>
|
1212
|
<td>
|
1213
|
<select <?=$edit_disabled;?> name="dstendport" class="formselect" onchange="ext_change()">
|
1214
|
<option value="">(<?=gettext("other"); ?>)</option>
|
1215
|
<option value="any" <?php $bfound = 0; if ($pconfig['dstendport'] == "any") { echo "selected=\"selected\""; $bfound = 1; } ?>><?=gettext("any");?></option>
|
1216
|
<?php foreach ($wkports as $wkport => $wkportdesc): ?>
|
1217
|
<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstendport']) { echo "selected=\"selected\""; $bfound = 1; } ?>><?=htmlspecialchars("{$wkportdesc} ({$wkport})");?></option>
|
1218
|
<?php endforeach; ?>
|
1219
|
</select>
|
1220
|
<input <?=$edit_disabled;?> autocomplete='off' class="formfldalias" name="dstendport_cust" id="dstendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstendport']) echo htmlspecialchars($pconfig['dstendport']); ?>" />
|
1221
|
</td>
|
1222
|
</tr>
|
1223
|
</table>
|
1224
|
<br />
|
1225
|
<span class="vexpl">
|
1226
|
<?=gettext("Specify the port or port range for the destination of the packet for this rule.");?>
|
1227
|
<br />
|
1228
|
<?=gettext("Hint: you can leave the"); ?> <em><?=gettext("'to'"); ?></em> <?=gettext("field empty if you only want to filter a single port");?>
|
1229
|
</span>
|
1230
|
</td>
|
1231
|
</tr>
|
1232
|
<tr>
|
1233
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Log");?></td>
|
1234
|
<td width="78%" class="vtable">
|
1235
|
<input name="log" type="checkbox" id="log" value="yes" <?php if ($pconfig['log']) echo "checked=\"checked\""; ?> />
|
1236
|
<strong><?=gettext("Log packets that are handled by this rule");?></strong>
|
1237
|
<br />
|
1238
|
<span class="vexpl"><?=gettext("Hint: the firewall has limited local log space. Don't turn on logging for everything. If you want to do a lot of logging, consider using a remote syslog server"); ?> (<?=gettext("see the"); ?> <a href="diag_logs_settings.php"><?=gettext("Diagnostics: System logs: Settings"); ?></a> <?=gettext("page"); ?>).</span>
|
1239
|
</td>
|
1240
|
</tr>
|
1241
|
<tr>
|
1242
|
<td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
|
1243
|
<td width="78%" class="vtable">
|
1244
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="52" maxlength="52" value="<?=htmlspecialchars($pconfig['descr']);?>" />
|
1245
|
<br />
|
1246
|
<span class="vexpl"><?=gettext("You may enter a description here for your reference.");?></span>
|
1247
|
</td>
|
1248
|
</tr>
|
1249
|
<?php if (!isset($id) || !($a_filter[$id] && firewall_check_for_advanced_options($a_filter[$id]) <> "")): ?>
|
1250
|
<tr>
|
1251
|
<td width="22%" valign="top"> </td>
|
1252
|
<td width="78%">
|
1253
|
<br />
|
1254
|
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" /> <input type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()" />
|
1255
|
<?php if (isset($id) && $a_filter[$id]): ?>
|
1256
|
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
|
1257
|
<?php endif; ?>
|
1258
|
<input name="after" type="hidden" value="<?=htmlspecialchars($after);?>" />
|
1259
|
</td>
|
1260
|
</tr>
|
1261
|
<?php endif; ?>
|
1262
|
<tr>
|
1263
|
<td> </td>
|
1264
|
</tr>
|
1265
|
<tr>
|
1266
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced features");?></td>
|
1267
|
</tr>
|
1268
|
<tr>
|
1269
|
<td width="22%" valign="top" class="vncell"><?=gettext("Source OS");?></td>
|
1270
|
<td width="78%" class="vtable">
|
1271
|
<div id="showadvsourceosbox" <?php if ($pconfig['os']) echo "style='display:none'"; ?>>
|
1272
|
<input type="button" onclick="show_advanced_sourceos()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
|
1273
|
</div>
|
1274
|
<div id="showsourceosadv" <?php if (empty($pconfig['os'])) echo "style='display:none'"; ?>>
|
1275
|
<?=gettext("OS Type:");?>
|
1276
|
<select name="os" id="os" class="formselect">
|
1277
|
<option value="" <?php if (empty($pconfig['os'])) echo "selected=\"selected\""; ?>>Any</option>
|
1278
|
<?php
|
1279
|
foreach ($ostypes as $ostype): ?>
|
1280
|
<option value="<?=$ostype;?>" <?php if ($ostype == $pconfig['os']) echo "selected=\"selected\""; ?>><?=htmlspecialchars($ostype);?></option>
|
1281
|
<?php
|
1282
|
endforeach;
|
1283
|
?>
|
1284
|
</select>
|
1285
|
<br />
|
1286
|
<?=gettext("Note: this only works for TCP rules. General OS choice matches all subtypes.");?>
|
1287
|
</div>
|
1288
|
</td>
|
1289
|
</tr>
|
1290
|
<tr>
|
1291
|
<td width="22%" valign="top" class="vncell"><?=gettext("Diffserv Code Point");?></td>
|
1292
|
<td width="78%" class="vtable">
|
1293
|
<div id="dsadv" <?php if ($pconfig['dscp']) echo "style='display:none'"; ?>>
|
1294
|
<input type="button" onclick="show_dsdiv();" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
|
1295
|
</div>
|
1296
|
<div id="dsdivmain" <?php if (empty($pconfig['dscp'])) echo "style='display:none'"; ?>>
|
1297
|
<select name="dscp" id="dscp">
|
1298
|
<option value=""></option>
|
1299
|
<?php foreach($firewall_rules_dscp_types as $frdt): ?>
|
1300
|
<option value="<?=$frdt?>"<?php if($pconfig['dscp'] == $frdt) echo " selected=\"selected\""; ?>><?=$frdt?></option>
|
1301
|
<?php endforeach; ?>
|
1302
|
</select>
|
1303
|
</div>
|
1304
|
</td>
|
1305
|
</tr>
|
1306
|
<tr>
|
1307
|
<td width="22%" valign="top" class="vncell"><?=gettext("Advanced Options");?></td>
|
1308
|
<td width="78%" class="vtable">
|
1309
|
<div id="aoadv" <?php if (is_aoadv_used($pconfig)) echo "style='display:none'"; ?>>
|
1310
|
<input type="button" onclick="show_aodiv();" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
|
1311
|
</div>
|
1312
|
<div id="aodivmain" <?php if (!is_aoadv_used($pconfig)) echo "style='display:none'"; ?>>
|
1313
|
<input type="checkbox" id="allowopts" value="yes" name="allowopts"<?php if($pconfig['allowopts'] == true) echo " checked=\"checked\""; ?> />
|
1314
|
<br /><span class="vexpl"><?=gettext("This allows packets with IP options to pass. Otherwise they are blocked by default. This is usually only seen with multicast traffic.");?>
|
1315
|
</span><p>
|
1316
|
<input type="checkbox" id="disablereplyto" value="yes" name="disablereplyto"<?php if($pconfig['disablereplyto'] == true) echo " checked=\"checked\""; ?> />
|
1317
|
<br /><span class="vexpl"><?=gettext("This will disable auto generated reply-to for this rule.");?>
|
1318
|
</span></p><p>
|
1319
|
<input name="tag" id="tag" value="<?=htmlspecialchars($pconfig['tag']);?>" />
|
1320
|
<br /><span class="vexpl"><?=gettext("You can mark a packet matching this rule and use this mark to match on other NAT/filter rules. It is called"); ?> <b><?=gettext("Policy filtering"); ?></b>
|
1321
|
</span></p><p>
|
1322
|
<input name="tagged" id="tagged" value="<?=htmlspecialchars($pconfig['tagged']);?>" />
|
1323
|
<br /><span class="vexpl"><?=gettext("You can match packet on a mark placed before on another rule.")?>
|
1324
|
</span></p><p>
|
1325
|
<input name="max" id="max" value="<?php echo htmlspecialchars($pconfig['max']) ?>" /><br /><?=gettext(" Maximum state entries this rule can create");?></p><p>
|
1326
|
<input name="max-src-nodes" id="max-src-nodes" value="<?php echo htmlspecialchars($pconfig['max-src-nodes']) ?>" /><br /><?=gettext(" Maximum number of unique source hosts");?></p><p>
|
1327
|
<input name="max-src-conn" id="max-src-conn" value="<?php echo htmlspecialchars($pconfig['max-src-conn']) ?>" /><br /><?=gettext(" Maximum number of established connections per host (TCP only)");?></p><p>
|
1328
|
<input name="max-src-states" id="max-src-states" value="<?php echo htmlspecialchars($pconfig['max-src-states']) ?>" /><br /><?=gettext(" Maximum state entries per host");?></p><p>
|
1329
|
<input name="max-src-conn-rate" id="max-src-conn-rate" value="<?php echo htmlspecialchars($pconfig['max-src-conn-rate']) ?>" /> /
|
1330
|
<select name="max-src-conn-rates" id="max-src-conn-rates">
|
1331
|
<option value=""<?php if(intval($pconfig['max-src-conn-rates']) < 1) echo " selected=\"selected\""; ?>></option>
|
1332
|
<?php for($x=1; $x<255; $x++) {
|
1333
|
if($x == $pconfig['max-src-conn-rates']) $selected = " selected=\"selected\""; else $selected = "";
|
1334
|
echo "<option value=\"{$x}\"{$selected}>{$x}</option>\n";
|
1335
|
} ?>
|
1336
|
</select><br />
|
1337
|
<?=gettext("Maximum new connections per host / per second(s) (TCP only)");?>
|
1338
|
</p><p>
|
1339
|
<input name="statetimeout" value="<?php echo htmlspecialchars($pconfig['statetimeout']) ?>" /><br />
|
1340
|
<?=gettext("State Timeout in seconds (TCP only)");?>
|
1341
|
</p>
|
1342
|
<p><strong><?=gettext("Note: Leave fields blank to disable that feature.");?></strong></p>
|
1343
|
</div>
|
1344
|
</td>
|
1345
|
</tr>
|
1346
|
<tr id="tcpflags">
|
1347
|
<td width="22%" valign="top" class="vncell"><?=gettext("TCP flags");?></td>
|
1348
|
<td width="78%" class="vtable">
|
1349
|
<div id="showtcpflagsbox" <?php if ($pconfig['tcpflags_any'] || $pconfig['tcpflags1'] || $pconfig['tcpflags2']) echo "style='display:none'"; ?>>
|
1350
|
<input type="button" onclick="show_advanced_tcpflags()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
|
1351
|
</div>
|
1352
|
<div id="showtcpflagsadv" <?php if (empty($pconfig['tcpflags_any']) && empty($pconfig['tcpflags1']) && empty($pconfig['tcpflags2'])) echo "style='display:none'"; ?>>
|
1353
|
<div id="tcpheader" align="center">
|
1354
|
<table border="0" cellspacing="0" cellpadding="0">
|
1355
|
<?php
|
1356
|
$setflags = explode(",", $pconfig['tcpflags1']);
|
1357
|
$outofflags = explode(",", $pconfig['tcpflags2']);
|
1358
|
$header = "<td width='40' class='nowrap'></td>";
|
1359
|
$tcpflags1 = "<td width='40' class='nowrap'>set</td>";
|
1360
|
$tcpflags2 = "<td width='40' class='nowrap'>out of</td>";
|
1361
|
foreach ($tcpflags as $tcpflag) {
|
1362
|
$header .= "<td width='40' class='nowrap'><strong>" . strtoupper($tcpflag) . "</strong></td>\n";
|
1363
|
$tcpflags1 .= "<td width='40' class='nowrap'> <input type='checkbox' name='tcpflags1_{$tcpflag}' value='on' ";
|
1364
|
if (array_search($tcpflag, $setflags) !== false)
|
1365
|
$tcpflags1 .= "checked=\"checked\"";
|
1366
|
$tcpflags1 .= " /></td>\n";
|
1367
|
$tcpflags2 .= "<td width='40' class='nowrap'> <input type='checkbox' name='tcpflags2_{$tcpflag}' value='on' ";
|
1368
|
if (array_search($tcpflag, $outofflags) !== false)
|
1369
|
$tcpflags2 .= "checked=\"checked\"";
|
1370
|
$tcpflags2 .= " /></td>\n";
|
1371
|
}
|
1372
|
echo "<tr id='tcpheader'>{$header}</tr>\n";
|
1373
|
echo "<tr id='tcpflags1'>{$tcpflags1}</tr>\n";
|
1374
|
echo "<tr id='tcpflags2'>{$tcpflags2}</tr>\n";
|
1375
|
?>
|
1376
|
</table>
|
1377
|
</div>
|
1378
|
<br /><center>
|
1379
|
<input onclick='tcpflags_anyclick(this);' type='checkbox' name='tcpflags_any' value='on' <?php if ($pconfig['tcpflags_any']) echo "checked=\"checked\""; ?> /><strong><?=gettext("Any flags.");?></strong><br /></center>
|
1380
|
<br />
|
1381
|
<span class="vexpl"><?=gettext("Use this to choose TCP flags that must ".
|
1382
|
"be set or cleared for this rule to match.");?></span>
|
1383
|
</div>
|
1384
|
</td>
|
1385
|
</tr>
|
1386
|
<tr>
|
1387
|
<td width="22%" valign="top" class="vncell"><?=gettext("State Type");?></td>
|
1388
|
<td width="78%" class="vtable">
|
1389
|
<div id="showadvstatebox" <?php if (!empty($pconfig['nopfsync']) || (!empty($pconfig['statetype']) && $pconfig['statetype'] != "keep state")) echo "style='display:none'"; ?>>
|
1390
|
<input type="button" onclick="show_advanced_state()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
|
1391
|
</div>
|
1392
|
<div id="showstateadv" <?php if (empty($pconfig['nopfsync']) && (empty($pconfig['statetype']) || $pconfig['statetype'] == "keep state")) echo "style='display:none'"; ?>>
|
1393
|
<input name="nopfsync" type="checkbox" id="nopfsync" value="yes" <?php if ($pconfig['nopfsync']) echo "checked=\"checked\""; ?> />
|
1394
|
<span class="vexpl">
|
1395
|
NO pfsync<br />
|
1396
|
<?=gettext("Hint: This prevents states created by this rule to be sync'ed over pfsync.");?><br />
|
1397
|
</span><br />
|
1398
|
<select name="statetype">
|
1399
|
<option value="keep state" <?php if(!isset($pconfig['statetype']) or $pconfig['statetype'] == "keep state") echo "selected=\"selected\""; ?>><?=gettext("keep state");?></option>
|
1400
|
<option value="sloppy state" <?php if($pconfig['statetype'] == "sloppy state") echo "selected=\"selected\""; ?>><?=gettext("sloppy state");?></option>
|
1401
|
<option value="synproxy state"<?php if($pconfig['statetype'] == "synproxy state") echo "selected=\"selected\""; ?>><?=gettext("synproxy state");?></option>
|
1402
|
<option value="none"<?php if($pconfig['statetype'] == "none") echo "selected=\"selected\""; ?>><?=gettext("none");?></option>
|
1403
|
</select><br />
|
1404
|
<span class="vexpl">
|
1405
|
<?=gettext("Hint: Select which type of state tracking mechanism you would like to use. If in doubt, use keep state.");?>
|
1406
|
</span>
|
1407
|
<table width="90%">
|
1408
|
<tr><td width="25%"><ul><li><?=gettext("keep state");?></li></ul></td><td><?=gettext("Works with all IP protocols.");?></td></tr>
|
1409
|
<tr><td width="25%"><ul><li><?=gettext("sloppy state");?></li></ul></td><td><?=gettext("Works with all IP protocols.");?></td></tr>
|
1410
|
<tr><td width="25%"><ul><li><?=gettext("synproxy state");?></li></ul></td><td><?=gettext("Proxies incoming TCP connections to help protect servers from spoofed TCP SYN floods. This option includes the functionality of keep state and modulate state combined.");?></td></tr>
|
1411
|
<tr><td width="25%"><ul><li><?=gettext("none");?></li></ul></td><td><?=gettext("Do not use state mechanisms to keep track. This is only useful if you're doing advanced queueing in certain situations. Please check the documentation.");?></td></tr>
|
1412
|
</table>
|
1413
|
</div>
|
1414
|
</td>
|
1415
|
</tr>
|
1416
|
<tr>
|
1417
|
<td width="22%" valign="top" class="vncell"><?=gettext("No XMLRPC Sync");?></td>
|
1418
|
<td width="78%" class="vtable">
|
1419
|
<div id="showadvnoxmlrpcsyncbox" <?php if ($pconfig['nosync']) echo "style='display:none'"; ?>>
|
1420
|
<input type="button" onclick="show_advanced_noxmlrpc()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
|
1421
|
</div>
|
1422
|
<div id="shownoxmlrpcadv" <?php if (empty($pconfig['nosync'])) echo "style='display:none'"; ?>>
|
1423
|
<input type="checkbox" name="nosync"<?php if($pconfig['nosync']) echo " checked=\"checked\""; ?> /><br />
|
1424
|
<?=gettext("Hint: This prevents the rule on Master from automatically syncing to other CARP members. This does NOT prevent the rule from being overwritten on Slave.");?>
|
1425
|
</div>
|
1426
|
</td>
|
1427
|
</tr>
|
1428
|
<tr>
|
1429
|
<td width="22%" valign="top" class="vncell"><?=gettext("802.1p");?></td>
|
1430
|
<td width="78%" class="vtable">
|
1431
|
<div id="showadvvlanpriobox" <?php if (!empty($pconfig['vlanprio'])) echo "style='display:none'"; ?>>
|
1432
|
<input type="button" onclick="show_advanced_vlanprio()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
|
1433
|
</div>
|
1434
|
<div id="showvlanprioadv" <?php if (empty($pconfig['vlanprio'])) echo "style='display:none'"; ?>>
|
1435
|
<?php $vlanprio = array("none", "be", "bk", "ee", "ca", "vi", "vo", "ic", "nc"); ?>
|
1436
|
<?php
|
1437
|
$opts = "";
|
1438
|
foreach($vlanprio as $vprio) {
|
1439
|
if ($vprio == $pconfig['vlanprio'])
|
1440
|
$selected = " selected=\"selected\"";
|
1441
|
else
|
1442
|
$selected = "";
|
1443
|
if ($vprio == "none")
|
1444
|
$opts .= "<option value=\"\">{$vprio}</option>\n";
|
1445
|
else
|
1446
|
$opts .= "<option value=\"{$vprio}\" {$selected}>" . strtoupper($vprio) . "</option>\n";
|
1447
|
}
|
1448
|
|
1449
|
$optsset = "";
|
1450
|
foreach($vlanprio as $vprioset) {
|
1451
|
if ($vprioset == $pconfig['vlanprioset'])
|
1452
|
$selected = " selected=\"selected\"";
|
1453
|
else
|
1454
|
$selected = "";
|
1455
|
if ($vprioset == "none")
|
1456
|
$optsset .= "<option value=\"\">{$vprioset}</option>\n";
|
1457
|
else
|
1458
|
$optsset .= "<option value=\"{$vprioset}\" {$selected}>" . strtoupper($vprioset) . "</option>\n";
|
1459
|
}
|
1460
|
?>
|
1461
|
<select name='vlanprio'>
|
1462
|
<?php echo $opts; ?>
|
1463
|
</select>
|
1464
|
<p><?=gettext("Choose 802.1p priority to match on");?></p>
|
1465
|
<select name='vlanprioset'>
|
1466
|
<?php echo $optsset; ?>
|
1467
|
</select>
|
1468
|
<p><?=gettext("Choose 802.1p priority to apply");?></p>
|
1469
|
</div>
|
1470
|
</td>
|
1471
|
</tr>
|
1472
|
<?php
|
1473
|
//build list of schedules
|
1474
|
$schedules = array();
|
1475
|
$schedules[] = "none";//leave none to leave rule enabled all the time
|
1476
|
if(is_array($config['schedules']['schedule'])) {
|
1477
|
foreach ($config['schedules']['schedule'] as $schedule) {
|
1478
|
if ($schedule['name'] <> "")
|
1479
|
$schedules[] = $schedule['name'];
|
1480
|
}
|
1481
|
}
|
1482
|
?>
|
1483
|
<tr>
|
1484
|
<td width="22%" valign="top" class="vncell"><?=gettext("Schedule");?></td>
|
1485
|
<td width="78%" class="vtable">
|
1486
|
<div id="showadvschedulebox" <?php if (!empty($pconfig['sched'])) echo "style='display:none'"; ?>>
|
1487
|
<input type="button" onclick="show_advanced_schedule()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
|
1488
|
</div>
|
1489
|
<div id="showscheduleadv" <?php if (empty($pconfig['sched'])) echo "style='display:none'"; ?>>
|
1490
|
<select name='sched'>
|
1491
|
<?php
|
1492
|
foreach($schedules as $schedule) {
|
1493
|
if($schedule == $pconfig['sched']) {
|
1494
|
$selected = " selected=\"selected\"";
|
1495
|
} else {
|
1496
|
$selected = "";
|
1497
|
}
|
1498
|
if ($schedule == "none") {
|
1499
|
echo "<option value=\"\" {$selected}>{$schedule}</option>\n";
|
1500
|
} else {
|
1501
|
echo "<option value=\"{$schedule}\" {$selected}>{$schedule}</option>\n";
|
1502
|
}
|
1503
|
}
|
1504
|
?>
|
1505
|
</select>
|
1506
|
<p><?=gettext("Leave as 'none' to leave the rule enabled all the time.");?></p>
|
1507
|
</div>
|
1508
|
</td>
|
1509
|
</tr>
|
1510
|
<tr>
|
1511
|
<td width="22%" valign="top" class="vncell"><?=gettext("Gateway");?></td>
|
1512
|
<td width="78%" class="vtable">
|
1513
|
<div id="showadvgatewaybox" <?php if (!empty($pconfig['gateway'])) echo "style='display:none'"; ?>>
|
1514
|
<input type="button" onclick="show_advanced_gateway()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
|
1515
|
</div>
|
1516
|
<div id="showgatewayadv" <?php if (empty($pconfig['gateway'])) echo "style='display:none'"; ?>>
|
1517
|
<select name='gateway'>
|
1518
|
<option value="" ><?=gettext("default");?></option>
|
1519
|
<?php
|
1520
|
/* build a list of gateways */
|
1521
|
$gateways = return_gateways_array();
|
1522
|
// add statically configured gateways to list
|
1523
|
foreach($gateways as $gwname => $gw) {
|
1524
|
if(($pconfig['ipprotocol'] == "inet46"))
|
1525
|
continue;
|
1526
|
if(($pconfig['ipprotocol'] == "inet6") && !(($gw['ipprotocol'] == "inet6") || (is_ipaddrv6($gw['gateway']))))
|
1527
|
continue;
|
1528
|
if(($pconfig['ipprotocol'] == "inet") && !(($gw['ipprotocol'] == "inet") || (is_ipaddrv4($gw['gateway']))))
|
1529
|
continue;
|
1530
|
if($gw == "")
|
1531
|
continue;
|
1532
|
if($gwname == $pconfig['gateway']) {
|
1533
|
$selected = " selected=\"selected\"";
|
1534
|
} else {
|
1535
|
$selected = "";
|
1536
|
}
|
1537
|
$gateway_addr_str = empty($gw['gateway']) ? "" : " - " . $gw[gateway];
|
1538
|
echo "<option value=\"{$gwname}\" {$selected}>{$gw['name']}{$gateway_addr_str}</option>\n";
|
1539
|
}
|
1540
|
/* add gateway groups to the list */
|
1541
|
if (is_array($a_gatewaygroups)) {
|
1542
|
foreach($a_gatewaygroups as $gwg_name => $gwg_data) {
|
1543
|
if((empty($pconfig['ipprotocol'])) || ($pconfig['ipprotocol'] == $gwg_data['ipprotocol'])) {
|
1544
|
if($pconfig['gateway'] == $gwg_name) {
|
1545
|
$selected = " selected=\"selected\"";
|
1546
|
} else {
|
1547
|
$selected = "";
|
1548
|
}
|
1549
|
echo "<option value=\"{$gwg_name}\" $selected>{$gwg_name}</option>\n";
|
1550
|
}
|
1551
|
}
|
1552
|
}
|
1553
|
?>
|
1554
|
</select>
|
1555
|
<p><?=gettext("Leave as 'default' to use the system routing table. Or choose a gateway to utilize policy based routing.");?></p>
|
1556
|
</div>
|
1557
|
</td>
|
1558
|
</tr>
|
1559
|
<tr>
|
1560
|
<td width="22%" valign="top" class="vncell"><?=gettext("In/Out");?></td>
|
1561
|
<td width="78%" class="vtable">
|
1562
|
<div id="showadvinoutbox" <?php if (!empty($pconfig['dnpipe'])) echo "style='display:none'"; ?>>
|
1563
|
<input type="button" onclick="show_advanced_inout()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
|
1564
|
</div>
|
1565
|
<div id="showinoutadv" <?php if (empty($pconfig['dnpipe'])) echo "style='display:none'"; ?>>
|
1566
|
<select name="dnpipe">
|
1567
|
<?php
|
1568
|
if (!is_array($dnqlist))
|
1569
|
$dnqlist = array();
|
1570
|
echo "<option value=\"\"";
|
1571
|
if (!$dnqselected) echo " selected=\"selected\"";
|
1572
|
echo " >none</option>";
|
1573
|
foreach ($dnqlist as $dnq => $dnqkey) {
|
1574
|
if($dnq == "")
|
1575
|
continue;
|
1576
|
echo "<option value=\"$dnq\"";
|
1577
|
if ($dnq == $pconfig['dnpipe']) {
|
1578
|
$dnqselected = 1;
|
1579
|
echo " selected=\"selected\"";
|
1580
|
}
|
1581
|
echo ">{$dnq}</option>";
|
1582
|
}
|
1583
|
?>
|
1584
|
</select> /
|
1585
|
<select name="pdnpipe">
|
1586
|
<?php
|
1587
|
$dnqselected = 0;
|
1588
|
echo "<option value=\"\"";
|
1589
|
if (!$dnqselected) echo " selected=\"selected\"";
|
1590
|
echo " >none</option>";
|
1591
|
foreach ($dnqlist as $dnq => $dnqkey) {
|
1592
|
if($dnq == "")
|
1593
|
continue;
|
1594
|
echo "<option value=\"$dnq\"";
|
1595
|
if ($dnq == $pconfig['pdnpipe']) {
|
1596
|
$dnqselected = 1;
|
1597
|
echo " selected=\"selected\"";
|
1598
|
}
|
1599
|
echo ">{$dnq}</option>";
|
1600
|
}
|
1601
|
?>
|
1602
|
</select>
|
1603
|
<br />
|
1604
|
<span class="vexpl"><?=gettext("Choose the Out queue/Virtual interface only if you have also selected In.")."<br />".gettext("The Out selection is applied to traffic leaving the interface where the rule is created, In is applied to traffic coming into the chosen interface.")."<br />".gettext("If you are creating a floating rule, if the direction is In then the same rules apply, if the direction is out the selections are reverted Out is for incoming and In is for outgoing.");?></span>
|
1605
|
</div>
|
1606
|
</td>
|
1607
|
</tr>
|
1608
|
|
1609
|
<tr>
|
1610
|
<td width="22%" valign="top" class="vncell"><?=gettext("Ackqueue/Queue");?></td>
|
1611
|
<td width="78%" class="vtable">
|
1612
|
<div id="showadvackqueuebox" <?php if (!empty($pconfig['defaultqueue'])) echo "style='display:none'"; ?>>
|
1613
|
<input type="button" onclick="show_advanced_ackqueue()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
|
1614
|
</div>
|
1615
|
<div id="showackqueueadv" <?php if (empty($pconfig['defaultqueue'])) echo "style='display:none'"; ?>>
|
1616
|
<select name="ackqueue">
|
1617
|
<?php
|
1618
|
if (!is_array($qlist))
|
1619
|
$qlist = array();
|
1620
|
echo "<option value=\"\"";
|
1621
|
if (!$qselected) echo " selected=\"selected\"";
|
1622
|
echo " >none</option>";
|
1623
|
foreach ($qlist as $q => $qkey) {
|
1624
|
if($q == "")
|
1625
|
continue;
|
1626
|
echo "<option value=\"$q\"";
|
1627
|
if ($q == $pconfig['ackqueue']) {
|
1628
|
$qselected = 1;
|
1629
|
echo " selected=\"selected\"";
|
1630
|
}
|
1631
|
if (isset($ifdisp[$q]))
|
1632
|
echo ">{$ifdisp[$q]}</option>";
|
1633
|
else
|
1634
|
echo ">{$q}</option>";
|
1635
|
}
|
1636
|
?>
|
1637
|
</select> /
|
1638
|
<select name="defaultqueue">
|
1639
|
<?php
|
1640
|
$qselected = 0;
|
1641
|
echo "<option value=\"\"";
|
1642
|
if (!$qselected) echo " selected=\"selected\"";
|
1643
|
echo " >none</option>";
|
1644
|
foreach ($qlist as $q => $qkey) {
|
1645
|
if($q == "")
|
1646
|
continue;
|
1647
|
echo "<option value=\"$q\"";
|
1648
|
if ($q == $pconfig['defaultqueue']) {
|
1649
|
$qselected = 1;
|
1650
|
echo " selected=\"selected\"";
|
1651
|
}
|
1652
|
if (isset($ifdisp[$q]))
|
1653
|
echo ">{$ifdisp[$q]}</option>";
|
1654
|
else
|
1655
|
echo ">{$q}</option>";
|
1656
|
}
|
1657
|
?>
|
1658
|
</select>
|
1659
|
<br />
|
1660
|
<span class="vexpl"><?=gettext("Choose the Acknowledge Queue only if you have selected Queue.");?></span>
|
1661
|
</div>
|
1662
|
</td>
|
1663
|
</tr>
|
1664
|
<tr>
|
1665
|
<td width="22%" valign="top" class="vncell"><?=gettext("Layer7");?></td>
|
1666
|
<td width="78%" class="vtable">
|
1667
|
<div id="showadvlayer7box" <?php if (!empty($pconfig['l7container'])) echo "style='display:none'"; ?>>
|
1668
|
<input type="button" onclick="show_advanced_layer7()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
|
1669
|
</div>
|
1670
|
<div id="showlayer7adv" <?php if (empty($pconfig['l7container'])) echo "style='display:none'"; ?>>
|
1671
|
<select name="l7container">
|
1672
|
<?php
|
1673
|
if (!is_array($l7clist))
|
1674
|
$l7clist = array();
|
1675
|
echo "<option value=\"\"";
|
1676
|
echo " >none</option>";
|
1677
|
foreach ($l7clist as $l7ckey) {
|
1678
|
echo "<option value=\"{$l7ckey}\"";
|
1679
|
if ($l7ckey == $pconfig['l7container']) {
|
1680
|
echo " selected=\"selected\"";
|
1681
|
}
|
1682
|
echo ">{$l7ckey}</option>";
|
1683
|
}
|
1684
|
?>
|
1685
|
</select>
|
1686
|
<br />
|
1687
|
<span class="vexpl">
|
1688
|
<?=gettext("Choose a Layer7 container to apply application protocol inspection rules. " .
|
1689
|
"These are valid for TCP and UDP protocols only.");?>
|
1690
|
</span>
|
1691
|
</div>
|
1692
|
</td>
|
1693
|
</tr>
|
1694
|
<?php
|
1695
|
// Allow extending of the firewall edit page and include custom input validation
|
1696
|
pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/htmlphplate");
|
1697
|
?>
|
1698
|
<?php
|
1699
|
$has_created_time = (isset($a_filter[$id]['created']) && is_array($a_filter[$id]['created']));
|
1700
|
$has_updated_time = (isset($a_filter[$id]['updated']) && is_array($a_filter[$id]['updated']));
|
1701
|
?>
|
1702
|
<?php if ($has_created_time || $has_updated_time): ?>
|
1703
|
<tr>
|
1704
|
<td> </td>
|
1705
|
</tr>
|
1706
|
<tr>
|
1707
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Rule Information");?></td>
|
1708
|
</tr>
|
1709
|
<?php if ($has_created_time): ?>
|
1710
|
<tr>
|
1711
|
<td width="22%" valign="top" class="vncell"><?=gettext("Created");?></td>
|
1712
|
<td width="78%" class="vtable">
|
1713
|
<?= date(gettext("n/j/y H:i:s"), $a_filter[$id]['created']['time']) ?> <?= gettext("by") ?> <strong><?= $a_filter[$id]['created']['username'] ?></strong>
|
1714
|
</td>
|
1715
|
</tr>
|
1716
|
<?php endif; ?>
|
1717
|
<?php if ($has_updated_time): ?>
|
1718
|
<tr>
|
1719
|
<td width="22%" valign="top" class="vncell"><?=gettext("Updated");?></td>
|
1720
|
<td width="78%" class="vtable">
|
1721
|
<?= date(gettext("n/j/y H:i:s"), $a_filter[$id]['updated']['time']) ?> <?= gettext("by") ?> <strong><?= $a_filter[$id]['updated']['username'] ?></strong>
|
1722
|
</td>
|
1723
|
</tr>
|
1724
|
<?php endif; ?>
|
1725
|
<?php endif; ?>
|
1726
|
<tr>
|
1727
|
<td width="22%" valign="top"> </td>
|
1728
|
<td width="78%">
|
1729
|
<br />
|
1730
|
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" /> <input type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()" />
|
1731
|
<?php if (isset($id) && $a_filter[$id]): ?>
|
1732
|
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
|
1733
|
<input name="tracker" type="hidden" value="<?=htmlspecialchars($pconfig['tracker']);?>">
|
1734
|
<?php endif; ?>
|
1735
|
<input name="after" type="hidden" value="<?=htmlspecialchars($after);?>" />
|
1736
|
</td>
|
1737
|
</tr>
|
1738
|
</table>
|
1739
|
</form>
|
1740
|
<script type="text/javascript">
|
1741
|
//<![CDATA[
|
1742
|
ext_change();
|
1743
|
typesel_change();
|
1744
|
proto_change();
|
1745
|
<?php if ( (!empty($pconfig['srcbeginport']) && $pconfig['srcbeginport'] != "any") || (!empty($pconfig['srcendport']) && $pconfig['srcendport'] != "any") ): ?>
|
1746
|
show_source_port_range();
|
1747
|
<?php endif; ?>
|
1748
|
|
1749
|
var addressarray = <?= json_encode(get_alias_list(array("host", "network", "openvpn", "urltable"))) ?>;
|
1750
|
var customarray = <?= json_encode(get_alias_list(array("port", "url_ports", "urltable_ports"))) ?>;
|
1751
|
|
1752
|
var oTextbox1 = new AutoSuggestControl(document.getElementById("src"), new StateSuggestions(addressarray));
|
1753
|
var oTextbox2 = new AutoSuggestControl(document.getElementById("srcbeginport_cust"), new StateSuggestions(customarray));
|
1754
|
var oTextbox3 = new AutoSuggestControl(document.getElementById("srcendport_cust"), new StateSuggestions(customarray));
|
1755
|
var oTextbox4 = new AutoSuggestControl(document.getElementById("dst"), new StateSuggestions(addressarray));
|
1756
|
var oTextbox5 = new AutoSuggestControl(document.getElementById("dstbeginport_cust"), new StateSuggestions(customarray));
|
1757
|
var oTextbox6 = new AutoSuggestControl(document.getElementById("dstendport_cust"), new StateSuggestions(customarray));
|
1758
|
//]]>
|
1759
|
</script>
|
1760
|
<?php include("fend.inc"); ?>
|
1761
|
</body>
|
1762
|
</html>
|