Project

General

Profile

Download (34.8 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/*
4
	firewall_rules_edit.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6

    
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9

    
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12

    
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15

    
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19

    
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31

    
32
require("guiconfig.inc");
33

    
34
$specialsrcdst = explode(" ", "any lan pptp");
35

    
36
if (!is_array($config['filter']['rule'])) {
37
	$config['filter']['rule'] = array();
38
}
39
filter_rules_sort();
40
$a_filter = &$config['filter']['rule'];
41

    
42
$id = $_GET['id'];
43
if (is_numeric($_POST['id']))
44
	$id = $_POST['id'];
45

    
46
$after = $_GET['after'];
47

    
48
if (isset($_POST['after']))
49
	$after = $_POST['after'];
50

    
51
if (isset($_GET['dup'])) {
52
	$id = $_GET['dup'];
53
	$after = $_GET['dup'];
54
}
55

    
56
function is_specialnet($net) {
57
	global $specialsrcdst;
58

    
59
	if (in_array($net, $specialsrcdst) || strstr($net, "opt"))
60
		return true;
61
	else
62
		return false;
63
}
64

    
65
function address_to_pconfig($adr, &$padr, &$pmask, &$pnot, &$pbeginport, &$pendport) {
66

    
67
	if (isset($adr['any']))
68
		$padr = "any";
69
	else if ($adr['network'])
70
		$padr = $adr['network'];
71
	else if ($adr['address']) {
72
		list($padr, $pmask) = explode("/", $adr['address']);
73
		if (!$pmask)
74
			$pmask = 32;
75
	}
76

    
77
	if (isset($adr['not']))
78
		$pnot = 1;
79
	else
80
		$pnot = 0;
81

    
82
	if ($adr['port']) {
83
		list($pbeginport, $pendport) = explode("-", $adr['port']);
84
		if (!$pendport)
85
			$pendport = $pbeginport;
86
	} else {
87
		if(alias_expand($pbeginport) <> "" || alias_expand($pendport) <> "") {
88
			/* Item is a port alias */
89
		} else {
90
			$pbeginport = "any";
91
			$pendport = "any";
92
		}
93
	}
94
}
95

    
96
function pconfig_to_address(&$adr, $padr, $pmask, $pnot, $pbeginport, $pendport) {
97

    
98
	$adr = array();
99

    
100
	if ($padr == "any")
101
		$adr['any'] = true;
102
	else if (is_specialnet($padr))
103
		$adr['network'] = $padr;
104
	else {
105
		$adr['address'] = $padr;
106
		if ($pmask != 32)
107
			$adr['address'] .= "/" . $pmask;
108
	}
109

    
110
	$adr['not'] = $pnot ? true : false;
111

    
112
	if (($pbeginport != 0) && ($pbeginport != "any")) {
113
		if ($pbeginport != $pendport)
114
			$adr['port'] = $pbeginport . "-" . $pendport;
115
		else
116
			$adr['port'] = $pbeginport;
117
	}
118

    
119
	if(alias_expand($pbeginport)) {
120
		$adr['port'] = $pbeginport;
121
	}
122
}
123

    
124
if (isset($id) && $a_filter[$id]) {
125
	$pconfig['interface'] = $a_filter[$id]['interface'];
126

    
127
	if (!isset($a_filter[$id]['type']))
128
		$pconfig['type'] = "pass";
129
	else
130
		$pconfig['type'] = $a_filter[$id]['type'];
131

    
132
	if (isset($a_filter[$id]['protocol']))
133
		$pconfig['proto'] = $a_filter[$id]['protocol'];
134
	else
135
		$pconfig['proto'] = "any";
136

    
137
	if ($a_filter[$id]['protocol'] == "icmp")
138
		$pconfig['icmptype'] = $a_filter[$id]['icmptype'];
139

    
140
	address_to_pconfig($a_filter[$id]['source'], $pconfig['src'],
141
		$pconfig['srcmask'], $pconfig['srcnot'],
142
		$pconfig['srcbeginport'], $pconfig['srcendport']);
143

    
144
	address_to_pconfig($a_filter[$id]['destination'], $pconfig['dst'],
145
		$pconfig['dstmask'], $pconfig['dstnot'],
146
		$pconfig['dstbeginport'], $pconfig['dstendport']);
147

    
148
	$pconfig['disabled'] = isset($a_filter[$id]['disabled']);
149
	$pconfig['log'] = isset($a_filter[$id]['log']);
150
	$pconfig['frags'] = isset($a_filter[$id]['frags']);
151
	$pconfig['descr'] = $a_filter[$id]['descr'];
152
	$pconfig['statetimeout'] = $a_filter[$id]['statetimeout'];
153

    
154
} else {
155
	/* defaults */
156
	if ($_GET['if'])
157
		$pconfig['interface'] = $_GET['if'];
158
	$pconfig['type'] = "pass";
159
	$pconfig['src'] = "any";
160
	$pconfig['dst'] = "any";
161
}
162

    
163
if (isset($_GET['dup']))
164
	unset($id);
