Commit 964786b3 authored by Franco Fichtner's avatar Franco Fichtner

filter: one of the largest offenders converted :)

parent 8fea4d96
...@@ -1664,8 +1664,8 @@ function filter_nat_rules_generate(&$FilterIflist) ...@@ -1664,8 +1664,8 @@ function filter_nat_rules_generate(&$FilterIflist)
if (!isset($FilterIflist[$natif])) { if (!isset($FilterIflist[$natif])) {
continue; continue;
} }
$srcaddr = filter_generate_address($rule, 'source'); $srcaddr = filter_generate_address($FilterIflist, $rule, 'source');
$dstaddr = filter_generate_address($rule, 'destination'); $dstaddr = filter_generate_address($FilterIflist, $rule, 'destination');
if(!$dstaddr) { if(!$dstaddr) {
$dstaddr = $FilterIflist[$natif]['ip']; $dstaddr = $FilterIflist[$natif]['ip'];
} }
...@@ -1719,8 +1719,8 @@ function filter_nat_rules_generate(&$FilterIflist) ...@@ -1719,8 +1719,8 @@ function filter_nat_rules_generate(&$FilterIflist)
if (!isset($FilterIflist[$natif])) { if (!isset($FilterIflist[$natif])) {
continue; continue;
} }
$srcaddr = filter_generate_address($rule, 'source'); $srcaddr = filter_generate_address($FilterIflist, $rule, 'source');
$dstaddr = filter_generate_address($rule, 'destination'); $dstaddr = filter_generate_address($FilterIflist, $rule, 'destination');
$srcaddr = trim($srcaddr); $srcaddr = trim($srcaddr);
$dstaddr = trim($dstaddr); $dstaddr = trim($dstaddr);
...@@ -1999,8 +1999,8 @@ function filter_nat_rules_generate(&$FilterIflist) ...@@ -1999,8 +1999,8 @@ function filter_nat_rules_generate(&$FilterIflist)
if (!isset($FilterIflist[$natif])) { if (!isset($FilterIflist[$natif])) {
continue; continue;
} }
$srcaddr = filter_generate_address($rule, 'source', true); $srcaddr = filter_generate_address($FilterIflist, $rule, 'source', true);
$dstaddr = filter_generate_address($rule, 'destination', true); $dstaddr = filter_generate_address($FilterIflist, $rule, 'destination', true);
$srcaddr = trim($srcaddr); $srcaddr = trim($srcaddr);
$dstaddr = trim($dstaddr); $dstaddr = trim($dstaddr);
...@@ -2229,10 +2229,11 @@ function filter_address_add_vips_subnets(&$subnets, $if, $not) { ...@@ -2229,10 +2229,11 @@ function filter_address_add_vips_subnets(&$subnets, $if, $not) {
} }
} }
function filter_generate_address(& $rule, $target = "source", $isnat = false) { function filter_generate_address(&$FilterIflist, &$rule, $target = 'source', $isnat = false)
{
global $config; global $config;
$FilterIflist = filter_generate_optcfg_array() ;
$src = ""; $src = '';
if(isset($rule[$target]['any'])) { if(isset($rule[$target]['any'])) {
$src = "any"; $src = "any";
...@@ -2558,7 +2559,7 @@ function filter_generate_user_rule(&$FilterIflist, $rule) ...@@ -2558,7 +2559,7 @@ function filter_generate_user_rule(&$FilterIflist, $rule)
update_filter_reload_status(sprintf(gettext("Creating rule %s"), $rule['descr'])); update_filter_reload_status(sprintf(gettext("Creating rule %s"), $rule['descr']));
/* source address */ /* source address */
$src = trim(filter_generate_address($rule, "source")); $src = trim(filter_generate_address($FilterIflist, $rule, "source"));
if (empty($src) || ($src == "/")) { if (empty($src) || ($src == "/")) {
return "# at the break!"; return "# at the break!";
} }
...@@ -2570,7 +2571,7 @@ function filter_generate_user_rule(&$FilterIflist, $rule) ...@@ -2570,7 +2571,7 @@ function filter_generate_user_rule(&$FilterIflist, $rule)
} }
/* destination address */ /* destination address */
$dst = trim(filter_generate_address($rule, "destination")); $dst = trim(filter_generate_address($FilterIflist, $rule, "destination"));
if (empty($dst) || ($dst == "/")) { if (empty($dst) || ($dst == "/")) {
return "# returning at dst $dst == \"/\""; return "# returning at dst $dst == \"/\"";
} }
......
...@@ -869,7 +869,7 @@ function openvpn_client_export_find_port_forwards($targetip, $targetport, $targe ...@@ -869,7 +869,7 @@ function openvpn_client_export_find_port_forwards($targetip, $targetport, $targe
continue; // Skip if there is no interface continue; // Skip if there is no interface
} }
$dstaddr = trim(filter_generate_address($natent, 'destination', true)); $dstaddr = trim(filter_generate_address($FilterIflist, $natent, 'destination', true));
if (!$dstaddr) { if (!$dstaddr) {
$dstaddr = $FilterIflist[$natif]['ip']; $dstaddr = $FilterIflist[$natif]['ip'];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment