Révision 4665dbdd
Ajouté par Renato Botelho il y a plus de 9 ans
etc/inc/pfsense-utils.inc | ||
---|---|---|
2510 | 2510 |
* is_ipaddr_configured |
2511 | 2511 |
* INPUTS |
2512 | 2512 |
* IP Address to check. |
2513 |
* If ignore_if is a VIP (not carp), vip array index is passed after string _virtualip |
|
2513 | 2514 |
* RESULT |
2514 | 2515 |
* returns true if the IP Address is |
2515 | 2516 |
* configured and present on this device. |
... | ... | |
2517 | 2518 |
function is_ipaddr_configured($ipaddr, $ignore_if = "", $check_localip = false, $check_subnets = false) { |
2518 | 2519 |
global $config; |
2519 | 2520 |
|
2521 |
$pos = strpos($ignore_if, '_virtualip'); |
|
2522 |
if ($pos !== false) { |
|
2523 |
$ignore_vip_id = substr($ignore_if, $pos+10); |
|
2524 |
$ignore_vip_if = substr($ignore_if, 0, $pos); |
|
2525 |
} else { |
|
2526 |
$ignore_vip_id = -1; |
|
2527 |
$ignore_vip_if = $ignore_if; |
|
2528 |
} |
|
2529 |
|
|
2520 | 2530 |
$isipv6 = is_ipaddrv6($ipaddr); |
2521 | 2531 |
|
2522 | 2532 |
if ($check_subnets) { |
... | ... | |
2543 | 2553 |
$interface_list_ips = get_configured_ip_addresses(); |
2544 | 2554 |
|
2545 | 2555 |
foreach($interface_list_ips as $if => $ilips) { |
2546 |
/* Also ignore CARP interfaces, it'll be checked below */ |
|
2547 |
if ($ignore_if == $if || strstr($ignore_if, "_vip")) |
|
2556 |
if ($ignore_if == $if) |
|
2548 | 2557 |
continue; |
2549 | 2558 |
if (strcasecmp($ipaddr, $ilips) == 0) |
2550 | 2559 |
return true; |
... | ... | |
2553 | 2562 |
|
2554 | 2563 |
$interface_list_vips = get_configured_vips_list(true); |
2555 | 2564 |
foreach ($interface_list_vips as $id => $vip) { |
2556 |
if ($ignore_if == $vip['if']) |
|
2565 |
/* Skip CARP interfaces here since they were already checked above */ |
|
2566 |
if ($id == $ignore_vip_id || (strstr($ignore_if, '_vip') && $ignore_vip_if == $vip['if'])) |
|
2557 | 2567 |
continue; |
2558 | 2568 |
if (strcasecmp($ipaddr, $vip['ipaddr']) == 0) |
2559 | 2569 |
return true; |
Formats disponibles : Unified diff
Make proper check if IP address is configured on another interfaces and ignore current one. It fixes #3807