165

    
166
if ($_POST) {
167

    
168
	if (($_POST['proto'] != "tcp") && ($_POST['proto'] != "udp") && ($_POST['proto'] != "tcp/udp")) {
169
		$_POST['srcbeginport'] = 0;
170
		$_POST['srcendport'] = 0;
171
		$_POST['dstbeginport'] = 0;
172
		$_POST['dstendport'] = 0;
173
	} else {
174

    
175
		if ($_POST['srcbeginport_cust'] && !$_POST['srcbeginport'])
176
			$_POST['srcbeginport'] = $_POST['srcbeginport_cust'];
177
		if ($_POST['srcendport_cust'] && !$_POST['srcendport'])
178
			$_POST['srcendport'] = $_POST['srcendport_cust'];
179

    
180
		if ($_POST['srcbeginport'] == "any") {
181
			$_POST['srcbeginport'] = 0;
182
			$_POST['srcendport'] = 0;
183
		} else {
184
			if (!$_POST['srcendport'])
185
				$_POST['srcendport'] = $_POST['srcbeginport'];
186
		}
187
		if ($_POST['srcendport'] == "any")
188
			$_POST['srcendport'] = $_POST['srcbeginport'];
189

    
190
		if ($_POST['dstbeginport_cust'] && !$_POST['dstbeginport'])
191
			$_POST['dstbeginport'] = $_POST['dstbeginport_cust'];
192
		if ($_POST['dstendport_cust'] && !$_POST['dstendport'])
193
			$_POST['dstendport'] = $_POST['dstendport_cust'];
194

    
195
		if ($_POST['dstbeginport'] == "any") {
196
			$_POST['dstbeginport'] = 0;
197
			$_POST['dstendport'] = 0;
198
		} else {
199
			if (!$_POST['dstendport'])
200
				$_POST['dstendport'] = $_POST['dstbeginport'];
201
		}
202
		if ($_POST['dstendport'] == "any")
203
			$_POST['dstendport'] = $_POST['dstbeginport'];
204
	}
205

    
206
	if (is_specialnet($_POST['srctype'])) {
207
		$_POST['src'] = $_POST['srctype'];
208
		$_POST['srcmask'] = 0;
209
	} else if ($_POST['srctype'] == "single") {
210
		$_POST['srcmask'] = 32;
211
	}
212
	if (is_specialnet($_POST['dsttype'])) {
213
		$_POST['dst'] = $_POST['dsttype'];
214
		$_POST['dstmask'] = 0;
215
	}  else if ($_POST['dsttype'] == "single") {
216
		$_POST['dstmask'] = 32;
217
	}
218

    
219
	unset($input_errors);
220
	$pconfig = $_POST;
221

    
222
	/* input validation */
223
	$reqdfields = explode(" ", "type interface proto src dst");
224
	$reqdfieldsn = explode(",", "Type,Interface,Protocol,Source,Destination");
225

    
226

    
227
	if($_POST['statetype'] == "modulate state" or $_POST['statetype'] == "synproxy state")
228
		if( $_POST['proto'] == "udp" or $_POST['proto'] == "tcp/udp" or $_POST['proto'] == "icmp")
229
			$input_errors[] = "You cannot select udp or icmp when using modulate state or synproxy state.";
230

    
231

    
232
	if (!(is_specialnet($_POST['srctype']) || ($_POST['srctype'] == "single"))) {
233
		$reqdfields[] = "srcmask";
234
		$reqdfieldsn[] = "Source bit count";
235
	}
236
	if (!(is_specialnet($_POST['dsttype']) || ($_POST['dsttype'] == "single"))) {
237
		$reqdfields[] = "dstmask";
238
		$reqdfieldsn[] = "Destination bit count";
239
	}
240

    
241
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
242

    
243
	if (!$_POST['srcbeginport']) {
244
		$_POST['srcbeginport'] = 0;
245
		$_POST['srcendport'] = 0;
246
	}
247
	if (!$_POST['dstbeginport']) {
248
		$_POST['dstbeginport'] = 0;
249
		$_POST['dstendport'] = 0;
250
	}
251

    
252
	if (($_POST['srcbeginport'] && !alias_expand($_POST['srcbeginport']) && !is_port($_POST['srcbeginport']))) {
253
		$input_errors[] = "The start source port must be an integer between 1 and 65535.";
254
	}
255
	if (($_POST['srcendport'] && !alias_expand($_POST['srcendport']) && !is_port($_POST['srcendport']))) {
256
		$input_errors[] = "The end source port must be an integer between 1 and 65535.";
257
	}
258
	if (($_POST['dstbeginport'] && !alias_expand($_POST['dstbeginport']) && !is_port($_POST['dstbeginport']))) {
259
		$input_errors[] = "The start destination port must be an integer between 1 and 65535.";
260
	}
261
	if (($_POST['dstendport'] && !alias_expand($_POST['dstbeginport']) && !is_port($_POST['dstendport']))) {
262
		$input_errors[] = "The end destination port must be an integer between 1 and 65535.";
263
	}
264

    
265
	if (!is_specialnet($_POST['srctype'])) {
266
		if (($_POST['src'] && !is_ipaddroranyalias($_POST['src']))) {
267
			$input_errors[] = "A valid source IP address or alias must be specified.";
268
		}
269
		if (($_POST['srcmask'] && !is_numericint($_POST['srcmask']))) {
270
			$input_errors[] = "A valid source bit count must be specified.";
271
		}
272
	}
273
	if (!is_specialnet($_POST['dsttype'])) {
274
		if (($_POST['dst'] && !is_ipaddroranyalias($_POST['dst']))) {
275
			$input_errors[] = "A valid destination IP address or alias must be specified.";
276
		}
277
		if (($_POST['dstmask'] && !is_numericint($_POST['dstmask']))) {
278
			$input_errors[] = "A valid destination bit count must be specified.";
279
		}
280
	}
281

    
282
	if ($_POST['srcbeginport'] > $_POST['srcendport']) {
283
		/* swap */
284
		$tmp = $_POST['srcendport'];
285
		$_POST['srcendport'] = $_POST['srcbeginport'];
286
		$_POST['srcbeginport'] = $tmp;
287
	}
288
	if ($_POST['dstbeginport'] > $_POST['dstendport']) {
289
		/* swap */
290
		$tmp = $_POST['dstendport'];
291
		$_POST['dstendport'] = $_POST['dstbeginport'];
292
		$_POST['dstbeginport'] = $tmp;
293
	}
294

    
295
	if (!$input_errors) {
296
		$filterent = array();
297
		$filterent['type'] = $_POST['type'];
298
		$filterent['interface'] = $_POST['interface'];
299

    
300
		/* Advanced options */
301
		$filterent['max-src-nodes'] = $_POST['max-src-nodes'];
302
		$filterent['max-src-states'] = $_POST['max-src-states'];
303
		$filterent['statetimeout'] = $_POST['statetimeout'];
304

    
305
		if ($_POST['proto'] != "any")
306
			$filterent['protocol'] = $_POST['proto'];
307
		else
308
			unset($filterent['protocol']);
309

    
310
		if ($_POST['proto'] == "icmp" && $_POST['icmptype'])
311
			$filterent['icmptype'] = $_POST['icmptype'];
312
		else
313
			unset($filterent['icmptype']);
314

    
315
		pconfig_to_address($filterent['source'], $_POST['src'],
316
			$_POST['srcmask'], $_POST['srcnot'],
317
			$_POST['srcbeginport'], $_POST['srcendport']);
318

    
319
		pconfig_to_address($filterent['destination'], $_POST['dst'],
320
			$_POST['dstmask'], $_POST['dstnot'],
321
			$_POST['dstbeginport'], $_POST['dstendport']);
322

    
323
		$filterent['disabled'] = $_POST['disabled'] ? true : false;
324
		$filterent['log'] = $_POST['log'] ? true : false;
325
		$filterent['frags'] = $_POST['frags'] ? true : false;
326
		$filterent['descr'] = $_POST['descr'];
327

    
328
		if (isset($id) && $a_filter[$id])
329
			$a_filter[$id] = $filterent;
330
		else {
331
			if (is_numeric($after))
332
				array_splice($a_filter, $after+1, 0, array($filterent));
333
			else
334
				$a_filter[] = $filterent;
335
		}
336

    
337
		write_config();
338
		touch($d_filterconfdirty_path);
339

    
340
		header("Location: firewall_rules.php?if=" . $_POST['interface']);
341
		exit;
342
	}
343
}
344
?>
345
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
346
<html>
347
<head>
348
<title><?=gentitle("Firewall: Rules: Edit");?></title>
349
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
350
<link href="gui.css" rel="stylesheet" type="text/css">
351
<script language="JavaScript">
352
<!--
353
var portsenabled = 1;
354

    
355
function ext_change() {
356
	if ((document.iform.srcbeginport.selectedIndex == 0) && portsenabled) {
357
		document.iform.srcbeginport_cust.disabled = 0;
358
	} else {
359
		document.iform.srcbeginport_cust.value = "";
360
		document.iform.srcbeginport_cust.disabled = 1;
361
	}
362
	if ((document.iform.srcendport.selectedIndex == 0) && portsenabled) {
363
		document.iform.srcendport_cust.disabled = 0;
364
	} else {
365
		document.iform.srcendport_cust.value = "";
366
		document.iform.srcendport_cust.disabled = 1;
367
	}
368
	if ((document.iform.dstbeginport.selectedIndex == 0) && portsenabled) {
369
		document.iform.dstbeginport_cust.disabled = 0;
370
	} else {
371
		document.iform.dstbeginport_cust.value = "";
372
		document.iform.dstbeginport_cust.disabled = 1;
373
	}
374
	if ((document.iform.dstendport.selectedIndex == 0) && portsenabled) {
375
		document.iform.dstendport_cust.disabled = 0;
376
	} else {
377
		document.iform.dstendport_cust.value = "";
378
		document.iform.dstendport_cust.disabled = 1;
379
	}
380

    
381
	if (!portsenabled) {
382
		document.iform.srcbeginport.disabled = 1;
383
		document.iform.srcendport.disabled = 1;
384
		document.iform.dstbeginport.disabled = 1;
385
		document.iform.dstendport.disabled = 1;
386
	} else {
387
		document.iform.srcbeginport.disabled = 0;
388
		document.iform.srcendport.disabled = 0;
389
		document.iform.dstbeginport.disabled = 0;
390
		document.iform.dstendport.disabled = 0;
391
	}
392
}
393

    
394
function typesel_change() {
395
	switch (document.iform.srctype.selectedIndex) {
396
		case 1:	/* single */
397
			document.iform.src.disabled = 0;
398
			document.iform.srcmask.value = "";
399
			document.iform.srcmask.disabled = 1;
400
			break;
401
		case 2:	/* network */
402
			document.iform.src.disabled = 0;
403
			document.iform.srcmask.disabled = 0;
404
			break;
405
		default:
406
			document.iform.src.value = "";
407
			document.iform.src.disabled = 1;
408
			document.iform.srcmask.value = "";
409
			document.iform.srcmask.disabled = 1;
410
			break;
411
	}
412
	switch (document.iform.dsttype.selectedIndex) {
413
		case 1:	/* single */
414
			document.iform.dst.disabled = 0;
415
			document.iform.dstmask.value = "";
416
			document.iform.dstmask.disabled = 1;
417
			break;
418
		case 2:	/* network */
419
			document.iform.dst.disabled = 0;
420
			document.iform.dstmask.disabled = 0;
421
			break;
422
		default:
423
			document.iform.dst.value = "";
424
			document.iform.dst.disabled = 1;
425
			document.iform.dstmask.value = "";
426
			document.iform.dstmask.disabled = 1;
427
			break;
428
	}
429
}
430

    
431
function proto_change() {
432
	if (document.iform.proto.selectedIndex < 3) {
433
		portsenabled = 1;
434
	} else {
435
		portsenabled = 0;
436
	}
437

    
438
	if (document.iform.proto.selectedIndex == 3) {
439
		document.iform.icmptype.disabled = 0;
440
	} else {
441
		document.iform.icmptype.disabled = 1;
442
	}
443

    
444
	ext_change();
445
}
446

    
447
function src_rep_change() {
448
	document.iform.srcendport.selectedIndex = document.iform.srcbeginport.selectedIndex;
449
}
450
function dst_rep_change() {
451
	document.iform.dstendport.selectedIndex = document.iform.dstbeginport.selectedIndex;
452
}
453
//-->
454
</script>
455
</head>
456

    
457
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
458
<?php include("fbegin.inc"); ?>
459
<p class="pgtitle">Firewall: Rules: Edit</p>
460
<?php if ($input_errors) print_input_errors($input_errors); ?>
461
            <form action="firewall_rules_edit.php" method="post" name="iform" id="iform">
