Revision b37f3f5d
Added by Reid Linnemann over 2 years ago
src/etc/inc/captiveportal.inc | ||
---|---|---|
2577 | 2577 |
|
2578 | 2578 |
function filter_captiveportal_tables() { |
2579 | 2579 |
/* return pf rules which defines tables used in captive portal zones */ |
2580 |
global $g, $config, $FilterIflist;
|
|
2580 |
global $config, $FilterIflist; |
|
2581 | 2581 |
|
2582 | 2582 |
$rules = ''; |
2583 | 2583 |
init_config_arr(array('captiveportal')); |
... | ... | |
2588 | 2588 |
|
2589 | 2589 |
$cpzoneprefix = CPPREFIX . $config['captiveportal'][$cpzone]['zoneid']; |
2590 | 2590 |
$cpips = $cpzoneprefix . '_cpips'; |
2591 |
$hosttable = $cpzoneprefix . '_host_'; |
|
2592 |
$cpiplist = ''; |
|
2591 |
$cpiplist = array(); |
|
2593 | 2592 |
|
2594 | 2593 |
foreach (explode(",", $cpcfg['interface']) as $cpifgrp) { |
2595 | 2594 |
if (isset($FilterIflist[$cpifgrp])) { |
... | ... | |
2597 | 2596 |
if (!empty($realif)) { |
2598 | 2597 |
$cpip = get_interface_ip($cpifgrp); |
2599 | 2598 |
if (is_ipaddrv4($cpip)) { |
2600 |
$cpiplist = $cpip . ' '; |
|
2601 |
$cpiplist .= get_interface_vip_ips($cpifgrp); |
|
2599 |
$cpipliststring = $cpip . ' ' . get_interface_vip_ips($cpifgrp); |
|
2600 |
$cpiplist = array_filter(array_merge($cpiplist, explode(' ', $cpipliststring)), |
|
2601 |
function ($val) { |
|
2602 |
return (trim($val) != ""); |
|
2603 |
}); |
|
2602 | 2604 |
} |
2603 | 2605 |
} |
2604 | 2606 |
} |
2605 | 2607 |
} |
2606 | 2608 |
if (!empty($cpiplist)) { |
2607 | 2609 |
/* captive portal web server IP addresses */ |
2608 |
$rules .= "table <{$cpips}> { {$cpiplist} }\n";
|
|
2610 |
$rules .= "table <{$cpips}> { " . join(' ', $cpiplist) . "}\n";
|
|
2609 | 2611 |
} |
2610 | 2612 |
} |
2611 | 2613 |
|
Also available in: Unified diff
Include all interface IPs and VIPs in cpip table. #13391
The cpzoneid_<zone>_cpips tables only include the IP and VIPS of the final
interface searched, causing captive portal zone associated with multiple
interfaces to work improperly.
The revision prior to this erroneously reassigned $cpiplist at each iteration
over the interface list rather than appending it. It also had no sanitizing to
keep out additional whitespace. This commit rectifies the situation by building
$cpiplist as an array, iterating each interface and merging the space separated
list of IP and VIP addresses for that interface which is filtered for empty
string values. This array is then rejoined into a space separated list for
output into the table definition.