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 |
84147b7b
|
Steve Beaver
|
if (array_key_exists('order-store', $_REQUEST)) {
|
47 |
|
|
if (is_array($_REQUEST['rule']) && !empty($_REQUEST['rule'])) {
|
48 |
6cb366de
|
Stephen Beaver
|
$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 |
84147b7b
|
Steve Beaver
|
if ($_REQUEST['savemsg']) {
|
78 |
|
|
$savemsg = $_REQUEST['savemsg'];
|
79 |
31bdcffb
|
Steve Beaver
|
}
|
80 |
5b237745
|
Scott Ullrich
|
|
81 |
31bdcffb
|
Steve Beaver
|
if ($_POST['apply']) {
|
82 |
e8c2c890
|
Bill Marquette
|
|
83 |
31bdcffb
|
Steve Beaver
|
$retval = 0;
|
84 |
7a6c350f
|
Scott Ullrich
|
|
85 |
31bdcffb
|
Steve Beaver
|
$retval |= filter_configure();
|
86 |
7d04082e
|
Scott Ullrich
|
|
87 |
31bdcffb
|
Steve Beaver
|
pfSense_handle_custom_code("/usr/local/pkg/firewall_nat/apply");
|
88 |
7d04082e
|
Scott Ullrich
|
|
89 |
31bdcffb
|
Steve Beaver
|
if ($retval == 0) {
|
90 |
|
|
clear_subsystem_dirty('natconf');
|
91 |
|
|
clear_subsystem_dirty('filter');
|
92 |
5b237745
|
Scott Ullrich
|
}
|
93 |
31bdcffb
|
Steve Beaver
|
|
94 |
5b237745
|
Scott Ullrich
|
}
|
95 |
|
|
|
96 |
31bdcffb
|
Steve Beaver
|
if ($_POST['act'] == "del") {
|
97 |
|
|
if ($a_nat[$_POST['id']]) {
|
98 |
3a343d73
|
jim-p
|
|
99 |
31bdcffb
|
Steve Beaver
|
if (isset($a_nat[$_POST['id']]['associated-rule-id'])) {
|
100 |
|
|
delete_id($a_nat[$_POST['id']]['associated-rule-id'], $config['filter']['rule']);
|
101 |
3a343d73
|
jim-p
|
$want_dirty_filter = true;
|
102 |
759d0de1
|
Renato Botelho
|
}
|
103 |
84147b7b
|
Steve Beaver
|
|
104 |
31bdcffb
|
Steve Beaver
|
unset($a_nat[$_POST['id']]);
|
105 |
3a343d73
|
jim-p
|
|
106 |
7d8552fc
|
Stephen Beaver
|
// Update the separators
|
107 |
|
|
$a_separators = &$config['nat']['separator'];
|
108 |
31bdcffb
|
Steve Beaver
|
$ridx = $_POST['id'];
|
109 |
a4f41878
|
NOYB
|
$mvnrows = -1;
|
110 |
|
|
move_separators($a_separators, $ridx, $mvnrows);
|
111 |
7d8552fc
|
Stephen Beaver
|
|
112 |
3a343d73
|
jim-p
|
if (write_config()) {
|
113 |
|
|
mark_subsystem_dirty('natconf');
|
114 |
37ba954d
|
Phil Davis
|
if ($want_dirty_filter) {
|
115 |
3a343d73
|
jim-p
|
mark_subsystem_dirty('filter');
|
116 |
37ba954d
|
Phil Davis
|
}
|
117 |
3a343d73
|
jim-p
|
}
|
118 |
0e6ac11d
|
Stephen Beaver
|
|
119 |
759d0de1
|
Renato Botelho
|
header("Location: firewall_nat.php");
|
120 |
|
|
exit;
|
121 |
|
|
}
|
122 |
|
|
}
|
123 |
|
|
|
124 |
00bcbdd0
|
Bill Marquette
|
if (isset($_POST['del_x'])) {
|
125 |
84147b7b
|
Steve Beaver
|
|
126 |
0e6ac11d
|
Stephen Beaver
|
/* delete selected rules */
|
127 |
|
|
if (is_array($_POST['rule']) && count($_POST['rule'])) {
|
128 |
7d8552fc
|
Stephen Beaver
|
$a_separators = &$config['nat']['separator'];
|
129 |
4b0815f3
|
Steve Beaver
|
$num_deleted = 0;
|
130 |
7d8552fc
|
Stephen Beaver
|
|
131 |
0e6ac11d
|
Stephen Beaver
|
foreach ($_POST['rule'] as $rulei) {
|
132 |
7d8552fc
|
Stephen Beaver
|
$target = $rule['target'];
|
133 |
|
|
|
134 |
b9e28d57
|
unknown
|
// Check for filter rule associations
|
135 |
6c07db48
|
Phil Davis
|
if (isset($a_nat[$rulei]['associated-rule-id'])) {
|
136 |
9b16b834
|
Ermal Lu?i
|
delete_id($a_nat[$rulei]['associated-rule-id'], $config['filter']['rule']);
|
137 |
b9e28d57
|
unknown
|
mark_subsystem_dirty('filter');
|
138 |
|
|
}
|
139 |
6cb366de
|
Stephen Beaver
|
|
140 |
0e6ac11d
|
Stephen Beaver
|
unset($a_nat[$rulei]);
|
141 |
7d8552fc
|
Stephen Beaver
|
|
142 |
|
|
// Update the separators
|
143 |
4b0815f3
|
Steve Beaver
|
// As rules are deleted, $ridx has to be decremented or separator position will break
|
144 |
|
|
$ridx = $rulei - $num_deleted;
|
145 |
a4f41878
|
NOYB
|
$mvnrows = -1;
|
146 |
|
|
move_separators($a_separators, $ridx, $mvnrows);
|
147 |
4b0815f3
|
Steve Beaver
|
$num_deleted++;
|
148 |
0e6ac11d
|
Stephen Beaver
|
}
|
149 |
6cb366de
|
Stephen Beaver
|
|
150 |
37ba954d
|
Phil Davis
|
if (write_config()) {
|
151 |
3a343d73
|
jim-p
|
mark_subsystem_dirty('natconf');
|
152 |
37ba954d
|
Phil Davis
|
}
|
153 |
6cb366de
|
Stephen Beaver
|
|
154 |
cd567545
|
Phil Davis
|
header("Location: firewall_nat.php");
|
155 |
|
|
exit;
|
156 |
|
|
}
|
157 |
31bdcffb
|
Steve Beaver
|
} else if ($_POST['act'] == "toggle") {
|
158 |
|
|
if ($a_nat[$_POST['id']]) {
|
159 |
|
|
if (isset($a_nat[$_POST['id']]['disabled'])) {
|
160 |
|
|
unset($a_nat[$_POST['id']]['disabled']);
|
161 |
be1bc233
|
Renato Botelho
|
$rule_status = true;
|
162 |
cd567545
|
Phil Davis
|
} else {
|
163 |
31bdcffb
|
Steve Beaver
|
$a_nat[$_POST['id']]['disabled'] = true;
|
164 |
be1bc233
|
Renato Botelho
|
$rule_status = false;
|
165 |
cd567545
|
Phil Davis
|
}
|
166 |
be1bc233
|
Renato Botelho
|
|
167 |
|
|
// Check for filter rule associations
|
168 |
31bdcffb
|
Steve Beaver
|
if (isset($a_nat[$_POST['id']]['associated-rule-id'])) {
|
169 |
|
|
toggle_id($a_nat[$_POST['id']]['associated-rule-id'],
|
170 |
be1bc233
|
Renato Botelho
|
$config['filter']['rule'], $rule_status);
|
171 |
|
|
unset($rule_status);
|
172 |
|
|
mark_subsystem_dirty('filter');
|
173 |
|
|
}
|
174 |
|
|
|
175 |
cd567545
|
Phil Davis
|
if (write_config(gettext("Firewall: NAT: Port forward, enable/disable NAT rule"))) {
|
176 |
|
|
mark_subsystem_dirty('natconf');
|
177 |
|
|
}
|
178 |
3a343d73
|
jim-p
|
header("Location: firewall_nat.php");
|
179 |
|
|
exit;
|
180 |
4b9a670c
|
Scott Ullrich
|
}
|
181 |
0e6ac11d
|
Stephen Beaver
|
}
|
182 |
|
|
|
183 |
6c07db48
|
Phil Davis
|
$pgtitle = array(gettext("Firewall"), gettext("NAT"), gettext("Port Forward"));
|
184 |
edcd7535
|
Phil Davis
|
$pglinks = array("", "@self", "@self");
|
185 |
6eb17647
|
Scott Ullrich
|
include("head.inc");
|
186 |
|
|
|
187 |
44c42356
|
Phil Davis
|
if ($_POST['apply']) {
|
188 |
|
|
print_apply_result_box($retval);
|
189 |
67c2baf1
|
Phil Davis
|
}
|
190 |
0e6ac11d
|
Stephen Beaver
|
|
191 |
67c2baf1
|
Phil Davis
|
if (is_subsystem_dirty('natconf')) {
|
192 |
3b3a95e5
|
Phil Davis
|
print_apply_box(gettext('The NAT configuration has been changed.') . '<br />' .
|
193 |
ee81ff38
|
NOYB
|
gettext('The changes must be applied for them to take effect.'));
|
194 |
67c2baf1
|
Phil Davis
|
}
|
195 |
2a9db752
|
Scott Dale
|
|
196 |
0e6ac11d
|
Stephen Beaver
|
$tab_array = array();
|
197 |
|
|
$tab_array[] = array(gettext("Port Forward"), true, "firewall_nat.php");
|
198 |
|
|
$tab_array[] = array(gettext("1:1"), false, "firewall_nat_1to1.php");
|
199 |
|
|
$tab_array[] = array(gettext("Outbound"), false, "firewall_nat_out.php");
|
200 |
|
|
$tab_array[] = array(gettext("NPt"), false, "firewall_nat_npt.php");
|
201 |
|
|
display_top_tabs($tab_array);
|
202 |
7d8552fc
|
Stephen Beaver
|
|
203 |
|
|
$columns_in_table = 13;
|
204 |
24f600b0
|
Scott Ullrich
|
?>
|
205 |
dd455f50
|
Steve Beaver
|
<!-- Allow table to scroll when dragging outside of the display window -->
|
206 |
|
|
<style>
|
207 |
|
|
.table-responsive {
|
208 |
|
|
clear: both;
|
209 |
|
|
overflow-x: visible;
|
210 |
|
|
margin-bottom: 0px;
|
211 |
|
|
}
|
212 |
|
|
</style>
|
213 |
d16a49ae
|
Colin Fleming
|
|
214 |
00bcbdd0
|
Bill Marquette
|
<form action="firewall_nat.php" method="post" name="iform">
|
215 |
8bbab8a3
|
Stephen Beaver
|
<div class="panel panel-default">
|
216 |
95fa5cce
|
Phil Davis
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('Rules')?></h2></div>
|
217 |
8bbab8a3
|
Stephen Beaver
|
<div class="panel-body table-responsive">
|
218 |
7d8552fc
|
Stephen Beaver
|
<table id="ruletable" class="table table-striped table-hover table-condensed">
|
219 |
8bbab8a3
|
Stephen Beaver
|
<thead>
|
220 |
|
|
<tr>
|
221 |
7c540a5c
|
Stephen Beaver
|
<th><!-- Checkbox --></th>
|
222 |
cd567545
|
Phil Davis
|
<th><!-- Icon --></th>
|
223 |
8bbab8a3
|
Stephen Beaver
|
<th><!-- Rule type --></th>
|
224 |
5b8a7e90
|
NewEraCracker
|
<th><?=gettext("Interface")?></th>
|
225 |
66c62a1a
|
NewEraCracker
|
<th><?=gettext("Protocol")?></th>
|
226 |
a66ce627
|
NewEraCracker
|
<th><?=gettext("Source Address")?></th>
|
227 |
|
|
<th><?=gettext("Source Ports")?></th>
|
228 |
|
|
<th><?=gettext("Dest. Address")?></th>
|
229 |
|
|
<th><?=gettext("Dest. Ports")?></th>
|
230 |
8bbab8a3
|
Stephen Beaver
|
<th><?=gettext("NAT IP")?></th>
|
231 |
|
|
<th><?=gettext("NAT Ports")?></th>
|
232 |
|
|
<th><?=gettext("Description")?></th>
|
233 |
|
|
<th><?=gettext("Actions")?></th>
|
234 |
|
|
</tr>
|
235 |
|
|
</thead>
|
236 |
|
|
<tbody class='user-entries'>
|
237 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
238 |
dbbd22f9
|
Stephen Beaver
|
|
239 |
0e6ac11d
|
Stephen Beaver
|
$nnats = $i = 0;
|
240 |
ccc62f13
|
NOYB
|
$separators = $config['nat']['separator'];
|
241 |
0e6ac11d
|
Stephen Beaver
|
|
242 |
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).
|
243 |
|
|
// More efficient than looping through the list of separators on every row.
|
244 |
|
|
$seprows = separator_rows($separators);
|
245 |
7d8552fc
|
Stephen Beaver
|
|
246 |
0e6ac11d
|
Stephen Beaver
|
foreach ($a_nat as $natent):
|
247 |
|
|
|
248 |
36bf13fd
|
NOYB
|
// Display separator(s) for section beginning at rule n
|
249 |
|
|
if ($seprows[$nnats]) {
|
250 |
|
|
display_separator($separators, $nnats, $columns_in_table);
|
251 |
|
|
}
|
252 |
|
|
|
253 |
474e70a2
|
Stephen Beaver
|
$localport = $natent['local-port'];
|
254 |
|
|
|
255 |
|
|
list($dstbeginport, $dstendport) = explode("-", $natent['destination']['port']);
|
256 |
|
|
|
257 |
|
|
if ($dstendport) {
|
258 |
|
|
$localendport = $natent['local-port'] + $dstendport - $dstbeginport;
|
259 |
|
|
$localport .= '-' . $localendport;
|
260 |
|
|
}
|
261 |
|
|
|
262 |
dbbd22f9
|
Stephen Beaver
|
$alias = rule_columns_with_alias(
|
263 |
|
|
$natent['source']['address'],
|
264 |
|
|
pprint_port($natent['source']['port']),
|
265 |
|
|
$natent['destination']['address'],
|
266 |
474e70a2
|
Stephen Beaver
|
pprint_port($natent['destination']['port']),
|
267 |
|
|
$natent['target'],
|
268 |
|
|
$localport
|
269 |
dbbd22f9
|
Stephen Beaver
|
);
|
270 |
0e6ac11d
|
Stephen Beaver
|
|
271 |
dbbd22f9
|
Stephen Beaver
|
/* if user does not have access to edit an interface skip on to the next record */
|
272 |
67c2baf1
|
Phil Davis
|
if (!have_natpfruleint_access($natent['interface'])) {
|
273 |
dbbd22f9
|
Stephen Beaver
|
continue;
|
274 |
67c2baf1
|
Phil Davis
|
}
|
275 |
cd567545
|
Phil Davis
|
|
276 |
|
|
if (isset($natent['disabled'])) {
|
277 |
|
|
$iconfn = "pass_d";
|
278 |
|
|
$trclass = 'class="disabled"';
|
279 |
|
|
} else {
|
280 |
|
|
$iconfn = "pass";
|
281 |
|
|
$trclass = '';
|
282 |
|
|
}
|
283 |
0e6ac11d
|
Stephen Beaver
|
?>
|
284 |
7c540a5c
|
Stephen Beaver
|
|
285 |
cd567545
|
Phil Davis
|
<tr id="fr<?=$nnats;?>" <?=$trclass?> onClick="fr_toggle(<?=$nnats;?>)" ondblclick="document.location='firewall_nat_edit.php?id=<?=$i;?>';">
|
286 |
7c540a5c
|
Stephen Beaver
|
<td >
|
287 |
|
|
<input type="checkbox" id="frc<?=$nnats;?>" onClick="fr_toggle(<?=$nnats;?>)" name="rule[]" value="<?=$i;?>"/>
|
288 |
|
|
</td>
|
289 |
8bbab8a3
|
Stephen Beaver
|
<td>
|
290 |
31bdcffb
|
Steve Beaver
|
<a href="?act=toggle&id=<?=$i?>" usepost>
|
291 |
cdec7893
|
Steve Beaver
|
<i class="fa fa-check" title="<?=gettext("click to toggle enabled/disabled status")?>"></i>
|
292 |
719635b2
|
jim-p
|
<?php if (isset($natent['nordr'])) { ?>
|
293 |
|
|
<i class="fa fa-hand-stop-o text-danger" title="<?=gettext("Negated: This rule excludes NAT from a later rule")?>"></i>
|
294 |
|
|
<?php } ?>
|
295 |
cd567545
|
Phil Davis
|
</a>
|
296 |
|
|
</td>
|
297 |
|
|
<td>
|
298 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
299 |
e6f34d22
|
Phil Davis
|
if ($natent['associated-rule-id'] == "pass"):
|
300 |
0e6ac11d
|
Stephen Beaver
|
?>
|
301 |
1b7379f9
|
Jared Dillard
|
<i class="fa fa-play" title="<?=gettext("All traffic matching this NAT entry is passed")?>"></i>
|
302 |
a8726a3d
|
Scott Ullrich
|
<?php
|
303 |
dbbd22f9
|
Stephen Beaver
|
elseif (!empty($natent['associated-rule-id'])):
|
304 |
a8726a3d
|
Scott Ullrich
|
?>
|
305 |
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>
|
306 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
307 |
dbbd22f9
|
Stephen Beaver
|
endif;
|
308 |
0e6ac11d
|
Stephen Beaver
|
?>
|
309 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
310 |
91d452c7
|
Stephen Beaver
|
<td>
|
311 |
8bbab8a3
|
Stephen Beaver
|
<?=$textss?>
|
312 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
313 |
67c2baf1
|
Phil Davis
|
if (!$natent['interface']) {
|
314 |
dbbd22f9
|
Stephen Beaver
|
echo htmlspecialchars(convert_friendly_interface_to_friendly_descr("wan"));
|
315 |
67c2baf1
|
Phil Davis
|
} else {
|
316 |
dbbd22f9
|
Stephen Beaver
|
echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface']));
|
317 |
67c2baf1
|
Phil Davis
|
}
|
318 |
0e6ac11d
|
Stephen Beaver
|
?>
|
319 |
8bbab8a3
|
Stephen Beaver
|
<?=$textse?>
|
320 |
|
|
</td>
|
321 |
dbbd22f9
|
Stephen Beaver
|
|
322 |
91d452c7
|
Stephen Beaver
|
<td>
|
323 |
8bbab8a3
|
Stephen Beaver
|
<?=$textss?><?=strtoupper($natent['protocol'])?><?=$textse?>
|
324 |
|
|
</td>
|
325 |
dbbd22f9
|
Stephen Beaver
|
|
326 |
91d452c7
|
Stephen Beaver
|
<td>
|
327 |
dbbd22f9
|
Stephen Beaver
|
|
328 |
|
|
|
329 |
|
|
<?php
|
330 |
|
|
if (isset($alias['src'])):
|
331 |
|
|
?>
|
332 |
84147b7b
|
Steve Beaver
|
<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">
|
333 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
334 |
|
|
endif;
|
335 |
|
|
?>
|
336 |
4b72f68f
|
Steve Beaver
|
<?=str_replace('_', '_<wbr>', htmlspecialchars(pprint_address($natent['source'])))?>
|
337 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
338 |
|
|
if (isset($alias['src'])):
|
339 |
|
|
?>
|
340 |
27cb1f65
|
NOYB
|
</a>
|
341 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
342 |
|
|
endif;
|
343 |
|
|
?>
|
344 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
345 |
91d452c7
|
Stephen Beaver
|
<td>
|
346 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
347 |
|
|
if (isset($alias['srcport'])):
|
348 |
|
|
?>
|
349 |
84147b7b
|
Steve Beaver
|
<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">
|
350 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
351 |
|
|
endif;
|
352 |
|
|
?>
|
353 |
4b72f68f
|
Steve Beaver
|
<?=str_replace('_', '_<wbr>', htmlspecialchars(pprint_port($natent['source']['port'])))?>
|
354 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
355 |
|
|
if (isset($alias['srcport'])):
|
356 |
|
|
?>
|
357 |
27cb1f65
|
NOYB
|
</a>
|
358 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
359 |
|
|
endif;
|
360 |
|
|
?>
|
361 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
362 |
dbbd22f9
|
Stephen Beaver
|
|
363 |
91d452c7
|
Stephen Beaver
|
<td>
|
364 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
365 |
|
|
if (isset($alias['dst'])):
|
366 |
|
|
?>
|
367 |
84147b7b
|
Steve Beaver
|
<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">
|
368 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
369 |
|
|
endif;
|
370 |
|
|
?>
|
371 |
4b72f68f
|
Steve Beaver
|
<?=str_replace('_', '_<wbr>', htmlspecialchars(pprint_address($natent['destination'])))?>
|
372 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
373 |
|
|
if (isset($alias['dst'])):
|
374 |
|
|
?>
|
375 |
14a73423
|
NOYB
|
</a>
|
376 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
377 |
|
|
endif;
|
378 |
|
|
?>
|
379 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
380 |
91d452c7
|
Stephen Beaver
|
<td>
|
381 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
382 |
|
|
if (isset($alias['dstport'])):
|
383 |
|
|
?>
|
384 |
84147b7b
|
Steve Beaver
|
<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">
|
385 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
386 |
|
|
endif;
|
387 |
|
|
?>
|
388 |
4b72f68f
|
Steve Beaver
|
<?=str_replace('_', '_<wbr>', htmlspecialchars(pprint_port($natent['destination']['port'])))?>
|
389 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
390 |
|
|
if (isset($alias['dstport'])):
|
391 |
|
|
?>
|
392 |
14a73423
|
NOYB
|
</a>
|
393 |
dbbd22f9
|
Stephen Beaver
|
<?php
|
394 |
|
|
endif;
|
395 |
|
|
?>
|
396 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
397 |
474e70a2
|
Stephen Beaver
|
<td>
|
398 |
|
|
<?php
|
399 |
|
|
if (isset($alias['target'])):
|
400 |
|
|
?>
|
401 |
84147b7b
|
Steve Beaver
|
<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" >
|
402 |
474e70a2
|
Stephen Beaver
|
<?php
|
403 |
|
|
endif;
|
404 |
|
|
?>
|
405 |
dbbd22f9
|
Stephen Beaver
|
|
406 |
4b72f68f
|
Steve Beaver
|
<?=str_replace('_', '_<wbr>', htmlspecialchars($natent['target']))?>
|
407 |
474e70a2
|
Stephen Beaver
|
<?php
|
408 |
|
|
if (isset($alias['target'])):
|
409 |
|
|
?>
|
410 |
|
|
</a>
|
411 |
|
|
<?php
|
412 |
|
|
endif;
|
413 |
|
|
?>
|
414 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
415 |
91d452c7
|
Stephen Beaver
|
<td>
|
416 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
417 |
474e70a2
|
Stephen Beaver
|
if (isset($alias['targetport'])):
|
418 |
|
|
?>
|
419 |
84147b7b
|
Steve Beaver
|
<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">
|
420 |
474e70a2
|
Stephen Beaver
|
<?php
|
421 |
|
|
endif;
|
422 |
0e6ac11d
|
Stephen Beaver
|
?>
|
423 |
4b72f68f
|
Steve Beaver
|
<?=str_replace('_', '_<wbr>', htmlspecialchars(pprint_port($localport)))?>
|
424 |
474e70a2
|
Stephen Beaver
|
<?php
|
425 |
|
|
if (isset($alias['targetport'])):
|
426 |
|
|
?>
|
427 |
|
|
</a>
|
428 |
|
|
<?php
|
429 |
|
|
endif;
|
430 |
|
|
?>
|
431 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
432 |
dbbd22f9
|
Stephen Beaver
|
|
433 |
91d452c7
|
Stephen Beaver
|
<td>
|
434 |
dbbd22f9
|
Stephen Beaver
|
<?=htmlspecialchars($natent['descr'])?>
|
435 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
436 |
91d452c7
|
Stephen Beaver
|
<td>
|
437 |
84147b7b
|
Steve Beaver
|
<a class="fa fa-pencil" title="<?=gettext("Edit rule"); ?>" href="firewall_nat_edit.php?id=<?=$i?>"></a>
|
438 |
|
|
<a class="fa fa-clone" title="<?=gettext("Add a new NAT based on this one")?>" href="firewall_nat_edit.php?dup=<?=$i?>"></a>
|
439 |
31bdcffb
|
Steve Beaver
|
<a class="fa fa-trash" title="<?=gettext("Delete rule")?>" href="firewall_nat.php?act=del&id=<?=$i?>" usepost></a>
|
440 |
8bbab8a3
|
Stephen Beaver
|
</td>
|
441 |
|
|
</tr>
|
442 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
443 |
|
|
$i++;
|
444 |
|
|
$nnats++;
|
445 |
8f561183
|
NOYB
|
|
446 |
0e6ac11d
|
Stephen Beaver
|
endforeach;
|
447 |
36bf13fd
|
NOYB
|
|
448 |
|
|
// There can be separator(s) after the last rule listed.
|
449 |
|
|
if ($seprows[$nnats]) {
|
450 |
|
|
display_separator($separators, $nnats, $columns_in_table);
|
451 |
|
|
}
|
452 |
0e6ac11d
|
Stephen Beaver
|
?>
|
453 |
8bbab8a3
|
Stephen Beaver
|
</tbody>
|
454 |
|
|
</table>
|
455 |
|
|
</div>
|
456 |
4cf530c4
|
Stephen Beaver
|
</div>
|
457 |
dbbd22f9
|
Stephen Beaver
|
|
458 |
c10cb196
|
Stephen Beaver
|
<nav class="action-buttons">
|
459 |
84147b7b
|
Steve 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')?>">
|
460 |
b807e59c
|
Stephen Beaver
|
<i class="fa fa-level-up icon-embed-btn"></i>
|
461 |
0149ef4d
|
Stephen Beaver
|
<?=gettext('Add')?>
|
462 |
|
|
</a>
|
463 |
84147b7b
|
Steve Beaver
|
<a href="firewall_nat_edit.php" class="btn btn-sm btn-success" title="<?=gettext('Add rule to the end of the list')?>">
|
464 |
b807e59c
|
Stephen Beaver
|
<i class="fa fa-level-down icon-embed-btn"></i>
|
465 |
|
|
<?=gettext('Add')?>
|
466 |
|
|
</a>
|
467 |
|
|
<button name="del_x" type="submit" class="btn btn-danger btn-sm" title="<?=gettext('Delete selected rules')?>">
|
468 |
9d5a20cf
|
heper
|
<i class="fa fa-trash icon-embed-btn"></i>
|
469 |
0149ef4d
|
Stephen Beaver
|
<?=gettext("Delete"); ?>
|
470 |
|
|
</button>
|
471 |
c4b60a9a
|
Colin Fleming
|
<button type="submit" id="order-store" name="order-store" class="btn btn-primary btn-sm" disabled title="<?=gettext('Save rule order')?>">
|
472 |
9d5a20cf
|
heper
|
<i class="fa fa-save icon-embed-btn"></i>
|
473 |
0149ef4d
|
Stephen Beaver
|
<?=gettext("Save")?>
|
474 |
|
|
</button>
|
475 |
7d8552fc
|
Stephen Beaver
|
<button type="submit" id="addsep" name="addsep" class="btn btn-sm btn-warning" title="<?=gettext('Add separator')?>">
|
476 |
|
|
<i class="fa fa-plus icon-embed-btn"></i>
|
477 |
|
|
<?=gettext("Separator")?>
|
478 |
|
|
</button>
|
479 |
09415b9e
|
Stephen Beaver
|
</nav>
|
480 |
0e6ac11d
|
Stephen Beaver
|
</form>
|
481 |
3d335c4d
|
Scott Ullrich
|
|
482 |
8fd9052f
|
Colin Fleming
|
<script type="text/javascript">
|
483 |
|
|
//<![CDATA[
|
484 |
2af731f8
|
NewEraCracker
|
//Need to create some variables here so that jquery/pfSenseHelpers.js can read them
|
485 |
7d8552fc
|
Stephen Beaver
|
iface = "<?=strtolower($if)?>";
|
486 |
|
|
cncltxt = '<?=gettext("Cancel")?>';
|
487 |
|
|
svtxt = '<?=gettext("Save")?>';
|
488 |
|
|
svbtnplaceholder = '<?=gettext("Enter a description, Save, then drag to final location.")?>';
|
489 |
|
|
configsection = "nat";
|
490 |
|
|
dirty = false;
|
491 |
|
|
|
492 |
65a0e193
|
Stephen Beaver
|
events.push(function() {
|
493 |
7c540a5c
|
Stephen Beaver
|
|
494 |
65a0e193
|
Stephen Beaver
|
// Make rules sortable
|
495 |
4cf530c4
|
Stephen Beaver
|
$('table tbody.user-entries').sortable({
|
496 |
|
|
cursor: 'grabbing',
|
497 |
|
|
update: function(event, ui) {
|
498 |
|
|
$('#order-store').removeAttr('disabled');
|
499 |
ae6814a2
|
Phil Davis
|
dirty = true;
|
500 |
7d8552fc
|
Stephen Beaver
|
reindex_rules(ui.item.parent('tbody'));
|
501 |
|
|
dirty = true;
|
502 |
4cf530c4
|
Stephen Beaver
|
}
|
503 |
|
|
});
|
504 |
6cb366de
|
Stephen Beaver
|
|
505 |
|
|
// Check all of the rule checkboxes so that their values are posted
|
506 |
|
|
$('#order-store').click(function () {
|
507 |
|
|
$('[id^=frc]').prop('checked', true);
|
508 |
ae6814a2
|
Phil Davis
|
|
509 |
7d8552fc
|
Stephen Beaver
|
// Save the separator bar configuration
|
510 |
|
|
save_separators();
|
511 |
|
|
|
512 |
ae6814a2
|
Phil Davis
|
// Suppress the "Do you really want to leave the page" message
|
513 |
|
|
saving = true;
|
514 |
7d8552fc
|
Stephen Beaver
|
|
515 |
ae6814a2
|
Phil Davis
|
});
|
516 |
|
|
|
517 |
|
|
// Globals
|
518 |
|
|
saving = false;
|
519 |
|
|
dirty = false;
|
520 |
|
|
|
521 |
|
|
// provide a warning message if the user tries to change page before saving
|
522 |
|
|
$(window).bind('beforeunload', function(){
|
523 |
|
|
if (!saving && dirty) {
|
524 |
ee81ff38
|
NOYB
|
return ("<?=gettext('One or more Port Forward rules have been moved but have not yet been saved')?>");
|
525 |
ae6814a2
|
Phil Davis
|
} else {
|
526 |
|
|
return undefined;
|
527 |
|
|
}
|
528 |
6cb366de
|
Stephen Beaver
|
});
|
529 |
4cf530c4
|
Stephen Beaver
|
});
|
530 |
8fd9052f
|
Colin Fleming
|
//]]>
|
531 |
4cf530c4
|
Stephen Beaver
|
</script>
|
532 |
3d335c4d
|
Scott Ullrich
|
<?php
|
533 |
0e6ac11d
|
Stephen Beaver
|
|
534 |
e6f34d22
|
Phil Davis
|
if (count($a_nat) > 0) {
|
535 |
3d335c4d
|
Scott Ullrich
|
?>
|
536 |
0e6ac11d
|
Stephen Beaver
|
<!-- Legend -->
|
537 |
|
|
<div>
|
538 |
|
|
<dl class="dl-horizontal responsive">
|
539 |
|
|
<dt><?=gettext('Legend')?></dt> <dd></dd>
|
540 |
1b7379f9
|
Jared Dillard
|
<dt><i class="fa fa-play"></i></dt> <dd><?=gettext('Pass')?></dd>
|
541 |
|
|
<dt><i class="fa fa-random"></i></dt> <dd><?=gettext('Linked rule')?></dd>
|
542 |
0e6ac11d
|
Stephen Beaver
|
</dl>
|
543 |
|
|
</div>
|
544 |
3d335c4d
|
Scott Ullrich
|
|
545 |
0e6ac11d
|
Stephen Beaver
|
<?php
|
546 |
|
|
}
|
547 |
|
|
|
548 |
c10cb196
|
Stephen Beaver
|
include("foot.inc");
|