1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
firewall_nat_out_edit.php
|
5
|
Copyright (C) 2004 Scott Ullrich
|
6
|
All rights reserved.
|
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: nat
|
35
|
*/
|
36
|
|
37
|
##|+PRIV
|
38
|
##|*IDENT=page-firewall-nat-outbound-edit
|
39
|
##|*NAME=Firewall: NAT: Outbound: Edit page
|
40
|
##|*DESCR=Allow access to the 'Firewall: NAT: Outbound: Edit' page.
|
41
|
##|*MATCH=firewall_nat_out_edit.php*
|
42
|
##|-PRIV
|
43
|
|
44
|
require("guiconfig.inc");
|
45
|
require_once("filter.inc");
|
46
|
require("shaper.inc");
|
47
|
|
48
|
if (!is_array($config['nat']['advancedoutbound']))
|
49
|
$config['nat']['advancedoutbound'] = array();
|
50
|
|
51
|
if (!is_array($config['nat']['advancedoutbound']['rule'])) {
|
52
|
$config['nat']['advancedoutbound']['rule'] = array();
|
53
|
}
|
54
|
|
55
|
$a_out = &$config['nat']['advancedoutbound']['rule'];
|
56
|
|
57
|
if (!is_array($config['aliases']['alias']))
|
58
|
$config['aliases']['alias'] = array();
|
59
|
$a_aliases = &$config['aliases']['alias'];
|
60
|
|
61
|
if (is_numericint($_GET['id']))
|
62
|
$id = $_GET['id'];
|
63
|
if (isset($_POST['id']) && is_numericint($_POST['id']))
|
64
|
$id = $_POST['id'];
|
65
|
|
66
|
if (is_numericint($_GET['after']) || $_GET['after'] == "-1")
|
67
|
$after = $_GET['after'];
|
68
|
if (isset($_POST['after']) && (is_numericint($_POST['after']) || $_POST['after'] == "-1"))
|
69
|
$after = $_POST['after'];
|
70
|
|
71
|
if (isset($_GET['dup']) && is_numericint($_GET['dup'])) {
|
72
|
$id = $_GET['dup'];
|
73
|
$after = $_GET['dup'];
|
74
|
}
|
75
|
|
76
|
if (isset($id) && $a_out[$id]) {
|
77
|
if ( isset($a_out[$id]['created']) && is_array($a_out[$id]['created']) )
|
78
|
$pconfig['created'] = $a_out[$id]['created'];
|
79
|
|
80
|
if ( isset($a_out[$id]['updated']) && is_array($a_out[$id]['updated']) )
|
81
|
$pconfig['updated'] = $a_out[$id]['updated'];
|
82
|
|
83
|
$pconfig['protocol'] = $a_out[$id]['protocol'];
|
84
|
list($pconfig['source'],$pconfig['source_subnet']) = explode('/', $a_out[$id]['source']['network']);
|
85
|
if (!is_numeric($pconfig['source_subnet']))
|
86
|
$pconfig['source_subnet'] = 32;
|
87
|
$pconfig['sourceport'] = $a_out[$id]['sourceport'];
|
88
|
address_to_pconfig($a_out[$id]['destination'], $pconfig['destination'],
|
89
|
$pconfig['destination_subnet'], $pconfig['destination_not'],
|
90
|
$none, $none);
|
91
|
$pconfig['dstport'] = $a_out[$id]['dstport'];
|
92
|
$pconfig['natport'] = $a_out[$id]['natport'];
|
93
|
$pconfig['target'] = $a_out[$id]['target'];
|
94
|
$pconfig['targetip'] = $a_out[$id]['targetip'];
|
95
|
$pconfig['targetip_subnet'] = $a_out[$id]['targetip_subnet'];
|
96
|
$pconfig['poolopts'] = $a_out[$id]['poolopts'];
|
97
|
$pconfig['interface'] = $a_out[$id]['interface'];
|
98
|
if (!$pconfig['interface']) {
|
99
|
$pconfig['interface'] = "wan";
|
100
|
}
|
101
|
$pconfig['descr'] = $a_out[$id]['descr'];
|
102
|
$pconfig['nonat'] = $a_out[$id]['nonat'];
|
103
|
$pconfig['staticnatport'] = isset($a_out[$id]['staticnatport']);
|
104
|
$pconfig['nosync'] = isset($a_out[$id]['nosync']);
|
105
|
} else {
|
106
|
$pconfig['source_subnet'] = 24;
|
107
|
$pconfig['destination'] = "any";
|
108
|
$pconfig['destination_subnet'] = 24;
|
109
|
$pconfig['interface'] = "wan";
|
110
|
}
|
111
|
|
112
|
if (isset($_GET['dup']) && is_numericint($_GET['dup']))
|
113
|
unset($id);
|
114
|
|
115
|
if ($_POST) {
|
116
|
if ($_POST['destination_type'] == "any") {
|
117
|
$_POST['destination'] = "any";
|
118
|
$_POST['destination_subnet'] = 24;
|
119
|
}
|
120
|
if ($_POST['source_type'] == "any") {
|
121
|
$_POST['source'] = "any";
|
122
|
$_POST['source_subnet'] = 24;
|
123
|
}
|
124
|
|
125
|
unset($input_errors);
|
126
|
$pconfig = $_POST;
|
127
|
/* run through $_POST items encoding HTML entties so that the user
|
128
|
* cannot think he is slick and perform a XSS attack on the unwilling
|
129
|
*/
|
130
|
foreach ($_POST as $key => $value) {
|
131
|
$temp = str_replace(">", "", $value);
|
132
|
$newpost = htmlentities($temp);
|
133
|
if($newpost <> $temp)
|
134
|
$input_errors[] = sprintf(gettext("Invalid characters detected (%s). Please remove invalid characters and save again."),$temp);
|
135
|
}
|
136
|
|
137
|
/* input validation */
|
138
|
$reqdfields = explode(" ", "interface protocol source source_subnet destination destination_subnet");
|
139
|
$reqdfieldsn = array(gettext("Interface"),gettext("Protocol"),gettext("Source"),gettext("Source bit count"),gettext("Destination"),gettext("Destination bit count"));
|
140
|
|
141
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
142
|
|
143
|
$protocol_uses_ports = in_array($_POST['protocol'], explode(" ", "any tcp udp tcp/udp"));
|
144
|
|
145
|
if ($_POST['source'])
|
146
|
$_POST['source'] = trim($_POST['source']);
|
147
|
if ($_POST['destination'])
|
148
|
$_POST['destination'] = trim($_POST['destination']);
|
149
|
if ($_POST['targetip'])
|
150
|
$_POST['targetip'] = trim($_POST['targetip']);
|
151
|
if ($_POST['sourceport'])
|
152
|
$_POST['sourceport'] = trim($_POST['sourceport']);
|
153
|
if ($_POST['dstport'])
|
154
|
$_POST['dstport'] = trim($_POST['dstport']);
|
155
|
if ($_POST['natport'])
|
156
|
$_POST['natport'] = trim($_POST['natport']);
|
157
|
|
158
|
if($protocol_uses_ports && $_POST['sourceport'] <> "" && !is_portoralias($_POST['sourceport']))
|
159
|
$input_errors[] = gettext("You must supply either a valid port or port alias for the source port entry.");
|
160
|
|
161
|
if($protocol_uses_ports && $_POST['dstport'] <> "" && !is_portoralias($_POST['dstport']))
|
162
|
$input_errors[] = gettext("You must supply either a valid port or port alias for the destination port entry.");
|
163
|
|
164
|
if($protocol_uses_ports && $_POST['natport'] <> "" && !is_port($_POST['natport']) && !isset($_POST['nonat']))
|
165
|
$input_errors[] = gettext("You must supply a valid port for the NAT port entry.");
|
166
|
|
167
|
if ($_POST['source_type'] != "any") {
|
168
|
if ($_POST['source'] && !is_ipaddroralias($_POST['source']) && $_POST['source'] <> "any") {
|
169
|
$input_errors[] = gettext("A valid source must be specified.");
|
170
|
}
|
171
|
}
|
172
|
if ($_POST['source_subnet'] && !is_numericint($_POST['source_subnet'])) {
|
173
|
$input_errors[] = gettext("A valid source bit count must be specified.");
|
174
|
}
|
175
|
if ($_POST['destination_type'] != "any") {
|
176
|
if ($_POST['destination'] && !is_ipaddroralias($_POST['destination'])) {
|
177
|
$input_errors[] = gettext("A valid destination must be specified.");
|
178
|
}
|
179
|
}
|
180
|
if ($_POST['destination_subnet'] && !is_numericint($_POST['destination_subnet'])) {
|
181
|
$input_errors[] = gettext("A valid destination bit count must be specified.");
|
182
|
}
|
183
|
if ($_POST['destination_type'] == "any") {
|
184
|
if ($_POST['destination_not']) {
|
185
|
$input_errors[] = gettext("Negating destination address of \"any\" is invalid.");
|
186
|
}
|
187
|
}
|
188
|
|
189
|
if ($_POST['target'] && !is_ipaddr($_POST['target']) && !is_subnet($_POST['target']) && !is_alias($_POST['target']) && !isset($_POST['nonat']) && !($_POST['target'] == "other-subnet")) {
|
190
|
$input_errors[] = gettext("A valid target IP address must be specified.");
|
191
|
}
|
192
|
|
193
|
if ($_POST['target'] == "other-subnet") {
|
194
|
if (!is_ipaddr($_POST['targetip'])) {
|
195
|
$input_errors[] = gettext("A valid target IP must be specified when using the 'Other Subnet' type.");
|
196
|
}
|
197
|
if (!is_numericint($_POST['targetip_subnet'])) {
|
198
|
$input_errors[] = gettext("A valid target bit count must be specified when using the 'Other Subnet' type.");
|
199
|
}
|
200
|
}
|
201
|
|
202
|
/* Verify Pool Options */
|
203
|
$poolopts = "";
|
204
|
if ($_POST['poolopts']) {
|
205
|
if (is_subnet($_POST['target']) || ($_POST['target'] == "other-subnet"))
|
206
|
$poolopts = $_POST['poolopts'];
|
207
|
elseif (is_alias($_POST['target'])) {
|
208
|
if (substr($_POST['poolopts'], 0, 11) == "round-robin")
|
209
|
$poolopts = $_POST['poolopts'];
|
210
|
else
|
211
|
$input_errors[] = gettext("Only Round Robin pool options may be chosen when selecting an alias.");
|
212
|
}
|
213
|
}
|
214
|
|
215
|
/* if user has selected any as source, set it here */
|
216
|
if($_POST['source_type'] == "any") {
|
217
|
$osn = "any";
|
218
|
} else if(is_alias($_POST['source'])) {
|
219
|
$osn = $_POST['source'];
|
220
|
} else {
|
221
|
$osn = gen_subnet($_POST['source'], $_POST['source_subnet']) . "/" . $_POST['source_subnet'];
|
222
|
}
|
223
|
|
224
|
/* check for existing entries */
|
225
|
if ($_POST['destination_type'] == "any") {
|
226
|
$ext = "any";
|
227
|
} else if(is_alias($_POST['destination'])) {
|
228
|
$ext = $_POST['destination'];
|
229
|
} else {
|
230
|
$ext = gen_subnet($_POST['destination'], $_POST['destination_subnet']) . "/" . $_POST['destination_subnet'];
|
231
|
}
|
232
|
|
233
|
foreach ($a_out as $natent) {
|
234
|
if (isset($id) && ($a_out[$id]) && ($a_out[$id] === $natent)) {
|
235
|
continue;
|
236
|
}
|
237
|
|
238
|
if (!$natent['interface']) {
|
239
|
$natent['interface'] == "wan";
|
240
|
}
|
241
|
}
|
242
|
|
243
|
// Allow extending of the firewall edit page and include custom input validation
|
244
|
pfSense_handle_custom_code("/usr/local/pkg/firewall_aon/input_validation");
|
245
|
|
246
|
if (!$input_errors) {
|
247
|
$natent = array();
|
248
|
$natent['source']['network'] = $osn;
|
249
|
$natent['sourceport'] = ($protocol_uses_ports) ? $_POST['sourceport'] : "";
|
250
|
$natent['descr'] = $_POST['descr'];
|
251
|
$natent['target'] = (!isset($_POST['nonat'])) ? $_POST['target'] : "";
|
252
|
$natent['targetip'] = (!isset($_POST['nonat'])) ? $_POST['targetip'] : "";
|
253
|
$natent['targetip_subnet'] = (!isset($_POST['nonat'])) ? $_POST['targetip_subnet'] : "";
|
254
|
$natent['interface'] = $_POST['interface'];
|
255
|
$natent['poolopts'] = $poolopts;
|
256
|
|
257
|
/* static-port */
|
258
|
if(isset($_POST['staticnatport']) && $protocol_uses_ports && !isset($_POST['nonat'])) {
|
259
|
$natent['staticnatport'] = true;
|
260
|
} else {
|
261
|
unset($natent['staticnatport']);
|
262
|
}
|
263
|
|
264
|
/* if user has selected not nat, set it here */
|
265
|
if(isset($_POST['nonat'])) {
|
266
|
$natent['nonat'] = true;
|
267
|
} else {
|
268
|
unset($natent['nonat']);
|
269
|
}
|
270
|
|
271
|
if ($_POST['protocol'] && $_POST['protocol'] != "any")
|
272
|
$natent['protocol'] = $_POST['protocol'];
|
273
|
else
|
274
|
unset($natent['protocol']);
|
275
|
|
276
|
if ($ext == "any") {
|
277
|
$natent['destination']['any'] = true;
|
278
|
} else {
|
279
|
$natent['destination']['address'] = $ext;
|
280
|
}
|
281
|
if($_POST['natport'] != "" && $protocol_uses_ports && !isset($_POST['nonat'])) {
|
282
|
$natent['natport'] = $_POST['natport'];
|
283
|
} else {
|
284
|
unset($natent['natport']);
|
285
|
}
|
286
|
if($_POST['dstport'] != "" && $protocol_uses_ports) {
|
287
|
$natent['dstport'] = $_POST['dstport'];
|
288
|
} else {
|
289
|
unset($natent['dstport']);
|
290
|
}
|
291
|
|
292
|
if($_POST['nosync'] == "yes") {
|
293
|
$natent['nosync'] = true;
|
294
|
} else {
|
295
|
unset($natent['nosync']);
|
296
|
}
|
297
|
|
298
|
if (isset($_POST['destination_not']) && $ext != "any") {
|
299
|
$natent['destination']['not'] = true;
|
300
|
}
|
301
|
|
302
|
if ( isset($a_out[$id]['created']) && is_array($a_out[$id]['created']) )
|
303
|
$natent['created'] = $a_out[$id]['created'];
|
304
|
|
305
|
$natent['updated'] = make_config_revision_entry();
|
306
|
|
307
|
// Allow extending of the firewall edit page and include custom input validation
|
308
|
pfSense_handle_custom_code("/usr/local/pkg/firewall_aon/pre_write_config");
|
309
|
|
310
|
if (isset($id) && $a_out[$id]) {
|
311
|
$a_out[$id] = $natent;
|
312
|
} else {
|
313
|
$natent['created'] = make_config_revision_entry();
|
314
|
if (is_numeric($after)) {
|
315
|
array_splice($a_out, $after+1, 0, array($natent));
|
316
|
} else {
|
317
|
$a_out[] = $natent;
|
318
|
}
|
319
|
}
|
320
|
|
321
|
if (write_config())
|
322
|
mark_subsystem_dirty('natconf');
|
323
|
header("Location: firewall_nat_out.php");
|
324
|
exit;
|
325
|
}
|
326
|
}
|
327
|
|
328
|
$pgtitle = array(gettext("Firewall"),gettext("NAT"),gettext("Outbound"),gettext("Edit"));
|
329
|
$closehead = false;
|
330
|
include("head.inc");
|
331
|
|
332
|
?>
|
333
|
|
334
|
<script type="text/javascript" src="/javascript/suggestions.js"></script>
|
335
|
<script type="text/javascript" src="/javascript/autosuggest.js"></script>
|
336
|
<script type="text/javascript">
|
337
|
//<![CDATA[
|
338
|
var portsenabled = 1;
|
339
|
function staticportchange() {
|
340
|
if(document.iform.staticnatport.checked) {
|
341
|
document.iform.natport.value = "";
|
342
|
document.iform.natport.disabled = 1;
|
343
|
} else {
|
344
|
document.iform.natport.disabled = 0;
|
345
|
}
|
346
|
}
|
347
|
function typesel_change() {
|
348
|
switch (document.iform.destination_type.selectedIndex) {
|
349
|
case 1: // network
|
350
|
document.iform.destination.disabled = 0;
|
351
|
document.iform.destination_subnet.disabled = 0;
|
352
|
break;
|
353
|
default:
|
354
|
document.iform.destination.value = "";
|
355
|
document.iform.destination.disabled = 1;
|
356
|
document.iform.destination_subnet.value = "24";
|
357
|
document.iform.destination_subnet.disabled = 1;
|
358
|
break;
|
359
|
}
|
360
|
}
|
361
|
function sourcesel_change() {
|
362
|
switch (document.iform.source_type.selectedIndex) {
|
363
|
case 1: // network
|
364
|
document.iform.source.disabled = 0;
|
365
|
document.iform.source_subnet.disabled = 0;
|
366
|
break;
|
367
|
default:
|
368
|
document.iform.source.value = "";
|
369
|
document.iform.source.disabled = 1;
|
370
|
document.iform.source_subnet.value = "24";
|
371
|
document.iform.source_subnet.disabled = 1;
|
372
|
break;
|
373
|
}
|
374
|
}
|
375
|
function nonat_change() {
|
376
|
if (document.iform.nonat.checked) {
|
377
|
document.getElementById("transtable").style.display = 'none';
|
378
|
} else {
|
379
|
document.getElementById("transtable").style.display = '';
|
380
|
}
|
381
|
}
|
382
|
function proto_change() {
|
383
|
if (document.iform.protocol.selectedIndex >= 0 && document.iform.protocol.selectedIndex <= 3) {
|
384
|
portsenabled = 1;
|
385
|
} else {
|
386
|
portsenabled = 0;
|
387
|
}
|
388
|
|
389
|
if (portsenabled) {
|
390
|
document.getElementById("sport_tr").style.display = '';
|
391
|
document.getElementById("dport_tr").style.display = '';
|
392
|
document.getElementById("tport_tr").style.display = '';
|
393
|
document.getElementById("tporttext_tr").style.display = '';
|
394
|
document.getElementById("tportstatic_tr").style.display = '';
|
395
|
} else {
|
396
|
document.getElementById("sport_tr").style.display = 'none';
|
397
|
document.getElementById("dport_tr").style.display = 'none';
|
398
|
document.getElementById("tport_tr").style.display = 'none';
|
399
|
document.getElementById("tporttext_tr").style.display = 'none';
|
400
|
document.getElementById("tportstatic_tr").style.display = 'none';
|
401
|
}
|
402
|
}
|
403
|
function poolopts_change() {
|
404
|
if (jQuery('#target option:selected').text().substring(0,4) == "Host") {
|
405
|
jQuery('#poolopts_tr').css('display','');
|
406
|
jQuery('#target_network').css('display','none');
|
407
|
} else if (jQuery('#target option:selected').text().substring(0,6) == "Subnet") {
|
408
|
jQuery('#poolopts_tr').css('display','');
|
409
|
jQuery('#target_network').css('display','none');
|
410
|
} else if (jQuery('#target option:selected').text().substring(0,5) == "Other") {
|
411
|
jQuery('#poolopts_tr').css('display','');
|
412
|
jQuery('#target_network').css('display','');
|
413
|
} else {
|
414
|
jQuery('#poolopts').prop('selectedIndex',0);
|
415
|
jQuery('#poolopts_tr').css('display','none');
|
416
|
jQuery('#target_network').css('display','none');
|
417
|
jQuery('#targetip').val('');
|
418
|
jQuery('#targetip_subnet').val('0');
|
419
|
}
|
420
|
}
|
421
|
//]]>
|
422
|
</script>
|
423
|
</head>
|
424
|
|
425
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
426
|
<?php include("fbegin.inc"); ?>
|
427
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
428
|
<form action="firewall_nat_out_edit.php" method="post" name="iform" id="iform">
|
429
|
<table width="100%" border="0" cellpadding="6" cellspacing="1" summary="firewall nat outbound edit">
|
430
|
<tr>
|
431
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit Advanced Outbound NAT entry");?></td>
|
432
|
</tr>
|
433
|
<?php
|
434
|
// Allow extending of the firewall edit page and include custom input validation
|
435
|
pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/htmlphpearly");
|
436
|
?>
|
437
|
<tr>
|
438
|
<td width="22%" valign="top" class="vncell"><?=gettext("Do not NAT");?></td>
|
439
|
<td width="78%" class="vtable">
|
440
|
<input type="checkbox" name="nonat" id="nonat" onclick="nonat_change();" <?php if(isset($pconfig['nonat'])) echo " checked=\"checked\""; ?> />
|
441
|
<span class="vexpl"><?=gettext("Enabling this option will disable NAT for traffic matching this rule and stop processing Outbound NAT rules.");?>
|
442
|
<br/><?=gettext("Hint: in most cases, you won't use this option.");?></span></td>
|
443
|
</tr>
|
444
|
<tr>
|
445
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface");?></td>
|
446
|
<td width="78%" class="vtable">
|
447
|
<select name="interface" class="formselect">
|
448
|
<?php
|
449
|
$iflist = get_configured_interface_with_descr(false, true);
|
450
|
foreach ($iflist as $if => $ifdesc)
|
451
|
if(have_ruleint_access($if))
|
452
|
$interfaces[$if] = $ifdesc;
|
453
|
|
454
|
if ($config['l2tp']['mode'] == "server")
|
455
|
if(have_ruleint_access("l2tp"))
|
456
|
$interfaces['l2tp'] = "L2TP VPN";
|
457
|
|
458
|
if ($config['pptpd']['mode'] == "server")
|
459
|
if(have_ruleint_access("pptp"))
|
460
|
$interfaces['pptp'] = "PPTP VPN";
|
461
|
|
462
|
if (is_pppoe_server_enabled() && have_ruleint_access("pppoe"))
|
463
|
$interfaces['pppoe'] = "PPPoE VPN";
|
464
|
|
465
|
/* add ipsec interfaces */
|
466
|
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable']))
|
467
|
if(have_ruleint_access("enc0"))
|
468
|
$interfaces["enc0"] = "IPsec";
|
469
|
|
470
|
/* add openvpn/tun interfaces */
|
471
|
if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
|
472
|
$interfaces["openvpn"] = "OpenVPN";
|
473
|
|
474
|
foreach ($interfaces as $iface => $ifacename): ?>
|
475
|
<option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo " selected=\"selected\""; ?>>
|
476
|
<?=htmlspecialchars($ifacename);?>
|
477
|
</option>
|
478
|
<?php endforeach; ?>
|
479
|
</select><br/>
|
480
|
<span class="vexpl"><?=gettext("Choose which interface this rule applies to.");?><br/>
|
481
|
<?=gettext("Hint: in most cases, you'll want to use WAN here.");?></span></td>
|
482
|
</tr>
|
483
|
<tr>
|
484
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
|
485
|
<td width="78%" class="vtable">
|
486
|
<select name="protocol" class="formselect" onchange="proto_change();">
|
487
|
<?php $protocols = explode(" ", "any TCP UDP TCP/UDP ICMP ESP AH GRE IPV6 IGMP carp pfsync");
|
488
|
foreach ($protocols as $proto): ?>
|
489
|
<option value="<?=strtolower($proto);?>" <?php if (strtolower($proto) == $pconfig['protocol']) echo " selected=\"selected\""; ?>><?=htmlspecialchars($proto);?></option>
|
490
|
<?php endforeach; ?>
|
491
|
</select> <br/> <span class="vexpl"><?=gettext("Choose which protocol this rule should match.");?><br />
|
492
|
<?php printf(gettext("Hint: in most cases, you should specify %s any %s here."),"<em>","</em> ");?></span>
|
493
|
</td>
|
494
|
</tr>
|
495
|
<tr>
|
496
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Source");?></td>
|
497
|
<td width="78%" class="vtable">
|
498
|
<table border="0" cellspacing="1" cellpadding="1" summary="source">
|
499
|
<tr>
|
500
|
<td><?=gettext("Type:");?> </td>
|
501
|
<td>
|
502
|
<select name="source_type" class="formselect" onchange="sourcesel_change()">
|
503
|
<option value="any" <?php if ($pconfig['source'] == "any") echo " selected=\"selected\""; ?>><?=gettext("any");?></option>
|
504
|
<option value="network" <?php if ($pconfig['source'] != "any") echo " selected=\"selected\""; ?>><?=gettext("Network");?></option>
|
505
|
</select>
|
506
|
</td>
|
507
|
</tr>
|
508
|
<tr>
|
509
|
<td><?=gettext("Address:");?> </td>
|
510
|
<td><input name="source" type="text" style="autocomplete:off" class="formfldalias" id="source" size="20" value="<?=htmlspecialchars($pconfig['source']);?>" />/<select name="source_subnet" class="formfld" id="source_subnet">
|
511
|
<?php for ($i = 32; $i >= 0; $i--): ?>
|
512
|
<option value="<?=$i;?>"<?php if ($i == $pconfig['source_subnet']) echo " selected=\"selected\""; ?>><?=$i;?></option>
|
513
|
<?php endfor; ?>
|
514
|
</select></td>
|
515
|
</tr>
|
516
|
<tr>
|
517
|
<td> </td>
|
518
|
<td><span class="vexpl"><?=gettext("Enter the source network for the outbound NAT mapping.");?></span></td>
|
519
|
</tr>
|
520
|
<tr id="sport_tr">
|
521
|
<td><?=gettext("Source port:");?> </td>
|
522
|
<td><input name="sourceport" type="text" style="autocomplete:off" class="formfldalias" id="sourceport" size="5" value="<?=htmlspecialchars($pconfig['sourceport']);?>" /> <?=gettext("(leave blank for any)");?></td>
|
523
|
</tr>
|
524
|
</table></td>
|
525
|
</tr>
|
526
|
<tr>
|
527
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Destination");?></td>
|
528
|
<td width="78%" class="vtable">
|
529
|
<input name="destination_not" type="checkbox" id="destination_not" value="yes" <?php if ($pconfig['destination_not']) echo "checked=\"checked\""; ?> />
|
530
|
<strong><?=gettext("not");?></strong><br/>
|
531
|
<?=gettext("Use this option to invert the sense of the match.");?><br/>
|
532
|
<br/>
|
533
|
<table border="0" cellspacing="1" cellpadding="1" summary="destination">
|
534
|
<tr>
|
535
|
<td><?=gettext("Type:");?> </td>
|
536
|
<td><select name="destination_type" class="formselect" onchange="typesel_change()">
|
537
|
<option value="any"<?php if ($pconfig['destination'] == "any") echo " selected=\"selected\""; ?>>
|
538
|
<?=gettext("any");?></option>
|
539
|
<option value="network"<?php if ($pconfig['destination'] != "any") echo " selected=\"selected\""; ?>>
|
540
|
<?=gettext("Network");?></option>
|
541
|
</select></td>
|
542
|
</tr>
|
543
|
<tr>
|
544
|
<td><?=gettext("Address:");?> </td>
|
545
|
<td><input name="destination" type="text" style="autocomplete:off" class="formfldalias" id="destination" size="20" value="<?=htmlspecialchars($pconfig['destination']);?>" />
|
546
|
/
|
547
|
<select name="destination_subnet" class="formselect" id="destination_subnet">
|
548
|
<?php for ($i = 32; $i >= 0; $i--): ?>
|
549
|
<option value="<?=$i;?>"<?php if ($i == $pconfig['destination_subnet']) echo " selected=\"selected\""; ?>><?=$i;?></option>
|
550
|
<?php endfor; ?>
|
551
|
</select> </td>
|
552
|
</tr>
|
553
|
<tr>
|
554
|
<td> </td>
|
555
|
<td><span class="vexpl"><?=gettext("Enter the destination network for ".
|
556
|
"the outbound NAT mapping.");?></span></td>
|
557
|
</tr>
|
558
|
<tr id="dport_tr">
|
559
|
<td><?=gettext("Destination port:");?> </td>
|
560
|
<td><input name="dstport" type="text" style="autocomplete:off" class="formfldalias" id="dstport" size="5" value="<?=htmlspecialchars($pconfig['dstport']);?>" /> <?=gettext("(leave blank for any)");?></td>
|
561
|
</tr>
|
562
|
</table>
|
563
|
</td>
|
564
|
</tr>
|
565
|
<tr id="transtable">
|
566
|
<td width="22%" valign="top" class="vncell"><?=gettext("Translation");?></td>
|
567
|
<td width="78%" class="vtable">
|
568
|
<table border="0" cellspacing="1" cellpadding="1" summary="translation">
|
569
|
<tr>
|
570
|
<td><?=gettext("Address:");?> </td>
|
571
|
<td><select name="target" class="formselect" id="target" onchange="poolopts_change();">
|
572
|
<option value=""<?php if (!$pconfig['target']) echo " selected=\"selected\""; ?>><?=gettext("Interface address");?></option>
|
573
|
<?php if (is_array($config['virtualip']['vip'])):
|
574
|
foreach ($config['virtualip']['vip'] as $sn):
|
575
|
if (isset($sn['noexpand']))
|
576
|
continue;
|
577
|
if ($sn['mode'] == "proxyarp" && $sn['type'] == "network"):
|
578
|
$start = ip2long32(gen_subnet($sn['subnet'], $sn['subnet_bits']));
|
579
|
$end = ip2long32(gen_subnet_max($sn['subnet'], $sn['subnet_bits']));
|
580
|
$len = $end - $start; ?>
|
581
|
<option value="<?=$sn['subnet'].'/'.$sn['subnet_bits'];?>" <?php if ($sn['subnet'].'/'.$sn['subnet_bits'] == $pconfig['target']) echo " selected=\"selected\""; ?>><?=htmlspecialchars("Subnet: {$sn['subnet']}/{$sn['subnet_bits']} ({$sn['descr']})");?></option>
|
582
|
<?php for ($i = 0; $i <= $len; $i++):
|
583
|
$snip = long2ip32($start+$i);
|
584
|
?>
|
585
|
<option value="<?=$snip;?>" <?php if ($snip == $pconfig['target']) echo "selected"; ?>><?=htmlspecialchars("{$snip} ({$sn['descr']})");?></option>
|
586
|
<?php endfor; ?>
|
587
|
<?php else: ?>
|
588
|
<option value="<?=$sn['subnet'];?>" <?php if ($sn['subnet'] == $pconfig['target']) echo " selected=\"selected\""; ?>><?=htmlspecialchars("{$sn['subnet']} ({$sn['descr']})");?></option>
|
589
|
<?php endif; endforeach;
|
590
|
endif;
|
591
|
foreach ($a_aliases as $alias):
|
592
|
if ($alias['type'] != "host")
|
593
|
continue; ?>
|
594
|
<option value="<?=$alias['name'];?>" <?php if ($alias['name'] == $pconfig['target']) echo " selected=\"selected\""; ?>><?=htmlspecialchars("Host Alias: {$alias['name']} ({$alias['descr']})");?></option>
|
595
|
<?php endforeach; ?>
|
596
|
<option value="other-subnet"<?php if($pconfig['target'] == "other-subnet") echo " selected=\"selected\""; ?>><?=gettext("Other Subnet (Enter Below)");?></option>
|
597
|
</select>
|
598
|
</td>
|
599
|
</tr>
|
600
|
|
601
|
<tr id="target_network">
|
602
|
<td><?=gettext("Other Subnet:");?> </td>
|
603
|
<td>
|
604
|
<input name="targetip" type="text" class="formfld unknown" id="targetip" size="20" value="<?=htmlspecialchars($pconfig['targetip']);?>" />/<select name="targetip_subnet" class="formfld" id="targetip_subnet">
|
605
|
<?php for ($i = 32; $i >= 0; $i--): ?>
|
606
|
<option value="<?=$i;?>"<?php if ($i == $pconfig['targetip_subnet']) echo " selected=\"selected\""; ?>><?=$i;?></option>
|
607
|
<?php endfor; ?>
|
608
|
</select>
|
609
|
</td>
|
610
|
</tr>
|
611
|
|
612
|
<tr><td> </td><td>
|
613
|
<span class="vexpl"><?=gettext("Packets matching this rule will be mapped to the IP address given here.");?><br/>
|
614
|
<?=gettext("If you want this rule to apply to another IP address rather than the IP address of the interface chosen above, ".
|
615
|
"select it here (you will need to define ");?> <a href="firewall_virtual_ip.php"><?=gettext("Virtual IP");?></a> <?=gettext("addresses on the interface first).");?>
|
616
|
</span><br/>
|
617
|
</td></tr>
|
618
|
<tr id="poolopts_tr">
|
619
|
<td valign="top">Pool Options</td>
|
620
|
<td>
|
621
|
<select name="poolopts" id="poolopts">
|
622
|
<option value="" <?php if ($pconfig['poolopts'] == "" ) echo " selected=\"selected\""; ?>><?=htmlspecialchars("Default" );?></option>
|
623
|
<option value="round-robin" <?php if ($pconfig['poolopts'] == "round-robin" ) echo " selected=\"selected\""; ?>><?=htmlspecialchars("Round Robin" );?></option>
|
624
|
<option value="round-robin sticky-address" <?php if ($pconfig['poolopts'] == "round-robin sticky-address") echo " selected=\"selected\""; ?>><?=htmlspecialchars("Round Robin with Sticky Address");?></option>
|
625
|
<option value="random" <?php if ($pconfig['poolopts'] == "random" ) echo " selected=\"selected\""; ?>><?=htmlspecialchars("Random" );?></option>
|
626
|
<option value="random sticky-address" <?php if ($pconfig['poolopts'] == "random sticky-address" ) echo " selected=\"selected\""; ?>><?=htmlspecialchars("Random with Sticky Address" );?></option>
|
627
|
<option value="source-hash" <?php if ($pconfig['poolopts'] == "source-hash" ) echo " selected=\"selected\""; ?>><?=htmlspecialchars("Source Hash" );?></option>
|
628
|
<option value="bitmask" <?php if ($pconfig['poolopts'] == "bitmask" ) echo " selected=\"selected\""; ?>><?=htmlspecialchars("Bitmask" );?></option>
|
629
|
</select><br/>
|
630
|
<span class="vexpl">
|
631
|
<?=gettext("Only Round Robin types work with Host Aliases. Any type can be used with a Subnet.");?><br/>
|
632
|
* <?=gettext("Round Robin: Loops through the translation addresses.");?><br/>
|
633
|
* <?=gettext("Random: Selects an address from the translation address pool at random.");?><br/>
|
634
|
* <?=gettext("Source Hash: Uses a hash of the source address to determine the translation address, ensuring that the redirection address is always the same for a given source.");?><br/>
|
635
|
* <?=gettext("Bitmask: Applies the subnet mask and keeps the last portion identical; 10.0.1.50 -> x.x.x.50.");?><br/>
|
636
|
* <?=gettext("Sticky Address: The Sticky Address option can be used with the Random and Round Robin pool types to ensure that a particular source address is always mapped to the same translation address.");?><br/>
|
637
|
</span><br/>
|
638
|
</td>
|
639
|
</tr>
|
640
|
<tr id="tport_tr">
|
641
|
<td><?=gettext("Port:");?> </td>
|
642
|
<td><input name="natport" type="text" class="formfld unknown" id="natport" size="5" value="<?=htmlspecialchars($pconfig['natport']);?>" /></td>
|
643
|
</tr>
|
644
|
<tr id="tporttext_tr"><td> </td><td>
|
645
|
<span class="vexpl"><?=gettext("Enter the source port for the outbound NAT mapping.");?></span>
|
646
|
</td></tr>
|
647
|
<tr id="tportstatic_tr">
|
648
|
<td><?=gettext("Static-port:");?> </td>
|
649
|
<td><input onchange="staticportchange();" name="staticnatport" type="checkbox" class="formfld" id="staticnatport" size="5"<?php if($pconfig['staticnatport']) echo " checked=\"checked\"";?> /></td>
|
650
|
</tr>
|
651
|
</table>
|
652
|
</td>
|
653
|
</tr>
|
654
|
<tr>
|
655
|
<td width="22%" valign="top" class="vncell"><?=gettext("No XMLRPC Sync");?></td>
|
656
|
<td width="78%" class="vtable">
|
657
|
<input value="yes" name="nosync" type="checkbox" class="formfld" id="nosync"<?php if($pconfig['nosync']) echo " checked=\"checked\""; ?> /><br/>
|
658
|
<?=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.");?>
|
659
|
</td>
|
660
|
</tr>
|
661
|
<tr>
|
662
|
<td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
|
663
|
<td width="78%" class="vtable">
|
664
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
|
665
|
<br/> <span class="vexpl"><?=gettext("You may enter a description here " .
|
666
|
"for your reference (not parsed).");?></span></td>
|
667
|
</tr>
|
668
|
<?php
|
669
|
$has_created_time = (isset($a_out[$id]['created']) && is_array($a_out[$id]['created']));
|
670
|
$has_updated_time = (isset($a_out[$id]['updated']) && is_array($a_out[$id]['updated']));
|
671
|
?>
|
672
|
<?php if ($has_created_time || $has_updated_time): ?>
|
673
|
<tr>
|
674
|
<td> </td>
|
675
|
</tr>
|
676
|
<tr>
|
677
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Rule Information");?></td>
|
678
|
</tr>
|
679
|
<?php if ($has_created_time): ?>
|
680
|
<tr>
|
681
|
<td width="22%" valign="top" class="vncell"><?=gettext("Created");?></td>
|
682
|
<td width="78%" class="vtable">
|
683
|
<?= date(gettext("n/j/y H:i:s"), $a_out[$id]['created']['time']) ?> <?= gettext("by") ?> <strong><?= $a_out[$id]['created']['username'] ?></strong>
|
684
|
</td>
|
685
|
</tr>
|
686
|
<?php endif; ?>
|
687
|
<?php if ($has_updated_time): ?>
|
688
|
<tr>
|
689
|
<td width="22%" valign="top" class="vncell"><?=gettext("Updated");?></td>
|
690
|
<td width="78%" class="vtable">
|
691
|
<?= date(gettext("n/j/y H:i:s"), $a_out[$id]['updated']['time']) ?> <?= gettext("by") ?> <strong><?= $a_out[$id]['updated']['username'] ?></strong>
|
692
|
</td>
|
693
|
</tr>
|
694
|
<?php endif; ?>
|
695
|
<?php endif; ?>
|
696
|
<?php
|
697
|
// Allow extending of the firewall edit page and include custom input validation
|
698
|
pfSense_handle_custom_code("/usr/local/pkg/firewall_aon/htmlphplate");
|
699
|
?>
|
700
|
<tr>
|
701
|
<td width="22%" valign="top"> </td>
|
702
|
<td width="78%">
|
703
|
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" /> <input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="history.back()" />
|
704
|
<?php if (isset($id) && $a_out[$id]): ?>
|
705
|
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
|
706
|
<?php endif; ?>
|
707
|
<input name="after" type="hidden" value="<?=htmlspecialchars($after);?>" />
|
708
|
</td>
|
709
|
</tr>
|
710
|
</table>
|
711
|
</form>
|
712
|
<script type="text/javascript">
|
713
|
//<![CDATA[
|
714
|
var autocomplete_off = ['source', 'sourceport', 'destination', 'dstport''];
|
715
|
for (var i = 0; i < autocomplete_off.length; i++) {
|
716
|
var node = document.getElementById(autocomplete_off[i]);
|
717
|
node.setAttribute("autocomplete",node.style.autocomplete);
|
718
|
}
|
719
|
//]]>
|
720
|
</script>
|
721
|
<script type="text/javascript">
|
722
|
//<![CDATA[
|
723
|
sourcesel_change();
|
724
|
typesel_change();
|
725
|
staticportchange();
|
726
|
nonat_change();
|
727
|
proto_change();
|
728
|
poolopts_change();
|
729
|
|
730
|
var addressarray = <?= json_encode(get_alias_list(array("host", "network", "openvpn", "urltable"))) ?>;
|
731
|
var customarray = <?= json_encode(get_alias_list("port")) ?>;
|
732
|
|
733
|
var oTextbox1 = new AutoSuggestControl(document.getElementById("source"), new StateSuggestions(addressarray));
|
734
|
var oTextbox2 = new AutoSuggestControl(document.getElementById("sourceport"), new StateSuggestions(customarray));
|
735
|
var oTextbox3 = new AutoSuggestControl(document.getElementById("destination"), new StateSuggestions(addressarray));
|
736
|
var oTextbox4 = new AutoSuggestControl(document.getElementById("dstport"), new StateSuggestions(customarray));
|
737
|
//]]>
|
738
|
</script>
|
739
|
<?php include("fend.inc"); ?>
|
740
|
</body>
|
741
|
</html>
|