462
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
463
                <tr>
464
                  <td width="22%" valign="top" class="vncellreq">Action</td>
465
                  <td width="78%" class="vtable">
466
<select name="type" class="formfld">
467
                      <?php $types = explode(" ", "Pass Block Reject"); foreach ($types as $type): ?>
468
                      <option value="<?=strtolower($type);?>" <?php if (strtolower($type) == strtolower($pconfig['type'])) echo "selected"; ?>>
469
                      <?=htmlspecialchars($type);?>
470
                      </option>
471
                      <?php endforeach; ?>
472
                    </select> <br>
473
                    <span class="vexpl">Choose what to do with packets that match
474
					the criteria specified below.<br>
475
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. Reject only works when the protocol is set to either TCP or UDP (but not &quot;TCP/UDP&quot;) below.</span></td>
476
                </tr>
477
                <tr>
478
                  <td width="22%" valign="top" class="vncellreq">Disabled</td>
479
                  <td width="78%" class="vtable">
480
                    <input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked"; ?>>
481
                    <strong>Disable this rule</strong><br>
482
                    <span class="vexpl">Set this option to disable this rule without
483
					removing it from the list.</span></td>
484
                </tr>
485
                <tr>
486
                  <td width="22%" valign="top" class="vncellreq">Interface</td>
