Revision df58fd46
Added by Ermal LUÇI almost 14 years ago
etc/inc/filter.inc | ||
---|---|---|
456 | 456 |
return $scrubrules; |
457 | 457 |
} |
458 | 458 |
|
459 |
function get_alias_type($name) { |
|
460 |
global $config; |
|
461 |
|
|
462 |
foreach ($config['aliases']['alias'] as $alias) |
|
463 |
if ($name == $alias['name']) |
|
464 |
return $alias['type']; |
|
465 |
return ""; |
|
466 |
} |
|
467 |
|
|
459 | 468 |
function filter_generate_nested_alias($name, $alias, &$aliasnesting, &$aliasaddrnesting) { |
460 | 469 |
global $aliastable, $filterdns; |
461 | 470 |
|
462 | 471 |
$addresses = split(" ", $alias); |
463 | 472 |
$finallist = ""; |
464 | 473 |
$builtlist = ""; |
465 |
$urltable_nesting = ""; |
|
466 | 474 |
$aliasnesting[$name] = $name; |
467 | 475 |
foreach ($addresses as $address) { |
468 | 476 |
if (empty($address)) |
... | ... | |
470 | 478 |
$linelength = strlen($builtlist); |
471 | 479 |
$tmpline = ""; |
472 | 480 |
if(is_alias($address)) { |
473 |
if (alias_get_type($address) == 'urltable') {
|
|
481 |
if (get_alias_type($address) == 'urltable'){
|
|
474 | 482 |
// Feature#1603. For this type of alias we do not need to recursively call filter_generate_nested_alias. Just load IPs from the file. |
475 |
$urltable_netsting = alias_expand_urltable($address); |
|
476 |
if (!empty($urltable_nesting)) { |
|
477 |
$urlfile_as_arr = file($urltable_nesting); |
|
478 |
foreach($urlfile_as_arr as $line) { |
|
483 |
$urlfn = alias_expand_urltable($address); |
|
484 |
if ($file_as_arr=file($urlfn)){ |
|
485 |
foreach($file_as_arr as $line){ |
|
479 | 486 |
$address= rtrim($line); |
480 |
if ((strlen($tmpline) + $linelength) > 4036) { |
|
481 |
$finallist .= "{$tmpline} \\\n"; |
|
482 |
$tmpline = ""; |
|
483 |
} |
|
484 |
$tmpline .= " {$address}"; |
|
487 |
$tmpline .= " $address"; |
|
485 | 488 |
} |
486 | 489 |
} |
487 | 490 |
} |
... | ... | |
494 | 497 |
continue; |
495 | 498 |
} |
496 | 499 |
$aliasaddrnesting[$address] = $address; |
497 |
$tmpline = " {$address}";
|
|
500 |
$tmpline = " $address";
|
|
498 | 501 |
} |
499 | 502 |
if ((strlen($tmpline)+ $linelength) > 4036) { |
500 | 503 |
$finallist .= "{$builtlist} \\\n"; |
etc/inc/util.inc | ||
---|---|---|
886 | 886 |
} |
887 | 887 |
} |
888 | 888 |
} |
889 |
|
|
890 | 889 |
/* check if an alias exists */ |
891 | 890 |
function is_alias($name) { |
892 | 891 |
global $aliastable; |
... | ... | |
894 | 893 |
return isset($aliastable[$name]); |
895 | 894 |
} |
896 | 895 |
|
897 |
function alias_get_type($name) { |
|
898 |
global $config; |
|
899 |
|
|
900 |
if (is_array($config['aliases']['alias'])) { |
|
901 |
foreach ($config['aliases']['alias'] as $alias) { |
|
902 |
if ($name == $alias['name']) |
|
903 |
return $alias['type']; |
|
904 |
} |
|
905 |
} |
|
906 |
|
|
907 |
return ""; |
|
908 |
} |
|
909 |
|
|
910 | 896 |
/* expand a host or network alias, if necessary */ |
911 | 897 |
function alias_expand($name) { |
912 | 898 |
global $aliastable; |
... | ... | |
924 | 910 |
$urltable_prefix = "/var/db/aliastables/"; |
925 | 911 |
$urltable_filename = $urltable_prefix . $name . ".txt"; |
926 | 912 |
|
927 |
if (is_array($config['aliases']['alias'])) { |
|
928 |
foreach ($config['aliases']['alias'] as $alias) { |
|
929 |
if (($alias['type'] == 'urltable') && ($alias['name'] == $name)) { |
|
930 |
if (is_URL($alias["url"]) && file_exists($urltable_filename) && filesize($urltable_filename)) |
|
931 |
return $urltable_filename; |
|
932 |
else if (process_alias_urltable($name, $alias["url"], 0, true)) |
|
933 |
return $urltable_filename; |
|
934 |
} |
|
913 |
foreach ($config['aliases']['alias'] as $alias) { |
|
914 |
if (($alias['type'] == 'urltable') && ($alias['name'] == $name)) { |
|
915 |
if (is_URL($alias["url"]) && file_exists($urltable_filename) && filesize($urltable_filename)) |
|
916 |
return $urltable_filename; |
|
917 |
else if (process_alias_urltable($name, $alias["url"], 0, true)) |
|
918 |
return $urltable_filename; |
|
935 | 919 |
} |
936 | 920 |
} |
937 | 921 |
return null; |
usr/local/www/firewall_aliases_edit.php | ||
---|---|---|
254 | 254 |
if (!alias_same_type($_POST["address{$x}"], $_POST['type'])) |
255 | 255 |
// But alias type network can include alias type urltable. Feature#1603. |
256 | 256 |
if (!($_POST['type'] == 'network' && |
257 |
alias_get_type($_POST["address{$x}"]) == 'urltable'))
|
|
257 |
get_alias_type($_POST["address{$x}"]) == 'urltable'))
|
|
258 | 258 |
$wrongaliases .= " " . $_POST["address{$x}"]; |
259 | 259 |
} else if ($_POST['type'] == "port") { |
260 | 260 |
if (!is_port($_POST["address{$x}"])) |
Also available in: Unified diff
Revert "Feature #1603. Correct nested urltable alias code to be more fullproof to errors and does not break the ruleset on large lists of urltables. Though this needs a revisit to work properly since it breaks urltable alias property of reloading contents."
This reverts commit 3a26fb7f03a0336ed8dd642c46c6e513fca794da.