mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 08:09:41 +00:00
plugins: improve the pattern handling in devices
Always bootstrap (an impossible) pattern to match devices. On the console end try the implied method now.
This commit is contained in:
parent
f81c2e864a
commit
1d8e5fec36
@ -53,8 +53,8 @@ function timeout($timer = 7)
|
||||
|
||||
function is_interface_mismatch($locked = true)
|
||||
{
|
||||
$patterns = ['^impossiblecontrolmatch$'];
|
||||
$mismatch = false;
|
||||
$patterns = [];
|
||||
|
||||
foreach (plugins_devices() as $device) {
|
||||
if (!$device['volatile']) {
|
||||
@ -62,14 +62,14 @@ function is_interface_mismatch($locked = true)
|
||||
}
|
||||
}
|
||||
|
||||
$regex = '/' . implode('|', $patterns) . '/';
|
||||
$regex = count($patterns) ? '/' . implode('|', $patterns) . '/' : null;
|
||||
|
||||
foreach (legacy_config_get_interfaces(['virtual' => false]) as $ifname => $ifcfg) {
|
||||
if ($locked && !empty($ifcfg['lock'])) {
|
||||
/* Do not mismatch if any lock was issued */
|
||||
$mismatch = false;
|
||||
break;
|
||||
} elseif (preg_match($regex, $ifcfg['if'])) {
|
||||
} elseif (!empty($regex) && preg_match($regex, $ifcfg['if'])) {
|
||||
/* Do not check these interfaces */
|
||||
continue;
|
||||
} elseif (does_interface_exist($ifcfg['if']) == false) {
|
||||
|
||||
@ -96,6 +96,7 @@ function plugins_devices()
|
||||
$devices = [];
|
||||
$defaults = [
|
||||
'configurable' => true, /* allow to configure IP connectivity */
|
||||
'pattern' => '^impossiblecontrolmatch$', /* never match by default */
|
||||
'spoofmac' => true, /* allow to change the MAC address */
|
||||
'volatile' => false, /* device known to persist */
|
||||
];
|
||||
@ -109,7 +110,6 @@ function plugins_devices()
|
||||
$func = sprintf('%s_devices', $name);
|
||||
if (function_exists($func)) {
|
||||
foreach ($func() as $work) {
|
||||
/* XXX make sure 'pattern' exists as a prerequisite */
|
||||
foreach ($defaults as $key => $val) {
|
||||
if (!isset($work[$key])) {
|
||||
$work[$key] = $val;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user