diff options
-rw-r--r-- | localwebsite/classes/MyOpenWrtUtils.php | 2 | ||||
-rw-r--r-- | localwebsite/config.php | 4 | ||||
-rw-r--r-- | localwebsite/handlers/ModemHandler.php | 5 |
3 files changed, 9 insertions, 2 deletions
diff --git a/localwebsite/classes/MyOpenWrtUtils.php b/localwebsite/classes/MyOpenWrtUtils.php index 6b70dbc..f83800a 100644 --- a/localwebsite/classes/MyOpenWrtUtils.php +++ b/localwebsite/classes/MyOpenWrtUtils.php @@ -119,7 +119,7 @@ class MyOpenWrtUtils { $ip = array_shift($words); array_pop($words); $hostname = trim(implode(' ', $words)); - if (!$hostname) + if (!$hostname || $hostname == '*') $hostname = '?'; return [ 'time' => $time, diff --git a/localwebsite/config.php b/localwebsite/config.php index 10bbcb7..8ad472c 100644 --- a/localwebsite/config.php +++ b/localwebsite/config.php @@ -81,5 +81,7 @@ return [ 'auth_pw_salt' => '', 'grafana_sensors_url' => '', - 'grafana_inverter_url' => '' + 'grafana_inverter_url' => '', + + 'dhcp_hostname_overrides' => [], ]; diff --git a/localwebsite/handlers/ModemHandler.php b/localwebsite/handlers/ModemHandler.php index aca69a3..b54b82c 100644 --- a/localwebsite/handlers/ModemHandler.php +++ b/localwebsite/handlers/ModemHandler.php @@ -146,7 +146,12 @@ class ModemHandler extends RequestHandler } public function GET_routing_dhcp_page() { + $overrides = config::get('dhcp_hostname_overrides'); $leases = MyOpenWrtUtils::getDHCPLeases(); + foreach ($leases as &$lease) { + if ($lease['hostname'] == '?' && array_key_exists($lease['mac'], $overrides)) + $lease['hostname'] = $overrides[$lease['mac']]; + } $this->tpl->set([ 'leases' => $leases ]); |