mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Ensure IP addresses w/o MAC addresses are also shown and that already added clients are hidden.
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -32,12 +32,12 @@ function reload_client_suggestions() {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add MAC address
|
||||
var text = key.toUpperCase();
|
||||
|
||||
// Check if this is a valid MAC address (skip mock devices)
|
||||
if (!utils.validateMAC(text)) {
|
||||
continue;
|
||||
var text = key,
|
||||
key_plain = key;
|
||||
if (key.startsWith("IP-")) {
|
||||
// Mock MAC address for address-only devices
|
||||
key_plain = key.substring(3);
|
||||
text = key_plain;
|
||||
}
|
||||
|
||||
// Append host name if available
|
||||
@@ -45,7 +45,7 @@ function reload_client_suggestions() {
|
||||
text += " (" + data[key] + ")";
|
||||
}
|
||||
|
||||
sel.append($("<option />").val(key).text(text));
|
||||
sel.append($("<option />").val(key_plain).text(text));
|
||||
}
|
||||
},
|
||||
"json"
|
||||
|
||||
@@ -216,7 +216,7 @@ if ($_POST['action'] == 'get_groups') {
|
||||
// Loop over results
|
||||
$ips = array();
|
||||
while ($res = $query->fetchArray(SQLITE3_ASSOC)) {
|
||||
$ips[$res['hwaddr']] = $res['name'] !== null ? $res['name'] : '';
|
||||
$ips[strtoupper($res['hwaddr'])] = $res['name'] !== null ? $res['name'] : '';
|
||||
}
|
||||
$FTLdb->close();
|
||||
|
||||
@@ -227,8 +227,11 @@ if ($_POST['action'] == 'get_groups') {
|
||||
|
||||
// Loop over results, remove already configured clients
|
||||
while (($res = $query->fetchArray(SQLITE3_ASSOC)) !== false) {
|
||||
if (isset($ips[$res['hwaddr']])) {
|
||||
unset($ips[$res['hwaddr']]);
|
||||
if (isset($ips[$res['ip']])) {
|
||||
unset($ips[$res['ip']]);
|
||||
}
|
||||
if (isset($ips["IP-".$res['ip']])) {
|
||||
unset($ips["IP-".$res['ip']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user