487
                  <td width="78%" class="vtable">
488
<select name="interface" class="formfld">
489
                      <?php $interfaces = array('wan' => 'WAN', 'lan' => 'LAN', 'pptp' => 'PPTP');
490
					  for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
491
					  	$interfaces['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
492
					  }
493
					  foreach ($interfaces as $iface => $ifacename): ?>
494
                      <option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected"; ?>>
495
                      <?=htmlspecialchars($ifacename);?>
496
                      </option>
497
                      <?php endforeach; ?>
498
                    </select> <br>
499
                    <span class="vexpl">Choose on which interface packets must
500
                    come in to match this rule.</span></td>
501
                </tr>
502
                <tr>
503
                  <td width="22%" valign="top" class="vncellreq">Protocol</td>
504
                  <td width="78%" class="vtable">
505
<select name="proto" class="formfld" onchange="proto_change()">
506
                      <?php $protocols = explode(" ", "TCP UDP TCP/UDP ICMP ESP AH GRE IPv6 IGMP any"); foreach ($protocols as $proto): ?>
507
                      <option value="<?=strtolower($proto);?>" <?php if (strtolower($proto) == $pconfig['proto']) echo "selected"; ?>>
508
                      <?=htmlspecialchars($proto);?>
509
                      </option>
510
                      <?php endforeach; ?>
