1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
firewall_nat_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
|
pfSense_MODULE: nat
|
33
|
*/
|
34
|
|
35
|
##|+PRIV
|
36
|
##|*IDENT=page-firewall-nat-portforward-edit
|
37
|
##|*NAME=Firewall: NAT: Port Forward: Edit page
|
38
|
##|*DESCR=Allow access to the 'Firewall: NAT: Port Forward: Edit' page.
|
39
|
##|*MATCH=firewall_nat_edit.php*
|
40
|
##|-PRIV
|
41
|
|
42
|
require("guiconfig.inc");
|
43
|
require_once("itemid.inc");
|
44
|
require("filter.inc");
|
45
|
require("shaper.inc");
|
46
|
|
47
|
if (!is_array($config['nat']['rule'])) {
|
48
|
$config['nat']['rule'] = array();
|
49
|
}
|
50
|
$a_nat = &$config['nat']['rule'];
|
51
|
|
52
|
$id = $_GET['id'];
|
53
|
if (isset($_POST['id']))
|
54
|
$id = $_POST['id'];
|
55
|
|
56
|
if (isset($_GET['dup'])) {
|
57
|
$id = $_GET['dup'];
|
58
|
$after = $_GET['dup'];
|
59
|
}
|
60
|
|
61
|
if (isset($id) && $a_nat[$id]) {
|
62
|
$pconfig['extaddr'] = $a_nat[$id]['external-address'];
|
63
|
$pconfig['proto'] = $a_nat[$id]['protocol'];
|
64
|
list($pconfig['beginport'],$pconfig['endport']) = explode("-", $a_nat[$id]['external-port']);
|
65
|
if(!$pconfig['endport'])
|
66
|
$pconfig['endport'] = $pconfig['beginport'];
|
67
|
$pconfig['localip'] = $a_nat[$id]['target'];
|
68
|
$pconfig['localbeginport'] = $a_nat[$id]['local-port'];
|
69
|
$pconfig['descr'] = $a_nat[$id]['descr'];
|
70
|
$pconfig['interface'] = $a_nat[$id]['interface'];
|
71
|
$pconfig['associated-rule-id'] = $a_nat[$id]['associated-rule-id'];
|
72
|
$pconfig['nosync'] = isset($a_nat[$id]['nosync']);
|
73
|
if (!$pconfig['interface'])
|
74
|
$pconfig['interface'] = "wan";
|
75
|
} else {
|
76
|
$pconfig['interface'] = "wan";
|
77
|
}
|
78
|
|
79
|
if (isset($_GET['dup']))
|
80
|
unset($id);
|
81
|
|
82
|
/* run through $_POST items encoding HTML entties so that the user
|
83
|
* cannot think he is slick and perform a XSS attack on the unwilling
|
84
|
*/
|
85
|
foreach ($_POST as $key => $value) {
|
86
|
$temp = $value;
|
87
|
$newpost = htmlentities($temp);
|
88
|
if($newpost <> $temp)
|
89
|
$input_errors[] = "Invalid characters detected ($temp). Please remove invalid characters and save again.";
|
90
|
}
|
91
|
|
92
|
if ($_POST) {
|
93
|
|
94
|
if ($_POST['beginport_cust'] && !$_POST['beginport'])
|
95
|
$_POST['beginport'] = $_POST['beginport_cust'];
|
96
|
if ($_POST['endport_cust'] && !$_POST['endport'])
|
97
|
$_POST['endport'] = $_POST['endport_cust'];
|
98
|
if ($_POST['localbeginport_cust'] && !$_POST['localbeginport'])
|
99
|
$_POST['localbeginport'] = $_POST['localbeginport_cust'];
|
100
|
|
101
|
if (!$_POST['endport'])
|
102
|
$_POST['endport'] = $_POST['beginport'];
|
103
|
/* Make beginning port end port if not defined and endport is */
|
104
|
if (!$_POST['beginport'] && $_POST['endport'])
|
105
|
$_POST['beginport'] = $_POST['endport'];
|
106
|
|
107
|
unset($input_errors);
|
108
|
$pconfig = $_POST;
|
109
|
|
110
|
/* input validation */
|
111
|
if(strtoupper($_POST['proto']) == "TCP" or strtoupper($_POST['proto']) == "UDP" or strtoupper($_POST['proto']) == "TCP/UDP") {
|
112
|
$reqdfields = explode(" ", "interface proto beginport endport localip localbeginport");
|
113
|
$reqdfieldsn = explode(",", "Interface,Protocol,External port from,External port to,NAT IP,Local port");
|
114
|
} else {
|
115
|
$reqdfields = explode(" ", "interface proto localip");
|
116
|
$reqdfieldsn = explode(",", "Interface,Protocol,NAT IP");
|
117
|
}
|
118
|
|
119
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
120
|
|
121
|
if (($_POST['localip'] && !is_ipaddroralias($_POST['localip']))) {
|
122
|
$input_errors[] = "\"{$_POST['localip']}\" is not valid NAT IP address or host alias.";
|
123
|
}
|
124
|
|
125
|
/* only validate the ports if the protocol is TCP, UDP or TCP/UDP */
|
126
|
if(strtoupper($_POST['proto']) == "TCP" or strtoupper($_POST['proto']) == "UDP" or strtoupper($_POST['proto']) == "TCP/UDP") {
|
127
|
|
128
|
if ($_POST['beginport'] && !is_portoralias($_POST['beginport'])) {
|
129
|
$input_errors[] = "The start port must be an integer between 1 and 65535.";
|
130
|
}
|
131
|
|
132
|
if ($_POST['endport'] && !is_portoralias($_POST['endport'])) {
|
133
|
$input_errors[] = "The end port must be an integer between 1 and 65535.";
|
134
|
}
|
135
|
|
136
|
if ($_POST['localbeginport'] && !is_portoralias($_POST['localbeginport'])) {
|
137
|
$input_errors[] = "The local port must be an integer between 1 and 65535.";
|
138
|
}
|
139
|
|
140
|
if ($_POST['beginport'] > $_POST['endport']) {
|
141
|
/* swap */
|
142
|
$tmp = $_POST['endport'];
|
143
|
$_POST['endport'] = $_POST['beginport'];
|
144
|
$_POST['beginport'] = $tmp;
|
145
|
}
|
146
|
|
147
|
if (!$input_errors) {
|
148
|
if (($_POST['endport'] - $_POST['beginport'] + $_POST['localbeginport']) > 65535)
|
149
|
$input_errors[] = "The target port range must be an integer between 1 and 65535.";
|
150
|
}
|
151
|
|
152
|
}
|
153
|
|
154
|
/* check for overlaps */
|
155
|
foreach ($a_nat as $natent) {
|
156
|
if (isset($id) && ($a_nat[$id]) && ($a_nat[$id] === $natent))
|
157
|
continue;
|
158
|
if ($natent['interface'] != $_POST['interface'])
|
159
|
continue;
|
160
|
if ($natent['external-address'] != $_POST['extaddr'])
|
161
|
continue;
|
162
|
if (($natent['proto'] != $_POST['proto']) && ($natent['proto'] != "tcp/udp") && ($_POST['proto'] != "tcp/udp"))
|
163
|
continue;
|
164
|
|
165
|
list($begp,$endp) = explode("-", $natent['external-port']);
|
166
|
if (!$endp)
|
167
|
$endp = $begp;
|
168
|
|
169
|
if (!( (($_POST['beginport'] < $begp) && ($_POST['endport'] < $begp))
|
170
|
|| (($_POST['beginport'] > $endp) && ($_POST['endport'] > $endp)))) {
|
171
|
|
172
|
$input_errors[] = "The external port range overlaps with an existing entry.";
|
173
|
break;
|
174
|
}
|
175
|
}
|
176
|
|
177
|
if (!$input_errors) {
|
178
|
$natent = array();
|
179
|
if ($_POST['extaddr'])
|
180
|
$natent['external-address'] = $_POST['extaddr'];
|
181
|
$natent['protocol'] = $_POST['proto'];
|
182
|
|
183
|
if ($_POST['beginport'] == $_POST['endport'])
|
184
|
$natent['external-port'] = $_POST['beginport'];
|
185
|
else
|
186
|
$natent['external-port'] = $_POST['beginport'] . "-" . $_POST['endport'];
|
187
|
|
188
|
$natent['target'] = $_POST['localip'];
|
189
|
$natent['local-port'] = $_POST['localbeginport'];
|
190
|
$natent['interface'] = $_POST['interface'];
|
191
|
$natent['descr'] = $_POST['descr'];
|
192
|
$natent['associated-rule-id'] = $_POST['associated-rule-id'];
|
193
|
|
194
|
if($_POST['filter-rule-association'] == "pass")
|
195
|
$natent['associated-rule-id'] = "pass";
|
196
|
|
197
|
if($_POST['nosync'] == "yes")
|
198
|
$natent['nosync'] = true;
|
199
|
else
|
200
|
unset($natent['nosync']);
|
201
|
|
202
|
// If we used to have an associated filter rule, but no-longer should have one
|
203
|
if ($a_nat[$id]>0 && empty($natent['associated-rule-id'])) {
|
204
|
// Delete the previous rule
|
205
|
delete_id($a_nat[$id]['associated-rule-id'], $config['filter']['rule']);
|
206
|
mark_subsystem_dirty('filter');
|
207
|
}
|
208
|
|
209
|
$need_filter_rule = false;
|
210
|
// Updating a rule with a filter rule associated
|
211
|
if (!empty($natent['associated-rule-id']))
|
212
|
$need_filter_rule = true;
|
213
|
// Create a rule or if we want to create a new one
|
214
|
if( $natent['associated-rule-id']=='new' ) {
|
215
|
$need_filter_rule = true;
|
216
|
unset( $natent['associated-rule-id'] );
|
217
|
$_POST['filter-rule-association']='add-associated';
|
218
|
}
|
219
|
// If creating a new rule, where we want to add the filter rule, associated or not
|
220
|
else if( isset($_POST['filter-rule-association']) &&
|
221
|
($_POST['filter-rule-association']=='add-associated' ||
|
222
|
$_POST['filter-rule-association']=='add-unassociated') )
|
223
|
$need_filter_rule = true;
|
224
|
|
225
|
// Determine NAT entry ID now, we need it for the firewall rule
|
226
|
if (isset($id) && $a_nat[$id])
|
227
|
$a_nat[$id] = $natent;
|
228
|
else {
|
229
|
if (is_numeric($after))
|
230
|
$id = $after + 1;
|
231
|
else
|
232
|
$id = count($a_nat);
|
233
|
}
|
234
|
|
235
|
if ($need_filter_rule == true) {
|
236
|
|
237
|
/* auto-generate a matching firewall rule */
|
238
|
$filterent = array();
|
239
|
unset($filterentid);
|
240
|
// If a rule already exists, load it
|
241
|
if (!empty($natent['associated-rule-id'])) {
|
242
|
$filterentid = get_id($natent['associated-rule-id'], $config['filter']['rule']);
|
243
|
if ($filterentid == false) {
|
244
|
$filterent['source']['any'] = "";
|
245
|
$filterent['associated-rule-id'] = $natent['associated-rule-id'];
|
246
|
} else
|
247
|
$filterent =& $config['filter']['rule'][$filterentid];
|
248
|
} else
|
249
|
// Create the default source entry for new filter entries
|
250
|
$filterent['source']['any'] = "";
|
251
|
|
252
|
// Update interface, protocol and destination
|
253
|
$filterent['interface'] = $_POST['interface'];
|
254
|
$filterent['protocol'] = $_POST['proto'];
|
255
|
$filterent['destination']['address'] = $_POST['localip'];
|
256
|
|
257
|
$dstpfrom = $_POST['localbeginport'];
|
258
|
$dstpto = $dstpfrom + $_POST['endport'] - $_POST['beginport'];
|
259
|
|
260
|
if ($dstpfrom == $dstpto)
|
261
|
$filterent['destination']['port'] = $dstpfrom;
|
262
|
else
|
263
|
$filterent['destination']['port'] = $dstpfrom . "-" . $dstpto;
|
264
|
|
265
|
/*
|
266
|
* Our firewall filter description may be no longer than
|
267
|
* 63 characters, so don't let it be.
|
268
|
*/
|
269
|
$filterent['descr'] = substr("NAT " . $_POST['descr'], 0, 62);
|
270
|
|
271
|
// If this is a new rule, create an ID and add the rule
|
272
|
if( $_POST['filter-rule-association']=='add-associated' ) {
|
273
|
$filterent['associated-rule-id'] = $natent['associated-rule-id'] = get_unique_id();
|
274
|
$config['filter']['rule'][] = $filterent;
|
275
|
}
|
276
|
|
277
|
mark_subsystem_dirty('filter');
|
278
|
}
|
279
|
|
280
|
// Update the NAT entry now
|
281
|
if (isset($id) && $a_nat[$id])
|
282
|
$a_nat[$id] = $natent;
|
283
|
else {
|
284
|
if (is_numeric($after))
|
285
|
array_splice($a_nat, $after+1, 0, array($natent));
|
286
|
else
|
287
|
$a_nat[] = $natent;
|
288
|
}
|
289
|
|
290
|
mark_subsystem_dirty('natconf');
|
291
|
|
292
|
write_config();
|
293
|
|
294
|
header("Location: firewall_nat.php");
|
295
|
exit;
|
296
|
}
|
297
|
}
|
298
|
|
299
|
$pgtitle = array("Firewall","NAT","Port Forward: Edit");
|
300
|
include("head.inc");
|
301
|
|
302
|
?>
|
303
|
|
304
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
305
|
<?php
|
306
|
include("fbegin.inc"); ?>
|
307
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
308
|
<form action="firewall_nat_edit.php" method="post" name="iform" id="iform">
|
309
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
310
|
<tr>
|
311
|
<td colspan="2" valign="top" class="listtopic">Edit NAT entry</td>
|
312
|
</tr>
|
313
|
<tr>
|
314
|
<td width="22%" valign="top" class="vncellreq">Interface</td>
|
315
|
<td width="78%" class="vtable">
|
316
|
<select name="interface" class="formselect">
|
317
|
<?php
|
318
|
|
319
|
$iflist = get_configured_interface_with_descr(false, true);
|
320
|
foreach ($iflist as $if => $ifdesc)
|
321
|
if(have_ruleint_access($if))
|
322
|
$interfaces[$if] = $ifdesc;
|
323
|
|
324
|
if ($config['pptpd']['mode'] == "server")
|
325
|
if(have_ruleint_access("pptp"))
|
326
|
$interfaces['pptp'] = "PPTP VPN";
|
327
|
|
328
|
if ($config['pppoe']['mode'] == "server")
|
329
|
if(have_ruleint_access("pppoe"))
|
330
|
$interfaces['pppoe'] = "PPPoE VPN";
|
331
|
|
332
|
/* add ipsec interfaces */
|
333
|
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable']))
|
334
|
if(have_ruleint_access("enc0"))
|
335
|
$interfaces["enc0"] = "IPsec";
|
336
|
|
337
|
foreach ($interfaces as $iface => $ifacename): ?>
|
338
|
<option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected"; ?>>
|
339
|
<?=htmlspecialchars($ifacename);?>
|
340
|
</option>
|
341
|
<?php endforeach; ?>
|
342
|
</select><br>
|
343
|
<span class="vexpl">Choose which interface this rule applies to.<br>
|
344
|
Hint: in most cases, you'll want to use WAN here.</span></td>
|
345
|
</tr>
|
346
|
<tr>
|
347
|
<td width="22%" valign="top" class="vncellreq">External address</td>
|
348
|
<td width="78%" class="vtable">
|
349
|
<select name="extaddr" class="formselect">
|
350
|
<option value="" <?php if (!$pconfig['extaddr']) echo "selected"; ?>>Interface address</option>
|
351
|
<?php if (is_array($config['virtualip']['vip'])):
|
352
|
foreach ($config['virtualip']['vip'] as $sn): ?>
|
353
|
<option value="<?=$sn['subnet'];?>" <?php if ($sn['subnet'] == $pconfig['extaddr']) echo "selected"; ?>><?=htmlspecialchars("{$sn['subnet']} ({$sn['descr']})");?></option>
|
354
|
<?php endforeach;
|
355
|
endif; ?>
|
356
|
<option value="any" <?php if($pconfig['extaddr'] == "any") echo "selected"; ?>>any</option>
|
357
|
</select>
|
358
|
<br />
|
359
|
<span class="vexpl">
|
360
|
If you want this rule to apply to another IP address than the IP address of the interface chosen above,
|
361
|
select it here (you need to define <a href="firewall_virtual_ip.php">Virtual IP</a> addresses on the first). Also note that if you are trying to redirect connections on the LAN select the "any" option.</span></td>
|
362
|
</tr>
|
363
|
<tr>
|
364
|
<td width="22%" valign="top" class="vncellreq">Protocol</td>
|
365
|
<td width="78%" class="vtable">
|
366
|
<select name="proto" class="formselect" onChange="proto_change(); check_for_aliases();">
|
367
|
<?php $protocols = explode(" ", "TCP UDP TCP/UDP GRE ESP"); foreach ($protocols as $proto): ?>
|
368
|
<option value="<?=strtolower($proto);?>" <?php if (strtolower($proto) == $pconfig['proto']) echo "selected"; ?>><?=htmlspecialchars($proto);?></option>
|
369
|
<?php endforeach; ?>
|
370
|
</select> <br> <span class="vexpl">Choose which IP protocol
|
371
|
this rule should match.<br>
|
372
|
Hint: in most cases, you should specify <em>TCP</em> here.</span></td>
|
373
|
</tr>
|
374
|
<tr>
|
375
|
<td width="22%" valign="top" class="vncellreq">External port
|
376
|
range </td>
|
377
|
<td width="78%" class="vtable">
|
378
|
<table border="0" cellspacing="0" cellpadding="0">
|
379
|
<tr>
|
380
|
<td>from: </td>
|
381
|
<td><select name="beginport" class="formselect" onChange="ext_rep_change(); ext_change(); check_for_aliases();">
|
382
|
<option value="">(other)</option>
|
383
|
<?php $bfound = 0; foreach ($wkports as $wkport => $wkportdesc): ?>
|
384
|
<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['beginport']) {
|
385
|
echo "selected";
|
386
|
$bfound = 1;
|
387
|
}?>>
|
388
|
<?=htmlspecialchars($wkportdesc);?>
|
389
|
</option>
|
390
|
<?php endforeach; ?>
|
391
|
</select> <input onChange="check_for_aliases();" autocomplete='off' class="formfldalias" name="beginport_cust" id="beginport_cust" type="text" size="5" value="<?php if (!$bfound) echo $pconfig['beginport']; ?>"></td>
|
392
|
</tr>
|
393
|
<tr>
|
394
|
<td>to:</td>
|
395
|
<td><select name="endport" class="formselect" onChange="ext_change(); check_for_aliases();">
|
396
|
<option value="">(other)</option>
|
397
|
<?php $bfound = 0; foreach ($wkports as $wkport => $wkportdesc): ?>
|
398
|
<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['endport']) {
|
399
|
echo "selected";
|
400
|
$bfound = 1;
|
401
|
}?>>
|
402
|
<?=htmlspecialchars($wkportdesc);?>
|
403
|
</option>
|
404
|
<?php endforeach; ?>
|
405
|
</select> <input onChange="check_for_aliases();" class="formfldalias" autocomplete='off' name="endport_cust" id="endport_cust" type="text" size="5" value="<?php if (!$bfound) echo $pconfig['endport']; ?>"></td>
|
406
|
</tr>
|
407
|
</table>
|
408
|
<br> <span class="vexpl">Specify the port or port range on
|
409
|
the firewall's external address for this mapping.<br>
|
410
|
Hint: you can leave the <em>'to'</em> field empty if you only
|
411
|
want to map a single port</span></td>
|
412
|
</tr>
|
413
|
<tr>
|
414
|
<td width="22%" valign="top" class="vncellreq">NAT IP</td>
|
415
|
<td width="78%" class="vtable">
|
416
|
<input autocomplete='off' name="localip" type="text" class="formfldalias" id="localip" size="20" value="<?=htmlspecialchars($pconfig['localip']);?>">
|
417
|
<br> <span class="vexpl">Enter the internal IP address of
|
418
|
the server on which you want to map the ports.<br>
|
419
|
e.g. <em>192.168.1.12</em></span></td>
|
420
|
</tr>
|
421
|
<tr>
|
422
|
<td width="22%" valign="top" class="vncellreq">Local port</td>
|
423
|
<td width="78%" class="vtable">
|
424
|
<select name="localbeginport" class="formselect" onChange="ext_change();check_for_aliases();">
|
425
|
<option value="">(other)</option>
|
426
|
<?php $bfound = 0; foreach ($wkports as $wkport => $wkportdesc): ?>
|
427
|
<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['localbeginport']) {
|
428
|
echo "selected";
|
429
|
$bfound = 1;
|
430
|
}?>>
|
431
|
<?=htmlspecialchars($wkportdesc);?>
|
432
|
</option>
|
433
|
<?php endforeach; ?>
|
434
|
</select> <input onChange="check_for_aliases();" autocomplete='off' class="formfldalias" name="localbeginport_cust" id="localbeginport_cust" type="text" size="5" value="<?php if (!$bfound) echo $pconfig['localbeginport']; ?>">
|
435
|
<br>
|
436
|
<span class="vexpl">Specify the port on the machine with the
|
437
|
IP address entered above. In case of a port range, specify
|
438
|
the beginning port of the range (the end port will be calculated
|
439
|
automatically).<br>
|
440
|
Hint: this is usually identical to the 'from' port above</span></td>
|
441
|
</tr>
|
442
|
<tr>
|
443
|
<td width="22%" valign="top" class="vncell">Description</td>
|
444
|
<td width="78%" class="vtable">
|
445
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
|
446
|
<br> <span class="vexpl">You may enter a description here
|
447
|
for your reference (not parsed).</span></td>
|
448
|
</tr>
|
449
|
<tr>
|
450
|
<td width="22%" valign="top" class="vncell">No XMLRPC Sync</td>
|
451
|
<td width="78%" class="vtable">
|
452
|
<input type="checkbox" value="yes" name="nosync"<?php if($pconfig['nosync']) echo " CHECKED"; ?>><br>
|
453
|
HINT: This prevents the rule from automatically syncing to other CARP members.
|
454
|
</td>
|
455
|
</tr>
|
456
|
<?php if (isset($id) && $a_nat[$id] && !isset($_GET['dup'])): ?>
|
457
|
<tr>
|
458
|
<td width="22%" valign="top" class="vncell">Filter rule association</td>
|
459
|
<td width="78%" class="vtable">
|
460
|
<select name="associated-rule-id">
|
461
|
<option value="">None</option>
|
462
|
<option value="pass" <?php if($pconfig['associated-rule-id'] == "pass") echo " SELECTED"; ?>>Pass</option>
|
463
|
<?php
|
464
|
if (is_array($config['filter']['rule'])) {
|
465
|
foreach ($config['filter']['rule'] as $filter_rule) {
|
466
|
if (isset($filter_rule['associated-rule-id'])) {
|
467
|
echo "<option value=\"{$filter_rule['associated-rule-id']}\"";
|
468
|
if ($filter_rule['associated-rule-id']==$pconfig['associated-rule-id'])
|
469
|
echo " SELECTED";
|
470
|
echo ">". htmlspecialchars('Rule ' . $filter_rule['descr']) . "</option>\n";
|
471
|
|
472
|
}
|
473
|
}
|
474
|
}
|
475
|
if (isset($pconfig['associated-rule-id']))
|
476
|
echo "<option value=\"new\">Create new associated filter rule</option>\n";
|
477
|
echo "</select>\n";
|
478
|
if(isset($pconfig['associated-rule-id']) && is_array($config['filter']['rule'])) {
|
479
|
foreach( $config['filter']['rule'] as $index => $filter_rule ) {
|
480
|
if( $filter_rule['assocaited-rule-id']==$pconfig['associated-rule-id'] ) {
|
481
|
echo "<a href=\"firewall_rules_edit.php?id={$filter_rule[$index]}\">View the filter rule</a>";
|
482
|
break;
|
483
|
}
|
484
|
}
|
485
|
}
|
486
|
?>
|
487
|
</td>
|
488
|
</tr>
|
489
|
<?php endif; ?>
|
490
|
<?php if ((!(isset($id) && $a_nat[$id])) || (isset($_GET['dup']))): ?>
|
491
|
<tr>
|
492
|
<td width="22%" valign="top" class="vncell">Filter rule association</td>
|
493
|
<td width="78%" class="vtable">
|
494
|
<select name="filter-rule-association" id="filter-rule-association">
|
495
|
<option value="">None</option>
|
496
|
<option value="add-associated" selected="selected">Add associated filter rule</option>
|
497
|
<option value="add-unassociated">Add unassociated filter rule</option>
|
498
|
<option value="pass">Pass</option>
|
499
|
</select>
|
500
|
</td>
|
501
|
</tr><?php endif; ?>
|
502
|
<tr>
|
503
|
<td width="22%" valign="top"> </td>
|
504
|
<td width="78%"> </td>
|
505
|
</tr>
|
506
|
<tr>
|
507
|
<td width="22%" valign="top"> </td>
|
508
|
<td width="78%">
|
509
|
<input name="Submit" type="submit" class="formbtn" value="Save"> <input type="button" class="formbtn" value="Cancel" onclick="history.back()">
|
510
|
<?php if (isset($id) && $a_nat[$id]): ?>
|
511
|
<input name="id" type="hidden" value="<?=$id;?>">
|
512
|
<?php endif; ?>
|
513
|
</td>
|
514
|
</tr>
|
515
|
</table>
|
516
|
</form>
|
517
|
<script language="JavaScript">
|
518
|
<!--
|
519
|
ext_change();
|
520
|
//-->
|
521
|
</script>
|
522
|
<?php
|
523
|
$isfirst = 0;
|
524
|
$aliases = "";
|
525
|
$addrisfirst = 0;
|
526
|
$aliasesaddr = "";
|
527
|
if($config['aliases']['alias'] <> "")
|
528
|
foreach($config['aliases']['alias'] as $alias_name) {
|
529
|
switch ($alias_name['type']) {
|
530
|
case "port":
|
531
|
if($isfirst == 1) $portaliases .= ",";
|
532
|
$portaliases .= "'" . $alias_name['name'] . "'";
|
533
|
$isfirst = 1;
|
534
|
break;
|
535
|
case "host":
|
536
|
case "network":
|
537
|
case "openvpn":
|
538
|
if($addrisfirst == 1) $aliasesaddr .= ",";
|
539
|
$aliasesaddr .= "'" . $alias_name['name'] . "'";
|
540
|
$addrisfirst = 1;
|
541
|
break;
|
542
|
default:
|
543
|
break;
|
544
|
}
|
545
|
}
|
546
|
?>
|
547
|
<script language="JavaScript">
|
548
|
<!--
|
549
|
var addressarray=new Array(<?php echo $aliasesaddr; ?>);
|
550
|
var customarray=new Array(<?php echo $portaliases; ?>);
|
551
|
|
552
|
var oTextbox1 = new AutoSuggestControl(document.getElementById("localip"), new StateSuggestions(addressarray));
|
553
|
var oTextbox2 = new AutoSuggestControl(document.getElementById("beginport_cust"), new StateSuggestions(customarray));
|
554
|
var oTextbox3 = new AutoSuggestControl(document.getElementById("endport_cust"), new StateSuggestions(customarray));
|
555
|
var oTextbox4 = new AutoSuggestControl(document.getElementById("localbeginport_cust"), new StateSuggestions(customarray));
|
556
|
//-->
|
557
|
</script>
|
558
|
<?php include("fend.inc"); ?>
|
559
|
</body>
|
560
|
</html>
|