mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Actually merge the part that does the real work with FreeBSD groups.
This commit is contained in:
parent
0ec2fdf0ad
commit
42753d259b
@ -560,6 +560,9 @@ function interfaces_configure() {
|
||||
/* bring ip IP aliases */
|
||||
interfaces_ipalias_configure();
|
||||
|
||||
/* configure interface groups */
|
||||
interfaces_group_setup();
|
||||
|
||||
if (!$g['booting']) {
|
||||
/* reconfigure static routes (kernel may have deleted them) */
|
||||
system_routing_configure();
|
||||
@ -1758,6 +1761,33 @@ EOD;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function interfaces_group_setup() {
|
||||
global $config;
|
||||
|
||||
if (!is_array($config['ifgroups']['ifgroupentry']))
|
||||
return;
|
||||
|
||||
foreach ($config['ifgroups']['ifgroupentry'] as $grouppar)
|
||||
interface_group_setup($groupar);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function interface_group_setup($groupname /* The parameter is an array */) {
|
||||
global $config;
|
||||
|
||||
if (!is_array($groupname))
|
||||
return;
|
||||
$members = explode(" ", $groupname['members']);
|
||||
foreach($members as $ifs) {
|
||||
$realif = get_real_interface($ifs);
|
||||
if ($realif)
|
||||
mwexec("/sbin/ifconfig {$realif} group {$groupname['ifname']}");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* XXX: stub for code that references the old functions(mostly packages) */
|
||||
function get_real_wan_interface($interface = "wan") {
|
||||
|
||||
@ -43,9 +43,14 @@ $a_ifgroups = &$config['ifgroups']['ifgroupentry'];
|
||||
|
||||
if ($_GET['act'] == "del") {
|
||||
if ($a_ifgroups[$_GET['id']]) {
|
||||
$members = explode(" ", $a_ifgroups[$_GET[$id]]);
|
||||
foreach ($members as $ifs) {
|
||||
$realif = get_real_interface($ifs);
|
||||
if ($realif)
|
||||
mwexec("/sbin/ifconfig {$realif} -group " . $a_ifgroups[$_GET[$id]]['ifname']);
|
||||
}
|
||||
unset($a_ifgroups[$_GET['id']]);
|
||||
write_config();
|
||||
touch($d_ifgroupsdirty_path);
|
||||
header("Location: interfaces_groups.php");
|
||||
exit;
|
||||
}
|
||||
@ -93,7 +98,7 @@ include("head.inc");
|
||||
</td>
|
||||
<td class="listr" ondblclick="document.location='interfaces_groups_edit.php?id=<?=$i;?>';">
|
||||
<?php
|
||||
$members_arr = array_slice(explode(" ", $ifgroupentry['members']), 0, 10);
|
||||
$members_arr = explode(" ", $ifgroupentry['members']);
|
||||
$iflist = get_configured_interface_with_descr();
|
||||
foreach ($members_arr as $memb)
|
||||
$memberses_arr[] = $iflist[$memb] ? $iflist[$memb] : $memb;
|
||||
@ -113,7 +118,7 @@ include("head.inc");
|
||||
<table border="0" cellspacing="0" cellpadding="1">
|
||||
<tr>
|
||||
<td valign="middle"><a href="interfaces_groups_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" title="edit group"></a></td>
|
||||
<td><a href="interfaces_ifgroups.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this group? All elements that still use it will become invalid (e.g. filter rules)!')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="delete ifgroupentry"></a></td>
|
||||
<td><a href="interfaces_groups.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this group? All elements that still use it will become invalid (e.g. filter rules)!')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="delete ifgroupentry"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
@ -59,9 +59,13 @@ if ($_POST) {
|
||||
unset($input_errors);
|
||||
$pconfig = $_POST;
|
||||
|
||||
foreach ($a_ifgroups as $groupentry)
|
||||
if ($groupentry['ifname'] == $_POST['ifname'])
|
||||
$input_errors[] = "Group name already exists!";
|
||||
if (empty($id)) {
|
||||
foreach ($a_ifgroups as $groupentry)
|
||||
if ($groupentry['ifname'] == $_POST['ifname'])
|
||||
$input_errors[] = "Group name already exists!";
|
||||
}
|
||||
if (preg_match("/([^a-zA-Z])+/", $_POST['ifname'], $match))
|
||||
$input_errors[] = "Only characters in a-z A-Z are allowed as interface name.";
|
||||
|
||||
$ifgroupentry = array();
|
||||
$ifgroupentry['ifname'] = $_POST['ifname'];
|
||||
@ -81,13 +85,25 @@ if ($_POST) {
|
||||
$ifgroupentry['members'] = $members;
|
||||
$ifgroupentry['descr'] = mb_convert_encoding($_POST['descr'],"HTML-ENTITIES","auto");
|
||||
|
||||
if (isset($id) && $a_ifgroups[$id])
|
||||
if (isset($id) && $a_ifgroups[$id]) {
|
||||
$omembers = explode(" ", $a_ifgroups[$id]['members']);
|
||||
$nmembers = explode(" ", $members);
|
||||
$delmembers = array_diff($omembers, $nmembers);
|
||||
if (count($delmembers) > 0) {
|
||||
foreach ($delmembers as $ifs) {
|
||||
$realif = get_real_interface($ifs);
|
||||
if ($realif)
|
||||
mwexec("/sbin/ifconfig {$realif} -group " . $a_ifgroups[$id]['ifname']);
|
||||
}
|
||||
}
|
||||
$a_ifgroups[$id] = $ifgroupentry;
|
||||
else
|
||||
} else
|
||||
$a_ifgroups[] = $ifgroupentry;
|
||||
|
||||
write_config();
|
||||
|
||||
interface_group_setup($ifgroupentry);
|
||||
|
||||
header("Location: interfaces_groups.php");
|
||||
exit;
|
||||
} else {
|
||||
@ -186,6 +202,8 @@ function removeRow(el) {
|
||||
<td valign="top" class="vncellreq">Interface</td>
|
||||
<td class="vtable">
|
||||
<input class="formfld unknown" name="ifname" id="ifname" value="<?=$pconfig['ifname'];?>" />
|
||||
<br />
|
||||
No numbers or spaces are allowed. Only characters in a-zA-Z
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user