1 |
340e6dca
|
Scott Ullrich
|
<?php
|
2 |
5b237745
|
Scott Ullrich
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* firewall_nat.php
|
4 |
9da2cf1c
|
Stephen Beaver
|
*
|
5 |
c5d81585
|
Renato Botelho
|
* part of pfSense (https://www.pfsense.org)
|
6 |
81299b5c
|
Renato Botelho
|
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
|
7 |
c5d81585
|
Renato Botelho
|
* All rights reserved.
|
8 |
fd9ebcd5
|
Stephen Beaver
|
*
|
9 |
c5d81585
|
Renato Botelho
|
* originally based on m0n0wall (http://m0n0.ch/wall)
|
10 |
|
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
11 |
|
|
* All rights reserved.
|
12 |
fd9ebcd5
|
Stephen Beaver
|
*
|
13 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
14 |
|
|
* you may not use this file except in compliance with the License.
|
15 |
|
|
* You may obtain a copy of the License at
|
16 |
fd9ebcd5
|
Stephen Beaver
|
*
|
17 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
18 |
fd9ebcd5
|
Stephen Beaver
|
*
|
19 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
20 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
21 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
22 |
|
|
* See the License for the specific language governing permissions and
|
23 |
|
|
* limitations under the License.
|
24 |
fd9ebcd5
|
Stephen Beaver
|
*/
|
25 |
5b237745
|
Scott Ullrich
|
|
26 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
27 |
|
|
##|*IDENT=page-firewall-nat-portforward
|
28 |
5230f468
|
jim-p
|
##|*NAME=Firewall: NAT: Port Forward
|
29 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'Firewall: NAT: Port Forward' page.
|
30 |
|
|
##|*MATCH=firewall_nat.php*
|
31 |
|
|
##|-PRIV
|
32 |
|
|
|
33 |
c81ef6e2
|
Phil Davis
|
require_once("guiconfig.inc");
|
34 |
7a927e67
|
Scott Ullrich
|
require_once("functions.inc");
|
35 |
|
|
require_once("filter.inc");
|
36 |
|
|
require_once("shaper.inc");
|
37 |
483e6de8
|
Scott Ullrich
|
require_once("itemid.inc");
|
38 |
5b237745
|
Scott Ullrich
|
|
39 |
37ba954d
|
Phil Davis
|
if (!is_array($config['nat']['rule'])) {
|
40 |
5b237745
|
Scott Ullrich
|
$config['nat']['rule'] = array();
|
41 |
37ba954d
|
Phil Davis
|
}
|
42 |
fbe94068
|
Scott Ullrich
|
|
43 |
5b237745
|
Scott Ullrich
|
$a_nat = &$config['nat']['rule'];
|
44 |
|
|
|
45 |
8bbab8a3
|
Stephen Beaver
|
/* update rule order, POST[rule] is an array of ordered IDs */
|
46 |
67c2baf1
|
Phil Davis
|
if (array_key_exists('order-store', $_POST)) {
|
47 |
6cb366de
|
Stephen Beaver
|
if (is_array($_POST['rule']) && !empty($_POST['rule'])) {
|
48 |
|
|
$a_nat_new = array();
|
49 |
8bbab8a3
|
Stephen Beaver
|
|
50 |
6cb366de
|
Stephen Beaver
|
// if a rule is not in POST[rule], it has been deleted by the user
|
51 |
67c2baf1
|
Phil Davis
|
foreach ($_POST['rule'] as $id) {
|
52 |
6cb366de
|
Stephen Beaver
|
$a_nat_new[] = $a_nat[$id];
|
53 |
67c2baf1
|
Phil Davis
|
}
|
54 |
8bbab8a3
|
Stephen Beaver
|
|
55 |
6cb366de
|
Stephen Beaver
|
$a_nat = $a_nat_new;
|
56 |
dbbd22f9
|
Stephen Beaver
|
|
57 |
7d8552fc
|
Stephen Beaver
|
|
58 |
|
|
$config['nat']['separator'] = "";
|
59 |
|
|
|
60 |
|
|
if ($_POST['separator']) {
|
61 |
|
|
$idx = 0;
|
62 |
|
|
foreach ($_POST['separator'] as $separator) {
|
63 |
|
|
$config['nat']['separator']['sep' . $idx++] = $separator;
|
64 |
|
|
}
|
65 |
|
|
}
|
66 |
|
|
|
67 |
67c2baf1
|
Phil Davis
|
if (write_config()) {
|
68 |
6cb366de
|
Stephen Beaver
|
mark_subsystem_dirty('filter');
|
69 |
67c2baf1
|
Phil Davis
|
}
|
70 |
dbbd22f9
|
Stephen Beaver
|
|
71 |
6cb366de
|
Stephen Beaver
|
header("Location: firewall_nat.php");
|
72 |
|
|
exit;
|
73 |
|
|
}
|
74 |
8bbab8a3
|
Stephen Beaver
|
}
|
75 |
|
|
|
76 |
514dbaf8
|
Scott Ullrich
|
/* if a custom message has been passed along, lets process it */
|
77 |
37ba954d
|
Phil Davis
|
if ($_GET['savemsg']) {
|
78 |
514dbaf8
|
Scott Ullrich
|
$savemsg = $_GET['savemsg'];
|
79 |
37ba954d
|
Phil Davis
|
}
|
80 |
514dbaf8
|
Scott Ullrich
|
|
81 |
5b237745
|
Scott Ullrich
|
if ($_POST) {
|
82 |
|
|
$pconfig = $_POST;
|
83 |
|
|
|
84 |
|
|
if ($_POST['apply']) {
|
85 |
e8c2c890
|
Bill Marquette
|
|
86 |
5b237745
|
Scott Ullrich
|
$retval = 0;
|
87 |
7a6c350f
|
Scott Ullrich
|
|
88 |
e2c9ef13
|
Scott Ullrich
|
$retval |= filter_configure();
|
89 |
05da8941
|
Erik Fonnesbeck
|
$savemsg = get_std_save_message($retval);
|
90 |
7d04082e
|
Scott Ullrich
|
|
91 |
1a700ea6
|
Scott Ullrich
|
pfSense_handle_custom_code("/usr/local/pkg/firewall_nat/apply");
|
92 |
|
|
|
93 |
5b237745
|
Scott Ullrich
|
if ($retval == 0) {
|
94 |
a368a026
|
Ermal Lu?i
|
clear_subsystem_dirty('natconf');
|
95 |
|
|
clear_subsystem_dirty('filter');
|
96 |
5b237745
|
Scott Ullrich
|
}
|
97 |
7d04082e
|
Scott Ullrich
|
|
98 |
5b237745
|
Scott Ullrich
|
}
|
99 |
|
|
}
|
100 |
|
|
|
101 |
759d0de1
|
Renato Botelho
|
if ($_GET['act'] == "del") {
|
102 |
|
|
if ($a_nat[$_GET['id']]) {
|
103 |
3a343d73
|
jim-p
|
|
104 |
759d0de1
|
Renato Botelho
|
if (isset($a_nat[$_GET['id']]['associated-rule-id'])) {
|
105 |
|
|
delete_id($a_nat[$_GET['id']]['associated-rule-id'], $config['filter']['rule']);
|
106 |
3a343d73
|
jim-p
|
$want_dirty_filter = true;
|
107 |
759d0de1
|
Renato Botelho
|
}
|
108 |
|
|
unset($a_nat[$_GET['id']]);
|
109 |
3a343d73
|
jim-p
|
|
110 |
7d8552fc
|
Stephen Beaver
|
// Update the separators
|
111 |
|
|
$a_separators = &$config['nat']['separator'];
|
112 |
a4f41878
|
NOYB
|
$ridx = $_GET['id'];
|
113 |
|
|
$mvnrows = -1;
|
114 |
|
|
move_separators($a_separators, $ridx, $mvnrows);
|
115 |
7d8552fc
|
Stephen Beaver
|
|
116 |
3a343d73
|
jim-p
|
if (write_config()) {
|
117 |
|
|
mark_subsystem_dirty('natconf');
|
118 |
37ba954d
|
Phil Davis
|
if ($want_dirty_filter) {
|
119 |
3a343d73
|
jim-p
|
mark_subsystem_dirty('filter');
|
120 |
37ba954d
|
Phil Davis
|
}
|
121 |
3a343d73
|
jim-p
|
}
|
122 |
0e6ac11d
|
Stephen Beaver
|
|
123 |
759d0de1
|
Renato Botelho
|
header("Location: firewall_nat.php");
|
124 |
|
|
exit;
|
125 |
|
|
}
|
126 |
|
|
}
|
127 |
|
|
|
128 |
00bcbdd0
|
Bill Marquette
|
if (isset($_POST['del_x'])) {
|
129 |
0e6ac11d
|
Stephen Beaver
|
/* delete selected rules */
|
130 |
|
|
if (is_array($_POST['rule']) && count($_POST['rule'])) {
|
131 |
7d8552fc
|
Stephen Beaver
|
$a_separators = &$config['nat']['separator'];
|
132 |
4b0815f3
|
Steve Beaver
|
$num_deleted = 0;
|
133 |
7d8552fc
|
Stephen Beaver
|
|
134 |
0e6ac11d
|
Stephen Beaver
|
foreach ($_POST['rule'] as $rulei) {
|
135 |
7d8552fc
|
Stephen Beaver
|
$target = $rule['target'];
|
136 |
|
|
|
137 |
b9e28d57
|
unknown
|
// Check for filter rule associations
|
138 |
6c07db48
|
Phil Davis
|
if (isset($a_nat[$rulei]['associated-rule-id'])) {
|
139 |
9b16b834
|
Ermal Lu?i
|
delete_id($a_nat[$rulei]['associated-rule-id'], $config['filter']['rule']);
|
140 |
b9e28d57
|
unknown
|
mark_subsystem_dirty('filter');
|
141 |
|
|
}
|
142 |
6cb366de
|
Stephen Beaver
|
|
143 |
0e6ac11d
|
Stephen Beaver
|
unset($a_nat[$rulei]);
|
144 |
7d8552fc
|
Stephen Beaver
|
|
145 |
|
|
// Update the separators
|
146 |
4b0815f3
|
Steve Beaver
|
// As rules are deleted, $ridx has to be decremented or separator position will break
|
147 |
|
|
$ridx = $rulei - $num_deleted;
|
148 |
a4f41878
|
NOYB
|
$mvnrows = -1;
|
149 |
|
|
move_separators($a_separators, $ridx, $mvnrows);
|
150 |
4b0815f3
|
Steve Beaver
|
$num_deleted++;
|
151 |
0e6ac11d
|
Stephen Beaver
|
}
|
152 |
6cb366de
|
Stephen Beaver
|
|
153 |
37ba954d
|
Phil Davis
|
if (write_config()) {
|
154 |
3a343d73
|
jim-p
|
mark_subsystem_dirty('natconf');
|
155 |
37ba954d
|
Phil Davis
|
}
|
156 |
6cb366de
|
Stephen Beaver
|
|
157 |
cd567545
|
Phil Davis
|
header("Location: firewall_nat.php");
|
158 |
|
|
exit;
|
159 |
|
|
}
|
160 |
|
|
} else if ($_GET['act'] == "toggle") {
|
161 |
|
|
if ($a_nat[$_GET['id']]) {
|
162 |
|
|
if (isset($a_nat[$_GET['id']]['disabled'])) {
|
163 |
|
|
unset($a_nat[$_GET['id']]['disabled']);
|
164 |
|
|
} else {
|
165 |
|
|
$a_nat[$_GET['id']]['disabled'] = true;
|
166 |
|
|
}
|
167 |
|
|
if (write_config(gettext("Firewall: NAT: Port forward, enable/disable NAT rule"))) {
|
168 |
|
|
mark_subsystem_dirty('natconf');
|
169 |
|
|
}
|
170 |
3a343d73
|
jim-p
|
header("Location: firewall_nat.php");
|
171 |
|
|
exit;
|
172 |
4b9a670c
|
Scott Ullrich
|
}
|
173 |
0e6ac11d
|
Stephen Beaver
|
}
|
174 |
|
|
|
175 |
6c07db48
|
Phil Davis
|
$pgtitle = array(gettext("Firewall"), gettext("NAT"), gettext("Port Forward"));
|
176 |
6eb17647
|
Scott Ullrich
|
include("head.inc");
|
177 |
|
|
|
178 |
67c2baf1
|
Phil Davis
|
if ($savemsg) {
|
179 |
0e6ac11d
|
Stephen Beaver
|
print_info_box($savemsg, 'success');
|
180 |
67c2baf1
|
Phil Davis
|
}
|
181 |
0e6ac11d
|
Stephen Beaver
|
|
182 |
67c2baf1
|
Phil Davis
|
if (is_subsystem_dirty('natconf')) {
|
183 |
3b3a95e5
|
Phil Davis
|
print_apply_box(gettext('The NAT configuration has been changed.') . '<br />' .
|
184 |
ee81ff38
|
NOYB
|
gettext('The changes must be applied for them to take effect.'));
|
185 |
67c2baf1
|
Phil Davis
|
}
|
186 |
2a9db752
|
Scott Dale
|
|
187 |
0e6ac11d
|
Stephen Beaver
|
$tab_array = array();
|
188 |
|
|
$tab_array[] = array(gettext("Port Forward"), true, "firewall_nat.php");
|
189 |
|
|
$tab_array[] = array(gettext("1:1"), false, "firewall_nat_1to1.php");
|
190 |
|
|
$tab_array[] = array(gettext("Outbound"), false, "firewall_nat_out.php");
|
191 |
|
|
$tab_array[] = array(gettext("NPt"), false, "firewall_nat_npt.php");
|
192 |
|
|
display_top_tabs($tab_array);
|
193 |
7d8552fc
|
Stephen Beaver
|
|
194 |
|
|
$columns_in_table = 13;
|
195 |
24f600b0
|
Scott Ullrich
|
?>
|
196 |
d16a49ae
|
Colin Fleming
|
|
197 |
00bcbdd0
|
Bill Marquette
|
<form action="firewall_nat.php" method="post" name="iform">
|
198 |
8bbab8a3
|
Stephen Beaver
|
<div class="panel panel-default">
|
199 |
95fa5cce
|
Phil Davis
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('Rules')?></h2></div>
|
200 |
8bbab8a3
|
Stephen Beaver
|
<div class="panel-body table-responsive">
|
201 |
7d8552fc
|
Stephen Beaver
|
<table id="ruletable" class="table table-striped table-hover table-condensed">
|
202 |
8bbab8a3
|
Stephen Beaver
|
<thead>
|
203 |
|
|
<tr>
|
204 |
7c540a5c
|
Stephen Beaver
|
<th><!-- Checkbox --></th>
|
205 |
cd567545
|
Phil Davis
|
<th><!-- Icon --></th>
|
206 |
8bbab8a3
|
Stephen Beaver
|
<th><!-- Rule type --></th>
|
207 |
5b8a7e90
|
NewEraCracker
|
<th><?=gettext("Interface")?></th>
|
208 |
66c62a1a
|
NewEraCracker
|
<th><?=gettext("Protocol")?></th>
|
209 |
a66ce627
|
NewEraCracker
|
<th><?=gettext("Source Address")?></th>
|
210 |
|
|
<th><?=gettext("Source Ports")?></th>
|
211 |
|
|
<th><?=gettext("Dest. Address")?></th>
|
212 |
|
|
<th><?=gettext("Dest. Ports")?></th>
|
213 |
8bbab8a3
|
Stephen Beaver
|
<th><?=gettext("NAT IP")?></th>
|
214 |
|
|
<th><?=gettext("NAT Ports")?></th>
|
215 |
|
|
<th><?=gettext("Description")?></th>
|
216 |
|
|
<th><?=gettext("Actions")?></th>
|
217 |
|
|
</tr>
|
218 |
|
|
</thead>
|
219 |
|
|
<tbody class='user-entries'>
|
220 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
221 |
dbbd22f9
|
Stephen Beaver
|
|
222 |
0e6ac11d
|
Stephen Beaver
|
$nnats = $i = 0;
|
223 |
ccc62f13
|
NOYB
|
$separators = $config['nat']['separator'];
|
224 |
0e6ac11d
|
Stephen Beaver
|
|
225 |
36bf13fd
|
NOYB
|
// Get a list of separator rows and use it to call the display separator function only for rows which there are separator(s).
|
226 |
|
|
// More efficient than looping through the list of separators on every row.
|
227 |
|
|
$seprows = separator_rows($separators);
|
228 |
7d8552fc
|
Stephen Beaver
|
|
229 |
0e6ac11d
|
Stephen Beaver
|
foreach ($a_nat as $natent):
|
230 |
|
|
|
231 |
36bf13fd
|
NOYB
|
// Display separator(s) for section beginning at rule n
|
232 |
|
|
if ($seprows[$nnats]) {
|
233 |
|
|
display_separator($separators, $nnats, $columns_in_table);
|
234 |
|
|
}
|
235 |
|
|
|
236 |
474e70a2
|
Stephen Beaver
|
$localport = $natent['local-port'];
|
237 |
|
|
|
238 |
|
|
list($dstbeginport, $dstendport) = explode("-", $natent['destination']['port']);
|
239 |
|
|
|
240 |
|
|
if ($dstendport) {
|
241 |
|
|
$localendport = $natent['local-port'] + $dstendport - $dstbeginport;
|
242 |
|
|
$localport .= '-' . $localendport;
|
243 |
|
|
}
|
244 |
|
|
|
245 |
dbbd22f9
|
Stephen Beaver
|
$alias = rule_columns_with_alias(
|
246 |
|
|
$natent['source']['address'],
|
247 |
|
|
pprint_port($natent['source']['port']),
|
248 |
|
|
$natent['destination']['address'],
|
249 |
474e70a2
|
Stephen Beaver
|
pprint_port($natent['destination']['port']),
|
250 |
|
|
$natent['target'],
|
251 |
|
|
$localport
|
252 |
dbbd22f9
|
Stephen Beaver
|
);
|
253 |
0e6ac11d
|
Stephen Beaver
|
|
254 |
dbbd22f9
|
Stephen Beaver
|
/* if user does not have access to edit an interface skip on to the next record */
|
255 |
67c2baf1
|
Phil Davis
|
if (!have_natpfruleint_access($natent['interface'])) {
|
256 |
dbbd22f9
|
Stephen Beaver
|
continue;
|
257 |
67c2baf1
|
Phil Davis
|
}
|
258 |
cd567545
|
Phil Davis
|
|
259 |
|
|
if (isset($natent['disabled'])) {
|
260 |
|
|
$iconfn = "pass_d";
|
261 |
|
|
$trclass = 'class="disabled"';
|
262 |
|
|
} else {
|
263 |
|
|
$iconfn = "pass";
|
264 |
|
|
$trclass = '';
|
265 |
|
|
}
|
266 |
0e6ac11d
|
Stephen Beaver
|
?>
|
267 |
7c540a5c
|
Stephen Beaver
|
|
268 |
cd567545
|
Phil Davis
|
<tr id="fr<?=$nnats;?>" <?=$trclass?> onClick="fr_toggle(<?=$nnats;?>)" ondblclick="document.location='firewall_nat_edit.php?id=<?=$i;?>';">
|
269 |
7c540a5c
|
Stephen Beaver
|
<td >
|
270 |
|
|
<input type="checkbox" id="frc<?=$nnats;?>" onClick="fr_toggle(<?=$nnats;?>)" name="rule[]" value="<?=$i;?>"/>
|
271 |
|
|
</td>
|
272 |
8bbab8a3
|
Stephen Beaver
|
<td>
|
273 |
cd567545
|
Phil Davis
|
<a href="?act=toggle&id=<?=$i?>">
|
274 |
|
|
<i class="fa <?= ($iconfn == "pass") ? "fa-check":"fa-times"?>" title="<?=gettext("click to toggle enabled/disabled status")?>"></i>
|
275 |
719635b2
|
jim-p
|
<?php if (isset($natent['nordr'])) { ?>
|
276 |
|
|
<i class="fa fa-hand-stop-o text-danger" title="<?=gettext("Negated: This rule excludes NAT from a later rule")?>"></i>
|
277 |
|
|
<?php } ?>
|
278 |
cd567545
|
Phil Davis
|
</a>
|
279 |
|
|
</td>
|
280 |
|
|
<td>
|
281 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
282 |
e6f34d22
|
Phil Davis
|
if ($natent['associated-rule-id'] == "pass"):
|
283 |
0e6ac11d
|
Stephen Beaver
|
?>
|
284 |
1b7379f9
|
Jared Dillard
|
<i class="fa fa-play" title="<?=gettext("All traffic matching this NAT entry is passed")?>"></i>
|
285 |
a8726a3d
|
Scott Ullrich
|
<?php
|
286 |
dbbd22f9
|
Stephen Beaver
|
elseif (!empty($natent['associated-rule-id'])):
|
287 |
a8726a3d
|
Scott Ullrich
|
?>
|
288 |
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>
|
289 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
290 |
dbbd22f9
|
Stephen Beaver
|
endif;
|
291 |
0e6ac11d
|
Stephen Beaver
|
?>
|
292 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
293 |
91d452c7
|
Stephen Beaver
|
<td>
|
294 |
8bbab8a3
|
Stephen Beaver
|
<?=$textss?>
|
295 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
296 |
67c2baf1
|
Phil Davis
|
if (!$natent['interface']) {
|
297 |
dbbd22f9
|
Stephen Beaver
|
echo htmlspecialchars(convert_friendly_interface_to_friendly_descr("wan"));
|
298 |
67c2baf1
|
Phil Davis
|
} else {
|
299 |
dbbd22f9
|
Stephen Beaver
|
echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface']));
|
300 |
67c2baf1
|
Phil Davis
|
}
|
301 |
0e6ac11d
|
Stephen Beaver
|
?>
|
302 |
8bbab8a3
|
Stephen Beaver
|
<?=$textse?>
|
303 |
|
|
</td>
|
304 |
dbbd22f9
|
Stephen Beaver
|
|
305 |
91d452c7
|
Stephen Beaver
|
<td>
|
306 |
8bbab8a3
|
Stephen Beaver
|
<?=$textss?><?=strtoupper($natent['protocol'])?><?=$textse?>
|
307 |
|
|
</td>
|
308 |
dbbd22f9
|
Stephen Beaver
|
|
309 |
91d452c7
|
Stephen Beaver
|
<td>
|
310 |
dbbd22f9
|
Stephen Beaver
|
|
311 |
|
|
|
312 |
|
|
<?php
|
313 |
|
|
if (isset($alias['src'])):
|
314 |
|
|
?>
|
315 |
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">
|
316 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
317 |
|
|
endif;
|
318 |
|
|
?>
|
319 |
ece727a7
|
NOYB
|
<?=str_replace('_', ' ', htmlspecialchars(pprint_address($natent['source'])))?>
|
320 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
321 |
|
|
if (isset($alias['src'])):
|
322 |
|
|
?>
|
323 |
27cb1f65
|
NOYB
|
</a>
|
324 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
325 |
|
|
endif;
|
326 |
|
|
?>
|
327 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
328 |
91d452c7
|
Stephen Beaver
|
<td>
|
329 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
330 |
|
|
if (isset($alias['srcport'])):
|
331 |
|
|
?>
|
332 |
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">
|
333 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
334 |
|
|
endif;
|
335 |
|
|
?>
|
336 |
ece727a7
|
NOYB
|
<?=str_replace('_', ' ', htmlspecialchars(pprint_port($natent['source']['port'])))?>
|
337 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
338 |
|
|
if (isset($alias['srcport'])):
|
339 |
|
|
?>
|
340 |
27cb1f65
|
NOYB
|
</a>
|
341 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
342 |
|
|
endif;
|
343 |
|
|
?>
|
344 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
345 |
dbbd22f9
|
Stephen Beaver
|
|
346 |
91d452c7
|
Stephen Beaver
|
<td>
|
347 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
348 |
|
|
if (isset($alias['dst'])):
|
349 |
|
|
?>
|
350 |
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">
|
351 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
352 |
|
|
endif;
|
353 |
|
|
?>
|
354 |
ece727a7
|
NOYB
|
<?=str_replace('_', ' ', htmlspecialchars(pprint_address($natent['destination'])))?>
|
355 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
356 |
|
|
if (isset($alias['dst'])):
|
357 |
|
|
?>
|
358 |
14a73423
|
NOYB
|
</a>
|
359 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
360 |
|
|
endif;
|
361 |
|
|
?>
|
362 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
363 |
91d452c7
|
Stephen Beaver
|
<td>
|
364 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
365 |
|
|
if (isset($alias['dstport'])):
|
366 |
|
|
?>
|
367 |
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">
|
368 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
369 |
|
|
endif;
|
370 |
|
|
?>
|
371 |
ece727a7
|
NOYB
|
<?=str_replace('_', ' ', htmlspecialchars(pprint_port($natent['destination']['port'])))?>
|
372 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
373 |
|
|
if (isset($alias['dstport'])):
|
374 |
|
|
?>
|
375 |
14a73423
|
NOYB
|
</a>
|
376 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
377 |
|
|
endif;
|
378 |
|
|
?>
|
379 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
380 |
474e70a2
|
Stephen Beaver
|
<td>
|
381 |
|
|
<?php
|
382 |
|
|
if (isset($alias['target'])):
|
383 |
|
|
?>
|
384 |
|
|
<a href="/firewall_aliases_edit.php?id=<?=$alias['target']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['target'])?>" data-html="true">
|
385 |
|
|
<?php
|
386 |
|
|
endif;
|
387 |
|
|
?>
|
388 |
dbbd22f9
|
Stephen Beaver
|
|
389 |
ece727a7
|
NOYB
|
<?=str_replace('_', ' ', htmlspecialchars($natent['target']))?>
|
390 |
474e70a2
|
Stephen Beaver
|
<?php
|
391 |
|
|
if (isset($alias['target'])):
|
392 |
|
|
?>
|
393 |
|
|
</a>
|
394 |
|
|
<?php
|
395 |
|
|
endif;
|
396 |
|
|
?>
|
397 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
398 |
91d452c7
|
Stephen Beaver
|
<td>
|
399 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
400 |
474e70a2
|
Stephen Beaver
|
if (isset($alias['targetport'])):
|
401 |
|
|
?>
|
402 |
|
|
<a href="/firewall_aliases_edit.php?id=<?=$alias['targetport']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['targetport'])?>" data-html="true">
|
403 |
|
|
<?php
|
404 |
|
|
endif;
|
405 |
0e6ac11d
|
Stephen Beaver
|
?>
|
406 |
ece727a7
|
NOYB
|
<?=str_replace('_', ' ', htmlspecialchars(pprint_port($localport)))?>
|
407 |
474e70a2
|
Stephen Beaver
|
<?php
|
408 |
|
|
if (isset($alias['targetport'])):
|
409 |
|
|
?>
|
410 |
|
|
</a>
|
411 |
|
|
<?php
|
412 |
|
|
endif;
|
413 |
|
|
?>
|
414 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
415 |
dbbd22f9
|
Stephen Beaver
|
|
416 |
91d452c7
|
Stephen Beaver
|
<td>
|
417 |
dbbd22f9
|
Stephen Beaver
|
<?=htmlspecialchars($natent['descr'])?>
|
418 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
419 |
91d452c7
|
Stephen Beaver
|
<td>
|
420 |
65a0e193
|
Stephen Beaver
|
<a class="fa fa-pencil" title="<?=gettext("Edit rule"); ?>" href="firewall_nat_edit.php?id=<?=$i?>"></a>
|
421 |
|
|
<a class="fa fa-clone" title="<?=gettext("Add a new NAT based on this one")?>" href="firewall_nat_edit.php?dup=<?=$i?>"></a>
|
422 |
314e439e
|
Stephen Beaver
|
<a class="fa fa-trash" title="<?=gettext("Delete rule")?>" href="firewall_nat.php?act=del&id=<?=$i?>"></a>
|
423 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
424 |
|
|
</tr>
|
425 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
426 |
|
|
$i++;
|
427 |
|
|
$nnats++;
|
428 |
8f561183
|
NOYB
|
|
429 |
0e6ac11d
|
Stephen Beaver
|
endforeach;
|
430 |
36bf13fd
|
NOYB
|
|
431 |
|
|
// There can be separator(s) after the last rule listed.
|
432 |
|
|
if ($seprows[$nnats]) {
|
433 |
|
|
display_separator($separators, $nnats, $columns_in_table);
|
434 |
|
|
}
|
435 |
0e6ac11d
|
Stephen Beaver
|
?>
|
436 |
8bbab8a3
|
Stephen Beaver
|
</tbody>
|
437 |
|
|
</table>
|
438 |
|
|
</div>
|
439 |
4cf530c4
|
Stephen Beaver
|
</div>
|
440 |
dbbd22f9
|
Stephen Beaver
|
|
441 |
c10cb196
|
Stephen Beaver
|
<nav class="action-buttons">
|
442 |
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')?>">
|
443 |
|
|
<i class="fa fa-level-up icon-embed-btn"></i>
|
444 |
0149ef4d
|
Stephen Beaver
|
<?=gettext('Add')?>
|
445 |
|
|
</a>
|
446 |
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')?>">
|
447 |
|
|
<i class="fa fa-level-down icon-embed-btn"></i>
|
448 |
|
|
<?=gettext('Add')?>
|
449 |
|
|
</a>
|
450 |
|
|
<button name="del_x" type="submit" class="btn btn-danger btn-sm" title="<?=gettext('Delete selected rules')?>">
|
451 |
9d5a20cf
|
heper
|
<i class="fa fa-trash icon-embed-btn"></i>
|
452 |
0149ef4d
|
Stephen Beaver
|
<?=gettext("Delete"); ?>
|
453 |
|
|
</button>
|
454 |
c4b60a9a
|
Colin Fleming
|
<button type="submit" id="order-store" name="order-store" class="btn btn-primary btn-sm" disabled title="<?=gettext('Save rule order')?>">
|
455 |
9d5a20cf
|
heper
|
<i class="fa fa-save icon-embed-btn"></i>
|
456 |
0149ef4d
|
Stephen Beaver
|
<?=gettext("Save")?>
|
457 |
|
|
</button>
|
458 |
7d8552fc
|
Stephen Beaver
|
<button type="submit" id="addsep" name="addsep" class="btn btn-sm btn-warning" title="<?=gettext('Add separator')?>">
|
459 |
|
|
<i class="fa fa-plus icon-embed-btn"></i>
|
460 |
|
|
<?=gettext("Separator")?>
|
461 |
|
|
</button>
|
462 |
09415b9e
|
Stephen Beaver
|
</nav>
|
463 |
0e6ac11d
|
Stephen Beaver
|
</form>
|
464 |
3d335c4d
|
Scott Ullrich
|
|
465 |
8fd9052f
|
Colin Fleming
|
<script type="text/javascript">
|
466 |
|
|
//<![CDATA[
|
467 |
2af731f8
|
NewEraCracker
|
//Need to create some variables here so that jquery/pfSenseHelpers.js can read them
|
468 |
7d8552fc
|
Stephen Beaver
|
iface = "<?=strtolower($if)?>";
|
469 |
|
|
cncltxt = '<?=gettext("Cancel")?>';
|
470 |
|
|
svtxt = '<?=gettext("Save")?>';
|
471 |
|
|
svbtnplaceholder = '<?=gettext("Enter a description, Save, then drag to final location.")?>';
|
472 |
|
|
configsection = "nat";
|
473 |
|
|
dirty = false;
|
474 |
|
|
|
475 |
65a0e193
|
Stephen Beaver
|
events.push(function() {
|
476 |
7c540a5c
|
Stephen Beaver
|
|
477 |
65a0e193
|
Stephen Beaver
|
// Make rules sortable
|
478 |
4cf530c4
|
Stephen Beaver
|
$('table tbody.user-entries').sortable({
|
479 |
|
|
cursor: 'grabbing',
|
480 |
|
|
update: function(event, ui) {
|
481 |
|
|
$('#order-store').removeAttr('disabled');
|
482 |
ae6814a2
|
Phil Davis
|
dirty = true;
|
483 |
7d8552fc
|
Stephen Beaver
|
reindex_rules(ui.item.parent('tbody'));
|
484 |
|
|
dirty = true;
|
485 |
4cf530c4
|
Stephen Beaver
|
}
|
486 |
|
|
});
|
487 |
6cb366de
|
Stephen Beaver
|
|
488 |
|
|
// Check all of the rule checkboxes so that their values are posted
|
489 |
|
|
$('#order-store').click(function () {
|
490 |
|
|
$('[id^=frc]').prop('checked', true);
|
491 |
ae6814a2
|
Phil Davis
|
|
492 |
7d8552fc
|
Stephen Beaver
|
// Save the separator bar configuration
|
493 |
|
|
save_separators();
|
494 |
|
|
|
495 |
ae6814a2
|
Phil Davis
|
// Suppress the "Do you really want to leave the page" message
|
496 |
|
|
saving = true;
|
497 |
7d8552fc
|
Stephen Beaver
|
|
498 |
ae6814a2
|
Phil Davis
|
});
|
499 |
|
|
|
500 |
|
|
// Globals
|
501 |
|
|
saving = false;
|
502 |
|
|
dirty = false;
|
503 |
|
|
|
504 |
|
|
// provide a warning message if the user tries to change page before saving
|
505 |
|
|
$(window).bind('beforeunload', function(){
|
506 |
|
|
if (!saving && dirty) {
|
507 |
ee81ff38
|
NOYB
|
return ("<?=gettext('One or more Port Forward rules have been moved but have not yet been saved')?>");
|
508 |
ae6814a2
|
Phil Davis
|
} else {
|
509 |
|
|
return undefined;
|
510 |
|
|
}
|
511 |
6cb366de
|
Stephen Beaver
|
});
|
512 |
4cf530c4
|
Stephen Beaver
|
});
|
513 |
8fd9052f
|
Colin Fleming
|
//]]>
|
514 |
4cf530c4
|
Stephen Beaver
|
</script>
|
515 |
3d335c4d
|
Scott Ullrich
|
<?php
|
516 |
0e6ac11d
|
Stephen Beaver
|
|
517 |
e6f34d22
|
Phil Davis
|
if (count($a_nat) > 0) {
|
518 |
3d335c4d
|
Scott Ullrich
|
?>
|
519 |
0e6ac11d
|
Stephen Beaver
|
<!-- Legend -->
|
520 |
|
|
<div>
|
521 |
|
|
<dl class="dl-horizontal responsive">
|
522 |
|
|
<dt><?=gettext('Legend')?></dt> <dd></dd>
|
523 |
1b7379f9
|
Jared Dillard
|
<dt><i class="fa fa-play"></i></dt> <dd><?=gettext('Pass')?></dd>
|
524 |
|
|
<dt><i class="fa fa-random"></i></dt> <dd><?=gettext('Linked rule')?></dd>
|
525 |
0e6ac11d
|
Stephen Beaver
|
</dl>
|
526 |
|
|
</div>
|
527 |
3d335c4d
|
Scott Ullrich
|
|
528 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
529 |
|
|
}
|
530 |
|
|
|
531 |
c10cb196
|
Stephen Beaver
|
include("foot.inc");
|