511
                    </select> <br>
512
                    <span class="vexpl">Choose which IP protocol this rule should
513
                    match.<br>
514
                    Hint: in most cases, you should specify <em>TCP</em> &nbsp;here.</span></td>
515
                </tr>
516
                <tr>
517
                  <td valign="top" class="vncell">ICMP type</td>
518
                  <td class="vtable">
519
                    <select name="icmptype" class="formfld">
520
                      <?php
521

    
522
					  $icmptypes = array(
523
					  	"" => "any",
524
					  	"unreach" => "Destination unreachable",
525
						"echo" => "Echo",
526
						"echorep" => "Echo reply",
527
						"squench" => "Source quench",
528
						"redir" => "Redirect",
529
						"timex" => "Time exceeded",
530
						"paramprob" => "Parameter problem",
531
						"timest" => "Timestamp",
532
						"timestrep" => "Timestamp reply",
533
						"inforeq" => "Information request",
534
						"inforep" => "Information reply",
535
						"maskreq" => "Address mask request",
536
						"maskrep" => "Address mask reply"
537
					  );
538

    
539
					  foreach ($icmptypes as $icmptype => $descr): ?>
540
                      <option value="<?=$icmptype;?>" <?php if ($icmptype == $pconfig['icmptype']) echo "selected"; ?>>
541
                      <?=htmlspecialchars($descr);?>
542
                      </option>
543
                      <?php endforeach; ?>
544
                    </select>
545
                    <br>
546
                    <span class="vexpl">If you selected ICMP for the protocol above, you may specify an ICMP type here.</span></td>
547
                </tr>
548
                <tr>
549
                  <td width="22%" valign="top" class="vncellreq">Source</td>
550
                  <td width="78%" class="vtable">
551
<input name="srcnot" type="checkbox" id="srcnot" value="yes" <?php if ($pconfig['srcnot']) echo "checked"; ?>>
552
                    <strong>not</strong><br>
553
                    Use this option to invert the sense of the match.<br>
554
                    <br>
555
                    <table border="0" cellspacing="0" cellpadding="0">
556
                      <tr>
557
                        <td>Type:&nbsp;&nbsp;</td>
558
                        <td><select name="srctype" class="formfld" onChange="typesel_change()">
559
							<?php $sel = is_specialnet($pconfig['src']); ?>
560
                            <option value="any" <?php if ($pconfig['src'] == "any") { echo "selected"; } ?>>
561
                            any</option>
