From 7a873d6f83ce3d0fdd846d436221c38d2ff98c83 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 5 Mar 2021 15:52:12 +0100 Subject: [remoteaccess] Allow changing client-side VNC port References #3823 --- modules-available/remoteaccess/api.inc.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'modules-available/remoteaccess/api.inc.php') diff --git a/modules-available/remoteaccess/api.inc.php b/modules-available/remoteaccess/api.inc.php index 2e1e4bf9..4ce733b3 100644 --- a/modules-available/remoteaccess/api.inc.php +++ b/modules-available/remoteaccess/api.inc.php @@ -7,9 +7,12 @@ $password = Request::post('password', false, 'string'); if ($password !== false) { $c = Database::queryFirst("SELECT machineuuid FROM machine WHERE clientip = :ip", ['ip' => $ip]); if ($c !== false) { - Database::exec("INSERT INTO remoteaccess_machine (machineuuid, password) - VALUES (:uuid, :passwd) - ON DUPLICATE KEY UPDATE password = VALUES(password)", ['uuid' => $c['machineuuid'], 'passwd' => $password]); + $vncport = Request::post('vncport', 5900, 'int'); + Database::exec("INSERT INTO remoteaccess_machine (machineuuid, password, vncport) + VALUES (:uuid, :passwd, :vncport) + ON DUPLICATE KEY UPDATE + password = VALUES(password), vncport = VALUES(vncport)", + ['uuid' => $c['machineuuid'], 'passwd' => $password, 'vncport' => $vncport]); } exit; } @@ -35,7 +38,7 @@ if (empty($remoteLocations)) { } else { // TODO fail-counter for WOL, so we can ignore machines that apparently can't be woken up // -> Reset counter in our ~poweron hook, but only if the time roughly matches a WOL attempt (within ~5 minutes) - $rows = Database::queryAll("SELECT m.clientip, m.locationid, m.state, ram.password, ram.woltime FROM machine m + $rows = Database::queryAll("SELECT m.clientip, m.locationid, m.state, ram.password, ram.vncport, ram.woltime FROM machine m LEFT JOIN remoteaccess_machine ram ON (ram.machineuuid = m.machineuuid AND (ram.password IS NOT NULL OR m.state <> 'IDLE')) LEFT JOIN runmode r ON (r.machineuuid = m.machineuuid) WHERE m.locationid IN (:locs) @@ -48,6 +51,7 @@ if (empty($remoteLocations)) { $row['wol_in_progress'] = true; } settype($row['locationid'], 'int'); + settype($row['vncport'], 'int'); unset($row['woltime']); } } -- cgit v1.2.3-55-g7522