1 |
2f35382a
|
Seth Mos
|
<?php
|
2 |
|
|
/* $Id$ */
|
3 |
|
|
/*
|
4 |
|
|
system_gateway_groups.php
|
5 |
|
|
part of pfSense (http://pfsense.com)
|
6 |
|
|
|
7 |
6216690b
|
smos
|
Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
|
8 |
2f35382a
|
Seth Mos
|
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 |
1d333258
|
Scott Ullrich
|
/*
|
32 |
|
|
pfSense_MODULE: routing
|
33 |
|
|
*/
|
34 |
2f35382a
|
Seth Mos
|
|
35 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
36 |
|
|
##|*IDENT=page-system-gatewaygroups
|
37 |
|
|
##|*NAME=System: Gateway Groups page
|
38 |
|
|
##|*DESCR=Allow access to the 'System: Gateway Groups' page.
|
39 |
|
|
##|*MATCH=system_gateway_groups.php*
|
40 |
|
|
##|-PRIV
|
41 |
|
|
|
42 |
2f35382a
|
Seth Mos
|
require("guiconfig.inc");
|
43 |
7a927e67
|
Scott Ullrich
|
require_once("functions.inc");
|
44 |
|
|
require_once("filter.inc");
|
45 |
|
|
require_once("shaper.inc");
|
46 |
30ca7b7e
|
Phil Davis
|
require_once("openvpn.inc");
|
47 |
2f35382a
|
Seth Mos
|
|
48 |
|
|
if (!is_array($config['gateways']['gateway_group']))
|
49 |
|
|
$config['gateways']['gateway_group'] = array();
|
50 |
|
|
|
51 |
|
|
$a_gateway_groups = &$config['gateways']['gateway_group'];
|
52 |
5ccd9857
|
Seth Mos
|
$a_gateways = &$config['gateways']['gateway_item'];
|
53 |
198afa09
|
Vinicius Coque
|
$changedesc = gettext("Gateway Groups") . ": ";
|
54 |
2f35382a
|
Seth Mos
|
|
55 |
|
|
if ($_POST) {
|
56 |
|
|
|
57 |
|
|
$pconfig = $_POST;
|
58 |
|
|
|
59 |
|
|
if ($_POST['apply']) {
|
60 |
|
|
|
61 |
|
|
$retval = 0;
|
62 |
|
|
|
63 |
|
|
$retval = system_routing_configure();
|
64 |
98aea4c3
|
Ermal
|
send_multiple_events(array("service reload dyndnsall", "service reload ipsecdns", "filter reload"));
|
65 |
|
|
|
66 |
33d72c67
|
Ermal
|
/* reconfigure our gateway monitor */
|
67 |
|
|
setup_gateways_monitor();
|
68 |
2f35382a
|
Seth Mos
|
|
69 |
|
|
$savemsg = get_std_save_message($retval);
|
70 |
a368a026
|
Ermal Lu?i
|
if ($retval == 0)
|
71 |
|
|
clear_subsystem_dirty('staticroutes');
|
72 |
30ca7b7e
|
Phil Davis
|
|
73 |
|
|
foreach ($a_gateway_groups as $gateway_group) {
|
74 |
|
|
$gw_subsystem = 'gwgroup.' . $gateway_group['name'];
|
75 |
|
|
if (is_subsystem_dirty($gw_subsystem)) {
|
76 |
|
|
openvpn_resync_gwgroup($gateway_group['name']);
|
77 |
|
|
clear_subsystem_dirty($gw_subsystem);
|
78 |
|
|
}
|
79 |
|
|
}
|
80 |
2f35382a
|
Seth Mos
|
}
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
if ($_GET['act'] == "del") {
|
84 |
|
|
if ($a_gateway_groups[$_GET['id']]) {
|
85 |
198afa09
|
Vinicius Coque
|
$changedesc .= gettext("removed gateway group") . " {$_GET['id']}";
|
86 |
f78302e8
|
Ermal
|
foreach ($config['filter']['rule'] as $idx => $rule) {
|
87 |
|
|
if ($rule['gateway'] == $a_gateway_groups[$_GET['id']]['name'])
|
88 |
|
|
unset($config['filter']['rule'][$idx]['gateway']);
|
89 |
|
|
}
|
90 |
2f35382a
|
Seth Mos
|
unset($a_gateway_groups[$_GET['id']]);
|
91 |
|
|
write_config($changedesc);
|
92 |
a368a026
|
Ermal Lu?i
|
mark_subsystem_dirty('staticroutes');
|
93 |
2f35382a
|
Seth Mos
|
header("Location: system_gateway_groups.php");
|
94 |
|
|
exit;
|
95 |
|
|
}
|
96 |
|
|
}
|
97 |
|
|
|
98 |
198afa09
|
Vinicius Coque
|
$pgtitle = array(gettext("System"),gettext("Gateway Groups"));
|
99 |
b32dd0a6
|
jim-p
|
$shortcut_section = "gateway-groups";
|
100 |
02ca24c9
|
jim-p
|
|
101 |
2f35382a
|
Seth Mos
|
include("head.inc");
|
102 |
|
|
|
103 |
|
|
?>
|
104 |
|
|
|
105 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
106 |
|
|
<?php include("fbegin.inc"); ?>
|
107 |
5ccd9857
|
Seth Mos
|
<form action="system_gateway_groups.php" method="post">
|
108 |
f488ef5a
|
Colin Fleming
|
<input type="hidden" name="y1" value="1" />
|
109 |
2f35382a
|
Seth Mos
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
110 |
a368a026
|
Ermal Lu?i
|
<?php if (is_subsystem_dirty('staticroutes')): ?><p>
|
111 |
f488ef5a
|
Colin Fleming
|
<?php print_info_box_np(sprintf(gettext("The gateway configuration has been changed.%sYou must apply the changes in order for them to take effect."), "<br/>"));?><br/></p>
|
112 |
2f35382a
|
Seth Mos
|
<?php endif; ?>
|
113 |
f488ef5a
|
Colin Fleming
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="system groups">
|
114 |
2f35382a
|
Seth Mos
|
<tr>
|
115 |
|
|
<td>
|
116 |
|
|
<?php
|
117 |
|
|
$tab_array = array();
|
118 |
198afa09
|
Vinicius Coque
|
$tab_array[0] = array(gettext("Gateways"), false, "system_gateways.php");
|
119 |
|
|
$tab_array[1] = array(gettext("Routes"), false, "system_routes.php");
|
120 |
|
|
$tab_array[2] = array(gettext("Groups"), true, "system_gateway_groups.php");
|
121 |
2f35382a
|
Seth Mos
|
display_top_tabs($tab_array);
|
122 |
|
|
?>
|
123 |
|
|
</td></tr>
|
124 |
|
|
<tr>
|
125 |
|
|
<td>
|
126 |
|
|
<div id="mainarea">
|
127 |
f488ef5a
|
Colin Fleming
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
|
128 |
313827fd
|
jim-p
|
<thead>
|
129 |
2f35382a
|
Seth Mos
|
<tr>
|
130 |
198afa09
|
Vinicius Coque
|
<td width="15%" class="listhdrr"><?=gettext("Group Name");?></td>
|
131 |
|
|
<td width="15%" class="listhdrr"><?=gettext("Gateways");?></td>
|
132 |
|
|
<td width="20%" class="listhdrr"><?=gettext("Priority");?></td>
|
133 |
|
|
<td width="30%" class="listhdr"><?=gettext("Description");?></td>
|
134 |
2f35382a
|
Seth Mos
|
<td width="10%" class="list">
|
135 |
f488ef5a
|
Colin Fleming
|
<table border="0" cellspacing="0" cellpadding="1" summary="icons">
|
136 |
2f35382a
|
Seth Mos
|
<tr>
|
137 |
|
|
<td width="17"></td>
|
138 |
f488ef5a
|
Colin Fleming
|
<td><a href="system_gateway_groups_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="edit" /></a></td>
|
139 |
2f35382a
|
Seth Mos
|
</tr>
|
140 |
|
|
</table>
|
141 |
|
|
</td>
|
142 |
|
|
</tr>
|
143 |
313827fd
|
jim-p
|
</thead>
|
144 |
f488ef5a
|
Colin Fleming
|
<tfoot>
|
145 |
|
|
<tr><td class="list" colspan="4"></td>
|
146 |
|
|
<td class="list">
|
147 |
|
|
<table border="0" cellspacing="0" cellpadding="1" summary="edit">
|
148 |
|
|
<tr>
|
149 |
|
|
<td width="17"></td>
|
150 |
|
|
<td><a href="system_gateway_groups_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="edit" /></a></td>
|
151 |
|
|
</tr>
|
152 |
|
|
</table>
|
153 |
|
|
</td>
|
154 |
|
|
</tr>
|
155 |
|
|
</tfoot>
|
156 |
313827fd
|
jim-p
|
<tbody>
|
157 |
2f35382a
|
Seth Mos
|
<?php $i = 0; foreach ($a_gateway_groups as $gateway_group): ?>
|
158 |
|
|
<tr>
|
159 |
|
|
<td class="listlr" ondblclick="document.location='system_gateway_groups_edit.php?id=<?=$i;?>';">
|
160 |
|
|
<?php
|
161 |
|
|
echo $gateway_group['name'];
|
162 |
8af8524e
|
Ermal
|
?>
|
163 |
2f35382a
|
Seth Mos
|
</td>
|
164 |
|
|
<td class="listr" ondblclick="document.location='system_gateway_groups_edit.php?id=<?=$i;?>';">
|
165 |
|
|
<?php
|
166 |
5ccd9857
|
Seth Mos
|
foreach($gateway_group['item'] as $item) {
|
167 |
|
|
$itemsplit = explode("|", $item);
|
168 |
adc79e41
|
Scott Ullrich
|
echo htmlspecialchars(strtoupper($itemsplit[0])) . "<br/>\n";
|
169 |
5ccd9857
|
Seth Mos
|
}
|
170 |
|
|
?>
|
171 |
2f35382a
|
Seth Mos
|
</td>
|
172 |
|
|
<td class="listr" ondblclick="document.location='system_gateway_groups_edit.php?id=<?=$i;?>';">
|
173 |
|
|
<?php
|
174 |
5ccd9857
|
Seth Mos
|
foreach($gateway_group['item'] as $item) {
|
175 |
|
|
$itemsplit = explode("|", $item);
|
176 |
|
|
echo "Tier ". htmlspecialchars($itemsplit[1]) . "<br/>\n";
|
177 |
|
|
}
|
178 |
|
|
?>
|
179 |
2f35382a
|
Seth Mos
|
</td>
|
180 |
|
|
<td class="listbg" ondblclick="document.location='system_gateway_groups_edit.php?id=<?=$i;?>';">
|
181 |
8af8524e
|
Ermal
|
<?=htmlspecialchars($gateway_group['descr']);?>
|
182 |
2f35382a
|
Seth Mos
|
</td>
|
183 |
f488ef5a
|
Colin Fleming
|
<td valign="middle" class="list nowrap">
|
184 |
|
|
<table border="0" cellspacing="0" cellpadding="1" summary="edit">
|
185 |
2f35382a
|
Seth Mos
|
<tr>
|
186 |
f488ef5a
|
Colin Fleming
|
<td><a href="system_gateway_groups_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="edit" /></a>
|
187 |
|
|
<td><a href="system_gateway_groups.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this gateway group?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="delete" /></a></td>
|
188 |
2f35382a
|
Seth Mos
|
</tr>
|
189 |
|
|
<tr>
|
190 |
|
|
<td width="17"></td>
|
191 |
f488ef5a
|
Colin Fleming
|
<td><a href="system_gateway_groups_edit.php?dup=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="duplicate" /></a></td>
|
192 |
2f35382a
|
Seth Mos
|
</tr>
|
193 |
|
|
</table>
|
194 |
|
|
|
195 |
|
|
</tr>
|
196 |
|
|
<?php $i++; endforeach; ?>
|
197 |
f488ef5a
|
Colin Fleming
|
<tr><td> </td></tr>
|
198 |
313827fd
|
jim-p
|
</tbody>
|
199 |
2f35382a
|
Seth Mos
|
</table>
|
200 |
|
|
</div>
|
201 |
|
|
</td>
|
202 |
|
|
</tr>
|
203 |
|
|
</table>
|
204 |
|
|
</form>
|
205 |
313827fd
|
jim-p
|
<p><b><?=gettext("Note:");?></b> <?=gettext("Remember to use these Gateway Groups in firewall rules in order to enable load balancing, failover, or policy-based routing. Without rules directing traffic into the Gateway Groups, they will not be used.");?></p>
|
206 |
2f35382a
|
Seth Mos
|
<?php include("fend.inc"); ?>
|
207 |
|
|
</body>
|
208 |
|
|
</html>
|