562
                            <option value="single" <?php if (($pconfig['srcmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>>
563
                            Single host or alias</option>
564
                            <option value="network" <?php if (!$sel) echo "selected"; ?>>
565
                            Network</option>
566
                            <option value="lan" <?php if ($pconfig['src'] == "lan") { echo "selected"; } ?>>
567
                            LAN subnet</option>
568
                            <option value="pptp" <?php if ($pconfig['src'] == "pptp") { echo "selected"; } ?>>
569
                            PPTP clients</option>
570
							<?php for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++): ?>
571
                            <option value="opt<?=$i;?>" <?php if ($pconfig['src'] == "opt" . $i) { echo "selected"; } ?>>
572
                            <?=htmlspecialchars($config['interfaces']['opt' . $i]['descr']);?> subnet</option>
573
							<?php endfor; ?>
574
                          </select></td>
575
                      </tr>
576
                      <tr>
577
                        <td>Address:&nbsp;&nbsp;</td>
578
                        <td><input autocomplete='off' onblur='actb_removedisp()'  onkeydown='actb_checkkey(event);' onkeyup='actb_tocomplete(this,event,addressarray)' name="src" type="text" class="formfldalias" id="src" size="20" value="<?php if (!is_specialnet($pconfig['src'])) echo htmlspecialchars($pconfig['src']);?>">
579
                        /
580
						<select name="srcmask" class="formfld" id="srcmask">
581
						<?php for ($i = 31; $i > 0; $i--): ?>
582
						<option value="<?=$i;?>" <?php if ($i == $pconfig['srcmask']) echo "selected"; ?>><?=$i;?></option>
583
						<?php endfor; ?>
584
						</select>
585
						</td>
586
					  </tr>
587
                    </table></td>
588
                </tr>
589
                <tr>
590
                  <td width="22%" valign="top" class="vncellreq">Source port range
591
                  </td>
592
                  <td width="78%" class="vtable">
593
                    <table border="0" cellspacing="0" cellpadding="0">
594
                      <tr>
595
                        <td>from:&nbsp;&nbsp;</td>
596
                        <td><select name="srcbeginport" class="formfld" onchange="src_rep_change();ext_change()">
597
                            <option value="">(other)</option>
598
                            <option value="any" <?php $bfound = 0; if ($pconfig['srcbeginport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
599
                            <?php foreach ($wkports as $wkport => $wkportdesc): ?>
600
                            <option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcbeginport']) {
601
																echo "selected";
602
																$bfound = 1;
603
															}?>>
604
                            <?=htmlspecialchars($wkportdesc);?>
605
                            </option>
606
                            <?php endforeach; ?>
607
                          </select> <input autocomplete='off' onblur='actb_removedisp()'  onkeydown='actb_checkkey(event);' onkeyup='actb_tocomplete(this,event,customarray)' class="formfldalias" name="srcbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcbeginport']) echo $pconfig['srcbeginport']; ?>"></td>
608
                      </tr>
609
                      <tr>
610
                        <td>to:</td>
611
                        <td><select name="srcendport" class="formfld" onchange="ext_change()">
612
                            <option value="">(other)</option>
613
                            <option value="any" <?php $bfound = 0; if ($pconfig['srcendport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
614
                            <?php foreach ($wkports as $wkport => $wkportdesc): ?>
615
                            <option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcendport']) {
616
																echo "selected";
617
																$bfound = 1;
618
															}?>>
619
                            <?=htmlspecialchars($wkportdesc);?>
620
                            </option>
621
                            <?php endforeach; ?>
622
                          </select> <input autocomplete='off' onblur='actb_removedisp()'  onkeydown='actb_checkkey(event);' onkeyup='actb_tocomplete(this,event,customarray)' class="formfldalias" name="srcendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcendport']) echo $pconfig['srcendport']; ?>"></td>
623
                      </tr>
624
                    </table>
625
                    <br>
626
                    <span class="vexpl">Specify the port or port range for
627
                    the source of the packet for this rule. This is usually not equal to the destination port range (and is often &quot;any&quot;). <br>
628
                    Hint: you can leave the <em>'to'</em> field empty if you only
629
                    want to filter a single port</span></td>
630
                <tr>
631
                  <td width="22%" valign="top" class="vncellreq">Destination</td>
632
                  <td width="78%" class="vtable">
633
                    <input name="dstnot" type="checkbox" id="dstnot" value="yes" <?php if ($pconfig['dstnot']) echo "checked"; ?>>
634
                    <strong>not</strong><br>
635
                    Use this option to invert the sense of the match.<br>
636
                    <br>
637
                    <table border="0" cellspacing="0" cellpadding="0">
638
                      <tr>
639
                        <td>Type:&nbsp;&nbsp;</td>
640
                        <td><select name="dsttype" class="formfld" onChange="typesel_change()">
641
                            <?php $sel = is_specialnet($pconfig['dst']); ?>
642
                            <option value="any" <?php if ($pconfig['dst'] == "any") { echo "selected"; } ?>>
643
                            any</option>
644
                            <option value="single" <?php if (($pconfig['dstmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>>
645
                            Single host or alias</option>
646
                            <option value="network" <?php if (!$sel) echo "selected"; ?>>
647
                            Network</option>
648
                            <option value="lan" <?php if ($pconfig['dst'] == "lan") { echo "selected"; } ?>>
649
                            LAN subnet</option>
650
                            <option value="pptp" <?php if ($pconfig['dst'] == "pptp") { echo "selected"; } ?>>
651
                            PPTP clients</option>
652
							<?php for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++): ?>
653
                            <option value="opt<?=$i;?>" <?php if ($pconfig['dst'] == "opt" . $i) { echo "selected"; } ?>>
654
                            <?=htmlspecialchars($config['interfaces']['opt' . $i]['descr']);?> subnet</option>
655
							<?php endfor; ?>
656
                          </select></td>
657
                      </tr>
658
                      <tr>
659
                        <td>Address:&nbsp;&nbsp;</td>
660
                        <td><input name="dst" autocomplete='off' onblur='actb_removedisp()'  onkeydown='actb_checkkey(event);' onkeyup='actb_tocomplete(this,event,addressarray)' type="text" class="formfldalias" id="dst" size="20" value="<?php if (!is_specialnet($pconfig['dst'])) echo htmlspecialchars($pconfig['dst']);?>">
661
                          /
662
                          <select name="dstmask" class="formfld" id="dstmask">
663
						<?php for ($i = 31; $i > 0; $i--): ?>
664
						<option value="<?=$i;?>" <?php if ($i == $pconfig['dstmask']) echo "selected"; ?>><?=$i;?></option>
665
						<?php endfor; ?>
666
						</select></td>
667
                      </tr>
668
                    </table></td>
669
                </tr>
670
                <tr>
671
                  <td width="22%" valign="top" class="vncellreq">Destination port
672
                    range </td>
673
                  <td width="78%" class="vtable">
674
                    <table border="0" cellspacing="0" cellpadding="0">
675
                      <tr>
676
                        <td>from:&nbsp;&nbsp;</td>
677
                        <td><select name="dstbeginport" class="formfld" onchange="dst_rep_change();ext_change()">
678
                            <option value="">(other)</option>
679
                            <option value="any" <?php $bfound = 0; if ($pconfig['dstbeginport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
680
                            <?php foreach ($wkports as $wkport => $wkportdesc): ?>
681
                            <option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstbeginport']) {
682
																echo "selected";
683
																$bfound = 1;
684
															}?>>
685
                            <?=htmlspecialchars($wkportdesc);?>
686
                            </option>
687
                            <?php endforeach; ?>
688
                          </select> <input autocomplete='off' onblur='actb_removedisp()' onkeydown='actb_checkkey(event);' onkeyup='actb_tocomplete(this,event,customarray)' class="formfldalias" name="dstbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstbeginport']) echo $pconfig['dstbeginport']; ?>"></td>
689
                      </tr>
690
                      <tr>
691
                        <td>to:</td>
692
                        <td><select name="dstendport" class="formfld" onchange="ext_change()">
693
                            <option value="">(other)</option>
694
                            <option value="any" <?php $bfound = 0; if ($pconfig['dstendport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
695
                            <?php foreach ($wkports as $wkport => $wkportdesc): ?>
696
                            <option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstendport']) {
697
																echo "selected";
698
																$bfound = 1;
699
															}?>>
700
                            <?=htmlspecialchars($wkportdesc);?>
701
                            </option>
702
                            <?php endforeach; ?>
703
                          </select> <input autocomplete='off' onblur='actb_removedisp()' onkeydown='actb_checkkey(event);' onkeyup='actb_tocomplete(this,event,customarray)' class="formfldalias" name="dstendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstendport']) echo $pconfig['dstendport']; ?>"></td>
704
                      </tr>
705
                    </table>
706
                    <br> <span class="vexpl">Specify the port or port range for
707
                    the destination of the packet for this rule.<br>
708
                    Hint: you can leave the <em>'to'</em> field empty if you only
709
                    want to filter a single port</span></td>
710

    
711
                <tr>
712
                  <td width="22%" valign="top" class="vncellreq">Fragments</td>
713
                  <td width="78%" class="vtable">
714
                    <input name="frags" type="checkbox" id="frags" value="yes" <?php if ($pconfig['frags']) echo "checked"; ?>>
715
                    <strong>Allow fragmented packets</strong><br>
716
                    <span class="vexpl">Hint: this option puts additional load
717
                    on the firewall and may make it vulnerable to DoS attacks.
718
                    In most cases, it is not needed. Try enabling it if you have
719
                    troubles connecting to certain sites.</span></td>
720
                </tr>
721
                <tr>
722
                  <td width="22%" valign="top" class="vncellreq">Log</td>
723
                  <td width="78%" class="vtable">
724
                    <input name="log" type="checkbox" id="log" value="yes" <?php if ($pconfig['log']) echo "checked"; ?>>
725
                    <strong>Log packets that are handled by this rule</strong><br>
726
                    <span class="vexpl">Hint: the firewall has limited local log
727
                    space. Don't turn on logging for everything. If you want to
728
                    do a lot of logging, consider using a remote syslog server
729
                    (see the <a href="diag_logs_settings.php">Diagnostics: System
730
                    logs: Settings</a> page).</span></td>
731
                </tr>
732
                <tr>
733
                  <td width="22%" valign="top" class="vncell">Description</td>
734
                  <td width="78%" class="vtable">
735
                    <input name="descr" type="text" class="formfld" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
736
                    <br> <span class="vexpl">You may enter a description here
737
                    for your reference (not parsed).</span></td>
738
                </tr>
739

    
740

    
741
               <tr>
742
                  <td width="22%" valign="top" class="vncell">Advanced Options</td>
743
                  <td width="78%" class="vtable">
744
			<input name="max-src-nodes" id="max-src-nodes" value="<?php echo $pconfig['max-src-nodes'] ?>"><br> Simultaneous client connection limit<p>
745
			<input name="max-src-states" id="max-src-states" value="<?php echo $pconfig['max-src-states'] ?>"><br> Maximum state entries per host<br>
746
			<p><strong>NOTE: Leave these fields blank to disable this feature.</strong>
747
		    </td>
748
                </tr>
749

    
750
               <tr>
751
                  <td width="22%" valign="top" class="vncell">State Type</td>
752
                  <td width="78%" class="vtable">
753
			<select name="statetype">
754
			<option value="keep state" <?php if(!isset($pconfig['statetype']) or $pconfig['statetype'] == "keep state") echo "selected"; ?>>keep state</option>
755
			<option value="modulate state" <?php if($pconfig['statetype'] == "modulate state")  echo "selected"; ?>>modulate state</option>
756
			<option value="synproxy state"<?php if($pconfig['statetype'] == "synproxy state")  echo "selected"; ?>>synproxy state</option>
757
			<option value="none"<?php if($pconfig['statetype'] == "none") echo "selected"; ?>>none</option>
758
			</select><br>HINT: Select which type of state tracking mechanism you would like to use.  If in doubt, use keep state.
759
			<p><strong>
760
			<table>
761
			<tr><td width="25%"><li>keep state</li></td><td>works with TCP, UDP, and ICMP.</td></tr>
762
			<tr><td width="25%"><li>modulate state</li></td><td>works only with TCP. pfSense will generate strong Initial Sequence Numbers (ISNs) for packets matching this rule.</li></td></tr>
763
			<tr><td width="25%"><li>synproxy state</li></td><td>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>
764
			<tr><td width="25%"><li>none</li></td><td>do not use state mechanisms to keep track.  this is only useful if your doing advanced queueing in certain situations.  please check the faq.</td></tr>
765
			</table>
766
			</strong>
767
		    </td>
768
                </tr>
769

    
770
		<tr>
771
                  <td width="22%" valign="top" class="vncell">State Timeout</td>
772
                  <td width="78%" class="vtable">
773
			<input name="statetimeout" value="<?php echo $pconfig['frags'] ?>">
774
			<p><strong>Leave blank for default.  Amount is in seconds.
775
			</strong>
776
		    </td>
777
		</tr>
778

    
779
                <tr>
780
                  <td width="22%" valign="top">&nbsp;</td>
781
                  <td width="78%">
782
                    <input name="Submit" type="submit" class="formbtn" value="Save">
783
                    <?php if (isset($id) && $a_filter[$id]): ?>
784
                    <input name="id" type="hidden" value="<?=$id;?>">
785
                    <?php endif; ?>
786
                    <input name="after" type="hidden" value="<?=$after;?>">
787
                  </td>
788
                </tr>
789
              </table>
790
</form>
791
<script language="JavaScript">
792
<!--
793
ext_change();
794
typesel_change();
795
proto_change();
796

    
797
<?php
798
$isfirst = 0;
799
$aliases = "";
800
$addrisfirst = 0;
801
$aliasesaddr = "";
802
foreach($config['aliases']['alias'] as $alias_name) {
803
	if(!stristr($alias_name['address'], ".")) {
804
		if($isfirst == 1) $aliases .= ",";
805
		$aliases .= "'" . $alias_name['name'] . "'";
806
		$isfirst = 1;
807
	} else {
808
		if($addrisfirst == 1) $aliasesaddr .= ",";
809
		$aliasesaddr .= "'" . $alias_name['name'] . "'";
810
		$addrisfirst = 1;
811
	}
812
}
813
?>
814

    
815
var addressarray=new Array(<?php echo $aliasesaddr; ?>);
816
var customarray=new Array(<?php echo $aliases; ?>);
817

    
818
//-->
819
</script>
820
<script type="text/javascript" language="javascript" src="auto_complete_helper.js">
821
</script>
822
<?php include("fend.inc"); ?>
823
</body>
824
</html>
(31-31/100)