Project

General

Profile

Feature #4881 » 54.diff

Viktor Gurov, 11/01/2021 05:45 AM

View differences:

src/etc/inc/filter.inc
if (isset($rule['disabled'])) {
continue;
}
$rule['ipprotocol'] = 'inet6';
if (!$rule['interface']) {
$natif = "wan";
src/usr/local/pfSense/include/www/firewall_nat_npt.inc
$reqdfieldsn = array(gettext("Interface"));
$reqdfields[] = "src";
$reqdfieldsn[] = gettext("Source prefix");
$reqdfields[] = "dst";
$reqdfieldsn[] = gettext("Destination prefix");
if (!is_specialnet($post['dsttype'])) {
$reqdfields[] = "dst";
$reqdfieldsn[] = gettext("Destination prefix");
}
if (!$json) {
do_input_validation($post, $reqdfields, $reqdfieldsn, $input_errors);
......
if (!is_ipaddrv6(trim($post['src']))) {
$input_errors[] = gettext("The specified source address is not a valid IPv6 prefix");
}
if (!is_ipaddrv6(trim($post['dst']))) {
if (!is_ipaddrv6(trim($post['dst'])) && !is_specialnet(trim($post['dsttype']))) {
$input_errors[] = gettext("The specified destination address is not a valid IPv6 prefix");
}
if (check_subnetsv6_overlap(get_interface_ipv6($post['interface']), 128, trim($post['dst']), $post['dstmask']) &&
!$post['dstnot']) {
$input_errors[] = gettext("The specified destination address and interface IPv6 address cannot overlap");
}
if (is_specialnet($post['dsttype'])) {
$track6ip = get_interface_track6ip($post['dsttype']);
$post['dstmask'] = $track6ip[1];
}
if (!empty($post['dstmask']) && ($post['srcmask'] != $post['dstmask'])) {
$input_errors[] = gettext("The specified source prefix size must be equal to the destination prefix size.");
}
if (!$input_errors) {
$natent = array();
......
if ($post['src']) {
$post['src'] = trim($post['src']);
}
if ($post['dst']) {
if (is_specialnet($post['dsttype'])) {
$post['dst'] = $post['dsttype'];
$post['dstmask'] = 0;
} elseif ($post['dst']) {
$post['dst'] = trim($post['dst']);
}
......
return $retval;
}
?>
?>
src/usr/local/www/firewall_nat_npt.php
</td>
<td>
<?php
echo $textss . pprint_address($natent['destination']) . $textse;
if (is_array($config['interfaces'][$natent['destination']['network']]) &&
($config['interfaces'][$natent['destination']['network']]['ipaddrv6'] == 'track6')) {
$track6ip = get_interface_track6ip($natent['destination']['network']);
$pdsubnet = gen_subnetv6($track6ip[0], $track6ip[1]);
$dst = "{$config['interfaces'][$natent['destination']['network']]['descr']} ({$pdsubnet}/{$track6ip[1]})";
} else {
$dst = pprint_address($natent['destination']);
}
echo $textss . $dst . $textse;
?>
</td>
<td>
src/usr/local/www/firewall_nat_npt_edit.php
$pglinks = array("", "firewall_nat.php", "firewall_nat_npt.php", "@self");
include("head.inc");
function dsttype_selected() {
global $pconfig;
if ($pconfig['dsttype']) {
// The rule type came from the $_POST array, after input errors, so keep it.
return $pconfig['dsttype'];
}
$sel = is_specialnet($pconfig['dst']);
if (!$sel) {
return('network');
}
return($pconfig['dst']);
}
function build_dsttype_list() {
global $pconfig, $config;
$sel = is_specialnet($pconfig['dst']);
$list = array('network' => gettext('Prefix'));
foreach (get_configured_interface_with_descr() as $if => $ifdesc) {
if (($config['interfaces'][$if]['ipaddrv6'] == 'track6') &&
get_interface_track6ip($if)) {
$track6ip = get_interface_track6ip($if);
$pdsubnet = gen_subnetv6($track6ip[0], $track6ip[1]);
$sntext .= " ({$pdsubnet}/{$track6ip[1]})";
$list[$if] = $ifdesc . $sntext;
}
}
return($list);
}
if ($input_errors) {
print_input_errors($input_errors);
}
......
))->setHelp('Choose which interface this rule applies to.%s' .
'Hint: Typically the "WAN" is used here.', '<br />');
$section->addInput(new Form_Checkbox(
$group = new Form_Group('*Source IPv6 prefix');
$group->add(new Form_Checkbox(
'srcnot',
'Internal IPv6 prefix',
'Not',
$pconfig['srcnot']
))->setHelp('Use this option to invert the sense of the match. ');
))->setHelp('Invert the sense of the match.')->setWidth(2);
$group->add(new Form_StaticText(
null,
null
))->setWidth(3);
$section->addInput(new Form_IpAddress(
$group->add(new Form_IpAddress(
'src',
'*Address',
'*Source prefix',
$pconfig['src'],
'V6'
))->addMask('srcmask', $pconfig['srcmask'])->setHelp('Internal (LAN) ULA IPv6 Prefix for the Network Prefix translation. ' .
'The prefix size specified for the internal IPv6 prefix will be applied to the external prefix.');
))->addMask('srcmask', $pconfig['srcmask'], 128, 1, false);
$section->addInput(new Form_Checkbox(
$group->setHelp('Internal (LAN) ULA IPv6 Prefix for the Network Prefix translation. ' .
'The prefix size specified for the internal IPv6 prefix will be applied to the external prefix.');
$section->add($group);
$group = new Form_Group('*Destination IPv6 prefix');
$group->add(new Form_Checkbox(
'dstnot',
'Destination IPv6 prefix',
null,
'Not',
$pconfig['dstnot']
))->setHelp('Use this option to invert the sense of the match. ');
))->setHelp('Invert the sense of the match.')->setWidth(2);
$section->addInput(new Form_IpAddress(
$group->add(new Form_Select(
'dsttype',
null,
dsttype_selected(),
build_dsttype_list()
))->setHelp('Type')->setWidth(3);
$group->add(new Form_IpAddress(
'dst',
'*Address',
'*Destination prefix',
$pconfig['dst'],
'V6'
))->addMask('dstmask', $pconfig['dstmask'])->setHelp('Global Unicast routable IPv6 prefix');
))->addMask('dstmask', $pconfig['dstmask'], 128, 1, false);
$group->setHelp('Global Unicast routable IPv6 prefix');
$section->add($group);
$section->addInput(new Form_Input(
'descr',
......
$form->add($section);
print($form);
?>
<script type="text/javascript">
//<![CDATA[
events.push(function() {
function typesel_change() {
switch ($('#dsttype').find(":selected").index()) {
case 0: // prefix
disableInput('dst', false);
disableInput('dstmask', false);
break;
default:
$('#dst').val('');
disableInput('dst', true);
$('#dstmask').val('');
disableInput('dstmask', true);
break;
}
}
// ---------- Click checkbox handlers ---------------------------------------------------------
$('#dsttype').change(function () {
typesel_change();
});
// ---------- On initial page load ------------------------------------------------------------
typesel_change();
});
//]]>
</script>
include("foot.inc");
<?php include("foot.inc");
(1-1/3)