Remote access: accept iodine opt_in_mode in heartbeat and schema.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Anton Afanasyev
2026-06-24 22:57:28 +02:00
committed by Anton Afanasyeu
parent d2602391c3
commit 8d42f818c6
2 changed files with 9 additions and 2 deletions

View File

@@ -0,0 +1,3 @@
-- Add iodine to remote access opt_in_mode (MariaDB).
ALTER TABLE remote_access_devices
MODIFY opt_in_mode ENUM('none','wireguard','rssh','iodine') NOT NULL DEFAULT 'none';

View File

@@ -9,6 +9,7 @@ final class RemoteAccessRepository {
public const OPT_NONE = 'none';
public const OPT_WIREGUARD = 'wireguard';
public const OPT_RSSH = 'rssh';
public const OPT_IODINE = 'iodine';
public const STATUS_PENDING = 'pending';
public const STATUS_ACTIVE = 'active';
@@ -243,9 +244,12 @@ final class RemoteAccessRepository {
if ($c === 'ssh_reverse' || $c === 'rssh') {
return self::OPT_RSSH;
}
if ($c === 'iodine') {
return self::OPT_IODINE;
}
}
$mode = strtolower(trim((string) ($heartbeat['tunnel_mode'] ?? '')));
if (in_array($mode, [self::OPT_WIREGUARD, self::OPT_RSSH, self::OPT_NONE], true)) {
if (in_array($mode, [self::OPT_WIREGUARD, self::OPT_RSSH, self::OPT_IODINE, self::OPT_NONE], true)) {
return $mode;
}
return self::OPT_WIREGUARD;
@@ -614,7 +618,7 @@ final class RemoteAccessRepository {
return ['ok' => false, 'error' => 'device_not_opted_in'];
}
$optIn = (string) ($device['opt_in_mode'] ?? self::OPT_NONE);
if (!in_array($optIn, [self::OPT_WIREGUARD, self::OPT_RSSH], true)) {
if (!in_array($optIn, [self::OPT_WIREGUARD, self::OPT_RSSH, self::OPT_IODINE], true)) {
return ['ok' => false, 'error' => 'device_not_opted_in'];
}
self::closeActiveSessionsForDevice($deviceId, 'superseded');