device matching via mac instead of ip address
This commit is contained in:
@@ -218,6 +218,69 @@ class RadiusController extends mfBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
protected function genieacsGetDeviceByMacAction() {
|
||||
try {
|
||||
$mac = $_GET['mac'] ?? null;
|
||||
$this->log->debug("genieacsGetDeviceByMacAction", ['mac' => $mac]);
|
||||
if (!$mac) self::sendError("MAC address is required");
|
||||
|
||||
$acs = $this->getGenieACS();
|
||||
$matchedDevice = $acs->getDeviceByMac($mac);
|
||||
|
||||
if (!$matchedDevice) {
|
||||
self::returnJson(['success' => false, 'message' => 'No device found with this MAC address']);
|
||||
return;
|
||||
}
|
||||
|
||||
self::returnJson([
|
||||
'success' => true,
|
||||
'deviceId' => GenieACS::getDeviceId($matchedDevice),
|
||||
'deviceInfo' => GenieACS::getDeviceInfo($matchedDevice),
|
||||
'mac' => $mac,
|
||||
'externalIp' => GenieACS::getExternalIP($matchedDevice),
|
||||
'managementIp' => GenieACS::getManagementIP($matchedDevice)
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
$this->log->debug("GetDeviceByMac Error", ['error' => $e->getMessage()]);
|
||||
self::sendError("Error fetching device: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected function genieacsRefreshDeviceAction() {
|
||||
try {
|
||||
$input = json_decode(file_get_contents('php://input'), true);
|
||||
$deviceId = $input['deviceId'] ?? null;
|
||||
$this->log->debug("genieacsRefreshDeviceAction", ['deviceId' => $deviceId]);
|
||||
|
||||
if (!$deviceId) self::sendError("Device ID is required");
|
||||
|
||||
$acs = $this->getGenieACS();
|
||||
$acs->getParameterValues($deviceId, [
|
||||
'InternetGatewayDevice.DeviceInfo.HardwareVersion',
|
||||
'InternetGatewayDevice.DeviceInfo.SoftwareVersion',
|
||||
'InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANIPConnection.*.MACAddress',
|
||||
'InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANIPConnection.*.ExternalIPAddress',
|
||||
'InternetGatewayDevice.LANDevice.*.WLANConfiguration.*.SSID',
|
||||
'InternetGatewayDevice.LANDevice.*.WLANConfiguration.*.KeyPassphrase',
|
||||
'InternetGatewayDevice.LANDevice.*.Hosts.Host.*.HostName',
|
||||
'InternetGatewayDevice.LANDevice.*.Hosts.Host.*.IPAddress',
|
||||
'InternetGatewayDevice.LANDevice.*.Hosts.Host.*.MACAddress'
|
||||
]);
|
||||
|
||||
$device = $acs->getDevice($deviceId);
|
||||
|
||||
self::returnJson([
|
||||
'success' => true,
|
||||
'deviceInfo' => GenieACS::getDeviceInfo($device),
|
||||
'externalIp' => GenieACS::getExternalIP($device),
|
||||
'managementIp' => GenieACS::getManagementIP($device)
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
$this->log->debug("RefreshDevice Error", ['error' => $e->getMessage()]);
|
||||
self::sendError("Error refreshing device: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected function genieacsRebootDeviceAction() {
|
||||
try {
|
||||
$input = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
Reference in New Issue
Block a user