From e1e3ea7eb68cc6840f67a8aec937fd3740e75b28 Mon Sep 17 00:00:00 2001 From: Pujit Mehrotra Date: Thu, 18 Dec 2025 10:34:06 -0500 Subject: [PATCH] fix: update myservers config references to connect config references (#1810) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `myservers.cfg` no longer gets written to or read (except for migration purposes), so it'd be better to read from the new values instead of continuing to use the old ones @elibosley @Squidly271 . unless i'm missing something! see #1805 ## Summary by CodeRabbit * **New Features** * Switches to a centralized remote-access configuration with a legacy fallback and richer client-side handling. * Optional GraphQL submission path for applying remote settings when available. * **Bug Fixes** * Normalized boolean and port handling to prevent incorrect values reaching the UI. * Improved error handling and UI state restoration during save/apply flows. ✏️ Tip: You can customize this high-level summary in your review settings. --- .../plugins/dynamix.my.servers/Connect.page | 122 +++++++++++++++--- 1 file changed, 104 insertions(+), 18 deletions(-) diff --git a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/Connect.page b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/Connect.page index c7f84fd10..26311afb9 100644 --- a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/Connect.page +++ b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/Connect.page @@ -15,12 +15,29 @@ Tag="globe" */ require_once "$docroot/plugins/dynamix.my.servers/include/state.php"; require_once "$docroot/plugins/dynamix.my.servers/include/api-config.php"; +require_once "$docroot/plugins/dynamix.my.servers/include/connect-config.php"; require_once "$docroot/webGui/include/Wrappers.php"; $serverState = new ServerState(); $keyfile = $serverState->keyfileBase64; -$myServersFlashCfg = $serverState->myServersFlashCfg; +$connectConfig = ConnectConfig::getConfig(); +$legacyRemoteCfg = $serverState->myServersFlashCfg['remote'] ?? []; + +$remoteDynamicRemoteAccessType = $connectConfig['dynamicRemoteAccessType'] ?? ($legacyRemoteCfg['dynamicRemoteAccessType'] ?? null); +$remoteWanAccessRaw = $connectConfig['wanaccess'] ?? ($legacyRemoteCfg['wanaccess'] ?? null); +$remoteUpnpEnabledRaw = $connectConfig['upnpEnabled'] ?? ($legacyRemoteCfg['upnpEnabled'] ?? null); +$remoteWanPortRaw = $connectConfig['wanport'] ?? ($legacyRemoteCfg['wanport'] ?? null); + +$wanaccessEnabled = filter_var($remoteWanAccessRaw, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); +if ($wanaccessEnabled === null) { + $wanaccessEnabled = false; +} +$upnpEnabled = filter_var($remoteUpnpEnabledRaw, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); +if ($upnpEnabled === null) { + $upnpEnabled = false; +} +$remoteWanPort = is_numeric($remoteWanPortRaw) ? (int)$remoteWanPortRaw : 0; $showT2Fa = (file_exists('/boot/config/plugins/dynamix.my.servers/showT2Fa')); @@ -37,9 +54,7 @@ $passwd_result = exec('/usr/bin/passwd --status root'); $boolWebUIAuth = $isRegistered && (($passwd_result !== false) && (substr($passwd_result, 0, 6) == 'root P')); // Helper to determine the current value for the remote access input -$dynamicRemoteAccessType = $myServersFlashCfg['remote']['dynamicRemoteAccessType'] ?? null; -$upnpEnabled = ($myServersFlashCfg['remote']['upnpEnabled'] ?? null) === 'yes'; -$wanaccessEnabled = ($myServersFlashCfg['remote']['wanaccess'] ?? null) === 'yes'; +$dynamicRemoteAccessType = $remoteDynamicRemoteAccessType ?? null; $currentRemoteAccessValue = 'OFF'; if ($dynamicRemoteAccessType === 'STATIC') { @@ -59,6 +74,12 @@ if ($dynamicRemoteAccessType === 'STATIC') { $enableRemoteT2fa = $showT2Fa && $currentRemoteAccessValue !== 'OFF' && $hasMyUnraidNetCert; $enableLocalT2fa = $showT2Fa && $var['USE_SSL'] === 'auto' && $hasMyUnraidNetCert; $shade="shade-".($display['theme']??'unk'); +$wanAccessOriginal = $remoteWanAccessRaw; +if (is_bool($wanAccessOriginal)) { + $wanAccessOriginal = $wanAccessOriginal ? 'yes' : 'no'; +} elseif (!is_string($wanAccessOriginal)) { + $wanAccessOriginal = ''; +} ?>