1 |
340e6dca
|
Scott Ullrich
|
<?php
|
2 |
5b237745
|
Scott Ullrich
|
/*
|
3 |
|
|
firewall_nat.php
|
4 |
|
|
*/
|
5 |
fd9ebcd5
|
Stephen Beaver
|
/* ====================================================================
|
6 |
7c540a5c
|
Stephen Beaver
|
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
|
7 |
9da2cf1c
|
Stephen Beaver
|
*
|
8 |
cb41dd63
|
Renato Botelho
|
* Some or all of this file is based on the m0n0wall project which is
|
9 |
|
|
* Copyright (c) 2004 Manuel Kasper (BSD 2 clause)
|
10 |
fd9ebcd5
|
Stephen Beaver
|
*
|
11 |
7c540a5c
|
Stephen Beaver
|
* Redistribution and use in source and binary forms, with or without modification,
|
12 |
|
|
* are permitted provided that the following conditions are met:
|
13 |
fd9ebcd5
|
Stephen Beaver
|
*
|
14 |
7c540a5c
|
Stephen Beaver
|
* 1. Redistributions of source code must retain the above copyright notice,
|
15 |
|
|
* this list of conditions and the following disclaimer.
|
16 |
fd9ebcd5
|
Stephen Beaver
|
*
|
17 |
7c540a5c
|
Stephen Beaver
|
* 2. Redistributions in binary form must reproduce the above copyright
|
18 |
|
|
* notice, this list of conditions and the following disclaimer in
|
19 |
|
|
* the documentation and/or other materials provided with the
|
20 |
|
|
* distribution.
|
21 |
fd9ebcd5
|
Stephen Beaver
|
*
|
22 |
7c540a5c
|
Stephen Beaver
|
* 3. All advertising materials mentioning features or use of this software
|
23 |
|
|
* must display the following acknowledgment:
|
24 |
|
|
* "This product includes software developed by the pfSense Project
|
25 |
|
|
* for use in the pfSense software distribution. (http://www.pfsense.org/).
|
26 |
fd9ebcd5
|
Stephen Beaver
|
*
|
27 |
7c540a5c
|
Stephen Beaver
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
28 |
|
|
* endorse or promote products derived from this software without
|
29 |
|
|
* prior written permission. For written permission, please contact
|
30 |
|
|
* coreteam@pfsense.org.
|
31 |
fd9ebcd5
|
Stephen Beaver
|
*
|
32 |
7c540a5c
|
Stephen Beaver
|
* 5. Products derived from this software may not be called "pfSense"
|
33 |
|
|
* nor may "pfSense" appear in their names without prior written
|
34 |
|
|
* permission of the Electric Sheep Fencing, LLC.
|
35 |
fd9ebcd5
|
Stephen Beaver
|
*
|
36 |
7c540a5c
|
Stephen Beaver
|
* 6. Redistributions of any form whatsoever must retain the following
|
37 |
|
|
* acknowledgment:
|
38 |
fd9ebcd5
|
Stephen Beaver
|
*
|
39 |
7c540a5c
|
Stephen Beaver
|
* "This product includes software developed by the pfSense Project
|
40 |
|
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
41 |
919d91f9
|
Phil Davis
|
*
|
42 |
7c540a5c
|
Stephen Beaver
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
43 |
|
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
44 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
45 |
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
46 |
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
47 |
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
48 |
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
49 |
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
50 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
51 |
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
52 |
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
53 |
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
54 |
fd9ebcd5
|
Stephen Beaver
|
*
|
55 |
7c540a5c
|
Stephen Beaver
|
* ====================================================================
|
56 |
fd9ebcd5
|
Stephen Beaver
|
*
|
57 |
|
|
*/
|
58 |
5b237745
|
Scott Ullrich
|
|
59 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
60 |
|
|
##|*IDENT=page-firewall-nat-portforward
|
61 |
5230f468
|
jim-p
|
##|*NAME=Firewall: NAT: Port Forward
|
62 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'Firewall: NAT: Port Forward' page.
|
63 |
|
|
##|*MATCH=firewall_nat.php*
|
64 |
|
|
##|-PRIV
|
65 |
|
|
|
66 |
5b237745
|
Scott Ullrich
|
require("guiconfig.inc");
|
67 |
7a927e67
|
Scott Ullrich
|
require_once("functions.inc");
|
68 |
|
|
require_once("filter.inc");
|
69 |
|
|
require_once("shaper.inc");
|
70 |
483e6de8
|
Scott Ullrich
|
require_once("itemid.inc");
|
71 |
5b237745
|
Scott Ullrich
|
|
72 |
37ba954d
|
Phil Davis
|
if (!is_array($config['nat']['rule'])) {
|
73 |
5b237745
|
Scott Ullrich
|
$config['nat']['rule'] = array();
|
74 |
37ba954d
|
Phil Davis
|
}
|
75 |
fbe94068
|
Scott Ullrich
|
|
76 |
5b237745
|
Scott Ullrich
|
$a_nat = &$config['nat']['rule'];
|
77 |
|
|
|
78 |
8bbab8a3
|
Stephen Beaver
|
/* update rule order, POST[rule] is an array of ordered IDs */
|
79 |
67c2baf1
|
Phil Davis
|
if (array_key_exists('order-store', $_POST)) {
|
80 |
6cb366de
|
Stephen Beaver
|
if (is_array($_POST['rule']) && !empty($_POST['rule'])) {
|
81 |
|
|
$a_nat_new = array();
|
82 |
8bbab8a3
|
Stephen Beaver
|
|
83 |
6cb366de
|
Stephen Beaver
|
// if a rule is not in POST[rule], it has been deleted by the user
|
84 |
67c2baf1
|
Phil Davis
|
foreach ($_POST['rule'] as $id) {
|
85 |
6cb366de
|
Stephen Beaver
|
$a_nat_new[] = $a_nat[$id];
|
86 |
67c2baf1
|
Phil Davis
|
}
|
87 |
8bbab8a3
|
Stephen Beaver
|
|
88 |
6cb366de
|
Stephen Beaver
|
$a_nat = $a_nat_new;
|
89 |
dbbd22f9
|
Stephen Beaver
|
|
90 |
67c2baf1
|
Phil Davis
|
if (write_config()) {
|
91 |
6cb366de
|
Stephen Beaver
|
mark_subsystem_dirty('filter');
|
92 |
67c2baf1
|
Phil Davis
|
}
|
93 |
dbbd22f9
|
Stephen Beaver
|
|
94 |
6cb366de
|
Stephen Beaver
|
header("Location: firewall_nat.php");
|
95 |
|
|
exit;
|
96 |
|
|
}
|
97 |
8bbab8a3
|
Stephen Beaver
|
}
|
98 |
|
|
|
99 |
514dbaf8
|
Scott Ullrich
|
/* if a custom message has been passed along, lets process it */
|
100 |
37ba954d
|
Phil Davis
|
if ($_GET['savemsg']) {
|
101 |
514dbaf8
|
Scott Ullrich
|
$savemsg = $_GET['savemsg'];
|
102 |
37ba954d
|
Phil Davis
|
}
|
103 |
514dbaf8
|
Scott Ullrich
|
|
104 |
5b237745
|
Scott Ullrich
|
if ($_POST) {
|
105 |
|
|
$pconfig = $_POST;
|
106 |
|
|
|
107 |
|
|
if ($_POST['apply']) {
|
108 |
e8c2c890
|
Bill Marquette
|
|
109 |
5b237745
|
Scott Ullrich
|
$retval = 0;
|
110 |
7a6c350f
|
Scott Ullrich
|
|
111 |
e2c9ef13
|
Scott Ullrich
|
$retval |= filter_configure();
|
112 |
05da8941
|
Erik Fonnesbeck
|
$savemsg = get_std_save_message($retval);
|
113 |
7d04082e
|
Scott Ullrich
|
|
114 |
1a700ea6
|
Scott Ullrich
|
pfSense_handle_custom_code("/usr/local/pkg/firewall_nat/apply");
|
115 |
|
|
|
116 |
5b237745
|
Scott Ullrich
|
if ($retval == 0) {
|
117 |
a368a026
|
Ermal Lu?i
|
clear_subsystem_dirty('natconf');
|
118 |
|
|
clear_subsystem_dirty('filter');
|
119 |
5b237745
|
Scott Ullrich
|
}
|
120 |
7d04082e
|
Scott Ullrich
|
|
121 |
5b237745
|
Scott Ullrich
|
}
|
122 |
|
|
}
|
123 |
|
|
|
124 |
759d0de1
|
Renato Botelho
|
if ($_GET['act'] == "del") {
|
125 |
|
|
if ($a_nat[$_GET['id']]) {
|
126 |
3a343d73
|
jim-p
|
|
127 |
759d0de1
|
Renato Botelho
|
if (isset($a_nat[$_GET['id']]['associated-rule-id'])) {
|
128 |
|
|
delete_id($a_nat[$_GET['id']]['associated-rule-id'], $config['filter']['rule']);
|
129 |
3a343d73
|
jim-p
|
$want_dirty_filter = true;
|
130 |
759d0de1
|
Renato Botelho
|
}
|
131 |
|
|
unset($a_nat[$_GET['id']]);
|
132 |
3a343d73
|
jim-p
|
|
133 |
|
|
if (write_config()) {
|
134 |
|
|
mark_subsystem_dirty('natconf');
|
135 |
37ba954d
|
Phil Davis
|
if ($want_dirty_filter) {
|
136 |
3a343d73
|
jim-p
|
mark_subsystem_dirty('filter');
|
137 |
37ba954d
|
Phil Davis
|
}
|
138 |
3a343d73
|
jim-p
|
}
|
139 |
0e6ac11d
|
Stephen Beaver
|
|
140 |
759d0de1
|
Renato Botelho
|
header("Location: firewall_nat.php");
|
141 |
|
|
exit;
|
142 |
|
|
}
|
143 |
|
|
}
|
144 |
|
|
|
145 |
00bcbdd0
|
Bill Marquette
|
if (isset($_POST['del_x'])) {
|
146 |
0e6ac11d
|
Stephen Beaver
|
/* delete selected rules */
|
147 |
|
|
if (is_array($_POST['rule']) && count($_POST['rule'])) {
|
148 |
|
|
foreach ($_POST['rule'] as $rulei) {
|
149 |
049a688e
|
Ermal Lu?i
|
$target = $rule['target'];
|
150 |
b9e28d57
|
unknown
|
// Check for filter rule associations
|
151 |
6c07db48
|
Phil Davis
|
if (isset($a_nat[$rulei]['associated-rule-id'])) {
|
152 |
9b16b834
|
Ermal Lu?i
|
delete_id($a_nat[$rulei]['associated-rule-id'], $config['filter']['rule']);
|
153 |
7d5b007c
|
Sjon Hortensius
|
|
154 |
b9e28d57
|
unknown
|
mark_subsystem_dirty('filter');
|
155 |
|
|
}
|
156 |
6cb366de
|
Stephen Beaver
|
|
157 |
0e6ac11d
|
Stephen Beaver
|
unset($a_nat[$rulei]);
|
158 |
|
|
}
|
159 |
6cb366de
|
Stephen Beaver
|
|
160 |
37ba954d
|
Phil Davis
|
if (write_config()) {
|
161 |
3a343d73
|
jim-p
|
mark_subsystem_dirty('natconf');
|
162 |
37ba954d
|
Phil Davis
|
}
|
163 |
6cb366de
|
Stephen Beaver
|
|
164 |
cd567545
|
Phil Davis
|
header("Location: firewall_nat.php");
|
165 |
|
|
exit;
|
166 |
|
|
}
|
167 |
|
|
} else if ($_GET['act'] == "toggle") {
|
168 |
|
|
if ($a_nat[$_GET['id']]) {
|
169 |
|
|
if (isset($a_nat[$_GET['id']]['disabled'])) {
|
170 |
|
|
unset($a_nat[$_GET['id']]['disabled']);
|
171 |
|
|
} else {
|
172 |
|
|
$a_nat[$_GET['id']]['disabled'] = true;
|
173 |
|
|
}
|
174 |
|
|
if (write_config(gettext("Firewall: NAT: Port forward, enable/disable NAT rule"))) {
|
175 |
|
|
mark_subsystem_dirty('natconf');
|
176 |
|
|
}
|
177 |
3a343d73
|
jim-p
|
header("Location: firewall_nat.php");
|
178 |
|
|
exit;
|
179 |
4b9a670c
|
Scott Ullrich
|
}
|
180 |
0e6ac11d
|
Stephen Beaver
|
}
|
181 |
|
|
|
182 |
6c07db48
|
Phil Davis
|
$pgtitle = array(gettext("Firewall"), gettext("NAT"), gettext("Port Forward"));
|
183 |
6eb17647
|
Scott Ullrich
|
include("head.inc");
|
184 |
|
|
|
185 |
67c2baf1
|
Phil Davis
|
if ($savemsg) {
|
186 |
0e6ac11d
|
Stephen Beaver
|
print_info_box($savemsg, 'success');
|
187 |
67c2baf1
|
Phil Davis
|
}
|
188 |
0e6ac11d
|
Stephen Beaver
|
|
189 |
67c2baf1
|
Phil Davis
|
if (is_subsystem_dirty('natconf')) {
|
190 |
3b3a95e5
|
Phil Davis
|
print_apply_box(gettext('The NAT configuration has been changed.') . '<br />' .
|
191 |
|
|
gettext('You must apply the changes in order for them to take effect.'));
|
192 |
67c2baf1
|
Phil Davis
|
}
|
193 |
2a9db752
|
Scott Dale
|
|
194 |
0e6ac11d
|
Stephen Beaver
|
$tab_array = array();
|
195 |
|
|
$tab_array[] = array(gettext("Port Forward"), true, "firewall_nat.php");
|
196 |
|
|
$tab_array[] = array(gettext("1:1"), false, "firewall_nat_1to1.php");
|
197 |
|
|
$tab_array[] = array(gettext("Outbound"), false, "firewall_nat_out.php");
|
198 |
|
|
$tab_array[] = array(gettext("NPt"), false, "firewall_nat_npt.php");
|
199 |
|
|
display_top_tabs($tab_array);
|
200 |
24f600b0
|
Scott Ullrich
|
?>
|
201 |
d16a49ae
|
Colin Fleming
|
|
202 |
00bcbdd0
|
Bill Marquette
|
<form action="firewall_nat.php" method="post" name="iform">
|
203 |
8bbab8a3
|
Stephen Beaver
|
<div class="panel panel-default">
|
204 |
95fa5cce
|
Phil Davis
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('Rules')?></h2></div>
|
205 |
8bbab8a3
|
Stephen Beaver
|
<div class="panel-body table-responsive">
|
206 |
|
|
<table class="table table-striped table-hover table-condensed">
|
207 |
|
|
<thead>
|
208 |
|
|
<tr>
|
209 |
7c540a5c
|
Stephen Beaver
|
<th><!-- Checkbox --></th>
|
210 |
cd567545
|
Phil Davis
|
<th><!-- Icon --></th>
|
211 |
8bbab8a3
|
Stephen Beaver
|
<th><!-- Rule type --></th>
|
212 |
5b8a7e90
|
NewEraCracker
|
<th><?=gettext("Interface")?></th>
|
213 |
66c62a1a
|
NewEraCracker
|
<th><?=gettext("Protocol")?></th>
|
214 |
a66ce627
|
NewEraCracker
|
<th><?=gettext("Source Address")?></th>
|
215 |
|
|
<th><?=gettext("Source Ports")?></th>
|
216 |
|
|
<th><?=gettext("Dest. Address")?></th>
|
217 |
|
|
<th><?=gettext("Dest. Ports")?></th>
|
218 |
8bbab8a3
|
Stephen Beaver
|
<th><?=gettext("NAT IP")?></th>
|
219 |
|
|
<th><?=gettext("NAT Ports")?></th>
|
220 |
|
|
<th><?=gettext("Description")?></th>
|
221 |
|
|
<th><?=gettext("Actions")?></th>
|
222 |
|
|
</tr>
|
223 |
|
|
</thead>
|
224 |
|
|
<tbody class='user-entries'>
|
225 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
226 |
dbbd22f9
|
Stephen Beaver
|
|
227 |
0e6ac11d
|
Stephen Beaver
|
$nnats = $i = 0;
|
228 |
|
|
|
229 |
|
|
foreach ($a_nat as $natent):
|
230 |
|
|
|
231 |
dbbd22f9
|
Stephen Beaver
|
$alias = rule_columns_with_alias(
|
232 |
|
|
$natent['source']['address'],
|
233 |
|
|
pprint_port($natent['source']['port']),
|
234 |
|
|
$natent['destination']['address'],
|
235 |
|
|
pprint_port($natent['destination']['port'])
|
236 |
|
|
);
|
237 |
0e6ac11d
|
Stephen Beaver
|
|
238 |
dbbd22f9
|
Stephen Beaver
|
/* if user does not have access to edit an interface skip on to the next record */
|
239 |
67c2baf1
|
Phil Davis
|
if (!have_natpfruleint_access($natent['interface'])) {
|
240 |
dbbd22f9
|
Stephen Beaver
|
continue;
|
241 |
67c2baf1
|
Phil Davis
|
}
|
242 |
cd567545
|
Phil Davis
|
|
243 |
|
|
if (isset($natent['disabled'])) {
|
244 |
|
|
$iconfn = "pass_d";
|
245 |
|
|
$trclass = 'class="disabled"';
|
246 |
|
|
} else {
|
247 |
|
|
$iconfn = "pass";
|
248 |
|
|
$trclass = '';
|
249 |
|
|
}
|
250 |
0e6ac11d
|
Stephen Beaver
|
?>
|
251 |
7c540a5c
|
Stephen Beaver
|
|
252 |
cd567545
|
Phil Davis
|
<tr id="fr<?=$nnats;?>" <?=$trclass?> onClick="fr_toggle(<?=$nnats;?>)" ondblclick="document.location='firewall_nat_edit.php?id=<?=$i;?>';">
|
253 |
7c540a5c
|
Stephen Beaver
|
<td >
|
254 |
|
|
<input type="checkbox" id="frc<?=$nnats;?>" onClick="fr_toggle(<?=$nnats;?>)" name="rule[]" value="<?=$i;?>"/>
|
255 |
|
|
</td>
|
256 |
8bbab8a3
|
Stephen Beaver
|
<td>
|
257 |
cd567545
|
Phil Davis
|
<a href="?act=toggle&id=<?=$i?>">
|
258 |
|
|
<i class="fa <?= ($iconfn == "pass") ? "fa-check":"fa-times"?>" title="<?=gettext("click to toggle enabled/disabled status")?>"></i>
|
259 |
|
|
</a>
|
260 |
|
|
</td>
|
261 |
|
|
<td>
|
262 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
263 |
e6f34d22
|
Phil Davis
|
if ($natent['associated-rule-id'] == "pass"):
|
264 |
0e6ac11d
|
Stephen Beaver
|
?>
|
265 |
1b7379f9
|
Jared Dillard
|
<i class="fa fa-play" title="<?=gettext("All traffic matching this NAT entry is passed")?>"></i>
|
266 |
a8726a3d
|
Scott Ullrich
|
<?php
|
267 |
dbbd22f9
|
Stephen Beaver
|
elseif (!empty($natent['associated-rule-id'])):
|
268 |
a8726a3d
|
Scott Ullrich
|
?>
|
269 |
7d95365e
|
Phil Davis
|
<i class="fa fa-random" title="<?=sprintf(gettext("Firewall rule ID %s is managed by this rule"), htmlspecialchars($natent['associated-rule-id']))?>"></i>
|
270 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
271 |
dbbd22f9
|
Stephen Beaver
|
endif;
|
272 |
0e6ac11d
|
Stephen Beaver
|
?>
|
273 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
274 |
91d452c7
|
Stephen Beaver
|
<td>
|
275 |
8bbab8a3
|
Stephen Beaver
|
<?=$textss?>
|
276 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
277 |
67c2baf1
|
Phil Davis
|
if (!$natent['interface']) {
|
278 |
dbbd22f9
|
Stephen Beaver
|
echo htmlspecialchars(convert_friendly_interface_to_friendly_descr("wan"));
|
279 |
67c2baf1
|
Phil Davis
|
} else {
|
280 |
dbbd22f9
|
Stephen Beaver
|
echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface']));
|
281 |
67c2baf1
|
Phil Davis
|
}
|
282 |
0e6ac11d
|
Stephen Beaver
|
?>
|
283 |
8bbab8a3
|
Stephen Beaver
|
<?=$textse?>
|
284 |
|
|
</td>
|
285 |
dbbd22f9
|
Stephen Beaver
|
|
286 |
91d452c7
|
Stephen Beaver
|
<td>
|
287 |
8bbab8a3
|
Stephen Beaver
|
<?=$textss?><?=strtoupper($natent['protocol'])?><?=$textse?>
|
288 |
|
|
</td>
|
289 |
dbbd22f9
|
Stephen Beaver
|
|
290 |
91d452c7
|
Stephen Beaver
|
<td>
|
291 |
dbbd22f9
|
Stephen Beaver
|
|
292 |
|
|
|
293 |
|
|
<?php
|
294 |
|
|
if (isset($alias['src'])):
|
295 |
|
|
?>
|
296 |
7d95365e
|
Phil Davis
|
<a href="/firewall_aliases_edit.php?id=<?=$alias['src']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['src'])?>" data-html="true">
|
297 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
298 |
|
|
endif;
|
299 |
|
|
?>
|
300 |
|
|
<?=htmlspecialchars(pprint_address($natent['source']))?>
|
301 |
|
|
<?php
|
302 |
|
|
if (isset($alias['src'])):
|
303 |
|
|
?>
|
304 |
1b7379f9
|
Jared Dillard
|
<i class='fa fa-pencil'></i></a>
|
305 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
306 |
|
|
endif;
|
307 |
|
|
?>
|
308 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
309 |
91d452c7
|
Stephen Beaver
|
<td>
|
310 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
311 |
|
|
if (isset($alias['srcport'])):
|
312 |
|
|
?>
|
313 |
7d95365e
|
Phil Davis
|
<a href="/firewall_aliases_edit.php?id=<?=$alias['srcport']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['srcport'])?>" data-html="true">
|
314 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
315 |
|
|
endif;
|
316 |
|
|
?>
|
317 |
|
|
<?=htmlspecialchars(pprint_port($natent['source']['port']))?>
|
318 |
|
|
<?php
|
319 |
|
|
if (isset($alias['srcport'])):
|
320 |
|
|
?>
|
321 |
1b7379f9
|
Jared Dillard
|
<i class='fa fa-pencil'></i></a>
|
322 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
323 |
|
|
endif;
|
324 |
|
|
?>
|
325 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
326 |
dbbd22f9
|
Stephen Beaver
|
|
327 |
91d452c7
|
Stephen Beaver
|
<td>
|
328 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
329 |
|
|
if (isset($alias['dst'])):
|
330 |
|
|
?>
|
331 |
7d95365e
|
Phil Davis
|
<a href="/firewall_aliases_edit.php?id=<?=$alias['dst']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['dst'])?>" data-html="true">
|
332 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
333 |
|
|
endif;
|
334 |
|
|
?>
|
335 |
|
|
<?=htmlspecialchars(pprint_address($natent['destination']))?>
|
336 |
|
|
<?php
|
337 |
|
|
if (isset($alias['dst'])):
|
338 |
|
|
?>
|
339 |
1b7379f9
|
Jared Dillard
|
<i class='fa fa-pencil'></i></a>
|
340 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
341 |
|
|
endif;
|
342 |
|
|
?>
|
343 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
344 |
91d452c7
|
Stephen Beaver
|
<td>
|
345 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
346 |
|
|
if (isset($alias['dstport'])):
|
347 |
|
|
?>
|
348 |
7d95365e
|
Phil Davis
|
<a href="/firewall_aliases_edit.php?id=<?=$alias['dstport']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['dstport'])?>" data-html="true">
|
349 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
350 |
|
|
endif;
|
351 |
|
|
?>
|
352 |
|
|
<?=htmlspecialchars(pprint_port($natent['destination']['port']))?>
|
353 |
|
|
<?php
|
354 |
|
|
if (isset($alias['dstport'])):
|
355 |
|
|
?>
|
356 |
1b7379f9
|
Jared Dillard
|
<i class='fa fa-pencil'></i></a>
|
357 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
358 |
|
|
endif;
|
359 |
|
|
?>
|
360 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
361 |
dbbd22f9
|
Stephen Beaver
|
|
362 |
91d452c7
|
Stephen Beaver
|
<td >
|
363 |
dbbd22f9
|
Stephen Beaver
|
<?=htmlspecialchars($natent['target'])?>
|
364 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
365 |
91d452c7
|
Stephen Beaver
|
<td>
|
366 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
367 |
dbbd22f9
|
Stephen Beaver
|
$localport = $natent['local-port'];
|
368 |
0e6ac11d
|
Stephen Beaver
|
|
369 |
dbbd22f9
|
Stephen Beaver
|
list($dstbeginport, $dstendport) = explode("-", $natent['destination']['port']);
|
370 |
0e6ac11d
|
Stephen Beaver
|
|
371 |
dbbd22f9
|
Stephen Beaver
|
if ($dstendport) {
|
372 |
|
|
$localendport = $natent['local-port'] + $dstendport - $dstbeginport;
|
373 |
|
|
$localport .= '-' . $localendport;
|
374 |
|
|
}
|
375 |
0e6ac11d
|
Stephen Beaver
|
?>
|
376 |
dbbd22f9
|
Stephen Beaver
|
<?=htmlspecialchars(pprint_port($localport))?>
|
377 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
378 |
dbbd22f9
|
Stephen Beaver
|
|
379 |
91d452c7
|
Stephen Beaver
|
<td>
|
380 |
dbbd22f9
|
Stephen Beaver
|
<?=htmlspecialchars($natent['descr'])?>
|
381 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
382 |
91d452c7
|
Stephen Beaver
|
<td>
|
383 |
65a0e193
|
Stephen Beaver
|
<a class="fa fa-pencil" title="<?=gettext("Edit rule"); ?>" href="firewall_nat_edit.php?id=<?=$i?>"></a>
|
384 |
|
|
<a class="fa fa-clone" title="<?=gettext("Add a new NAT based on this one")?>" href="firewall_nat_edit.php?dup=<?=$i?>"></a>
|
385 |
314e439e
|
Stephen Beaver
|
<a class="fa fa-trash" title="<?=gettext("Delete rule")?>" href="firewall_nat.php?act=del&id=<?=$i?>"></a>
|
386 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
387 |
|
|
</tr>
|
388 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
389 |
|
|
$i++;
|
390 |
|
|
$nnats++;
|
391 |
|
|
endforeach;
|
392 |
|
|
?>
|
393 |
8bbab8a3
|
Stephen Beaver
|
</tbody>
|
394 |
|
|
</table>
|
395 |
|
|
</div>
|
396 |
4cf530c4
|
Stephen Beaver
|
</div>
|
397 |
dbbd22f9
|
Stephen Beaver
|
|
398 |
c10cb196
|
Stephen Beaver
|
<nav class="action-buttons">
|
399 |
b807e59c
|
Stephen Beaver
|
<a href="firewall_nat_edit.php?after=-1" class="btn btn-sm btn-success" title="<?=gettext('Add rule to the top of the list')?>">
|
400 |
|
|
<i class="fa fa-level-up icon-embed-btn"></i>
|
401 |
0149ef4d
|
Stephen Beaver
|
<?=gettext('Add')?>
|
402 |
|
|
</a>
|
403 |
b807e59c
|
Stephen Beaver
|
<a href="firewall_nat_edit.php" class="btn btn-sm btn-success" title="<?=gettext('Add rule to the end of the list')?>">
|
404 |
|
|
<i class="fa fa-level-down icon-embed-btn"></i>
|
405 |
|
|
<?=gettext('Add')?>
|
406 |
|
|
</a>
|
407 |
|
|
<button name="del_x" type="submit" class="btn btn-danger btn-sm" title="<?=gettext('Delete selected rules')?>">
|
408 |
9d5a20cf
|
heper
|
<i class="fa fa-trash icon-embed-btn"></i>
|
409 |
0149ef4d
|
Stephen Beaver
|
<?=gettext("Delete"); ?>
|
410 |
|
|
</button>
|
411 |
c4b60a9a
|
Colin Fleming
|
<button type="submit" id="order-store" name="order-store" class="btn btn-primary btn-sm" disabled title="<?=gettext('Save rule order')?>">
|
412 |
9d5a20cf
|
heper
|
<i class="fa fa-save icon-embed-btn"></i>
|
413 |
0149ef4d
|
Stephen Beaver
|
<?=gettext("Save")?>
|
414 |
|
|
</button>
|
415 |
09415b9e
|
Stephen Beaver
|
</nav>
|
416 |
0e6ac11d
|
Stephen Beaver
|
</form>
|
417 |
3d335c4d
|
Scott Ullrich
|
|
418 |
8fd9052f
|
Colin Fleming
|
<script type="text/javascript">
|
419 |
|
|
//<![CDATA[
|
420 |
65a0e193
|
Stephen Beaver
|
events.push(function() {
|
421 |
7c540a5c
|
Stephen Beaver
|
|
422 |
65a0e193
|
Stephen Beaver
|
// Make rules sortable
|
423 |
4cf530c4
|
Stephen Beaver
|
$('table tbody.user-entries').sortable({
|
424 |
|
|
cursor: 'grabbing',
|
425 |
|
|
update: function(event, ui) {
|
426 |
|
|
$('#order-store').removeAttr('disabled');
|
427 |
|
|
}
|
428 |
|
|
});
|
429 |
6cb366de
|
Stephen Beaver
|
|
430 |
|
|
// Check all of the rule checkboxes so that their values are posted
|
431 |
|
|
$('#order-store').click(function () {
|
432 |
|
|
$('[id^=frc]').prop('checked', true);
|
433 |
|
|
});
|
434 |
4cf530c4
|
Stephen Beaver
|
});
|
435 |
8fd9052f
|
Colin Fleming
|
//]]>
|
436 |
4cf530c4
|
Stephen Beaver
|
</script>
|
437 |
3d335c4d
|
Scott Ullrich
|
<?php
|
438 |
0e6ac11d
|
Stephen Beaver
|
|
439 |
e6f34d22
|
Phil Davis
|
if (count($a_nat) > 0) {
|
440 |
3d335c4d
|
Scott Ullrich
|
?>
|
441 |
0e6ac11d
|
Stephen Beaver
|
<!-- Legend -->
|
442 |
|
|
<div>
|
443 |
|
|
<dl class="dl-horizontal responsive">
|
444 |
|
|
<dt><?=gettext('Legend')?></dt> <dd></dd>
|
445 |
1b7379f9
|
Jared Dillard
|
<dt><i class="fa fa-play"></i></dt> <dd><?=gettext('Pass')?></dd>
|
446 |
|
|
<dt><i class="fa fa-random"></i></dt> <dd><?=gettext('Linked rule')?></dd>
|
447 |
0e6ac11d
|
Stephen Beaver
|
</dl>
|
448 |
|
|
</div>
|
449 |
3d335c4d
|
Scott Ullrich
|
|
450 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
451 |
|
|
}
|
452 |
|
|
|
453 |
c10cb196
|
Stephen Beaver
|
include("foot.inc");
|