mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-12-26 23:26:47 +01:00
Determine start index of nearby networks more robustly
Resolves #2003: Unless we examine its source code, we don't exactly know if `wpa_cli ... list_networks` always assigns network ids in the order the known networks are listed in the configuration file. Therefore, we should not assume it to be this way and instead, we should make the code capable of handling all scenarios (in-synch as well as async) in a robust way.
This commit is contained in:
@@ -93,13 +93,16 @@ class WiFiManager
|
||||
exec('sed -rn "s/ssid=(.*)\s*$/\1/p" ' . escapeshellarg(RASPI_HOSTAPD_CONFIG), $ap_ssid);
|
||||
$ap_ssid = $ap_ssid[0] ?? '';
|
||||
|
||||
$index = 0;
|
||||
// determine the next index that follows the indexes of the known networks
|
||||
$index = -1;
|
||||
if (!empty($networks)) {
|
||||
$lastnet = end($networks);
|
||||
if (isset($lastnet['index'])) {
|
||||
$index = $lastnet['index'] + 1;
|
||||
foreach ($networks as $network) {
|
||||
if (isset($network['index']) && ($network['index'] > $index)) {
|
||||
$index = $network['index'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$index++;
|
||||
|
||||
$current = [];
|
||||
$commitCurrent = function () use (&$current, &$networks, &$index, $ap_ssid) {
|
||||
|
||||
Reference in New Issue
Block a user