From 52ff1b70c379a7c4b7d091334385917af4da079f Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Thu, 16 Sep 2021 13:06:18 -0400 Subject: [PATCH 01/11] add(upc): os version --- plugins/dynamix.my.servers/include/myservers2.php | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/dynamix.my.servers/include/myservers2.php b/plugins/dynamix.my.servers/include/myservers2.php index b37c64671..bad46257b 100644 --- a/plugins/dynamix.my.servers/include/myservers2.php +++ b/plugins/dynamix.my.servers/include/myservers2.php @@ -459,6 +459,7 @@ "internalip" => $_SERVER['SERVER_ADDR'], "internalport" => $_SERVER['SERVER_PORT'], "keyfile" => str_replace(['+','/','='], ['-','_',''], trim(base64_encode(@file_get_contents($var['regFILE'])))), + "osVersion" => $var['version'], "plgVersion" => 'base-'.$var['version'], "protocol" => $_SERVER['REQUEST_SCHEME'], "reggen" => (int)$var['regGen'], From 97397b2b3364fedfd2fba88057d06875b54f2b83 Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Thu, 16 Sep 2021 14:41:50 -0400 Subject: [PATCH 02/11] feat: ssl requires sign in warning --- plugins/dynamix.my.servers/include/myservers2.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/dynamix.my.servers/include/myservers2.php b/plugins/dynamix.my.servers/include/myservers2.php index bad46257b..f856cd7fc 100644 --- a/plugins/dynamix.my.servers/include/myservers2.php +++ b/plugins/dynamix.my.servers/include/myservers2.php @@ -447,6 +447,9 @@ "nokeyserver" => 'NO_KEY_SERVER', "withdrawn" => 'WITHDRAWN', ]; + // required for boolean to check if user has unraid.net Let's Encrypt cert + $hasCert = file_exists('/boot/config/ssl/certs/certificate_bundle.pem'); + $externalhostname = $hasCert ? trim(exec("/usr/bin/openssl x509 -subject -noout -in /boot/config/ssl/certs/certificate_bundle.pem | awk -F' = ' '{print $2}'")) : ''; // feeds server vars to Vuex store in a slightly different array than state.php $serverstate = [ "avatar" => $remote['avatar'], @@ -473,6 +476,7 @@ 'configError' => $var['configValid'] !== 'yes' ? (array_key_exists($var['configValid'], $configErrorEnum) ? $configErrorEnum[$var['configValid']] : 'UNKNOWN_ERROR') : null, + 'hasUnraidNetSSL' => preg_match('/.*\.unraid\.net$/', $externalhostname), ]; ?> Date: Thu, 16 Sep 2021 15:47:38 -0400 Subject: [PATCH 03/11] chore: upc translations --- plugins/dynamix.my.servers/include/myservers2.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugins/dynamix.my.servers/include/myservers2.php b/plugins/dynamix.my.servers/include/myservers2.php index f856cd7fc..b4bf20e9d 100644 --- a/plugins/dynamix.my.servers/include/myservers2.php +++ b/plugins/dynamix.my.servers/include/myservers2.php @@ -57,6 +57,19 @@ 'openDropdown' => _('Open dropdown'), 'pleaseConfirmClosureYouHaveOpenPopUp' => _('Please confirm closure').'. '._('You have an open pop-up').'.', 'trialHasExpiredSeeOptions' => _('Trial has expired see options below'), + 'errorCertRequiresSignIn' => _('Sign In before your Unraid.net SSL certificate expires'), + 'noRemoteApikeyRegisteredWithPlg' => [ + 'heading' => _('My Servers Error'), + 'msg' => _('Unraid.net re-authentication required'), + ], + 'errorTooManyDisks' => [ + 'heading' => 'Too many devices', + 'msg' => [ + 'base' => 'You must upgrade your key to support more devices.', + 'basic' => 'Your Basic key supports 6 devices.', + 'plus' => 'Your Plus key supports 12 devices.', + ], + ], 'extraLinks' => [ 'newTab' => sprintf(_('Opens %s in new tab'), '{0}'), 'myServers' => _('My Servers Dashboard'), From 15cee10f4de1aa9c36b6668c414cf10fef62b3f6 Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Fri, 17 Sep 2021 14:28:33 -0400 Subject: [PATCH 04/11] refactor: unraid.net cert requires server to be signed in --- plugins/dynamix/ManagementAccess.page | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/plugins/dynamix/ManagementAccess.page b/plugins/dynamix/ManagementAccess.page index 1ee62dcfa..483da76d5 100644 --- a/plugins/dynamix/ManagementAccess.page +++ b/plugins/dynamix/ManagementAccess.page @@ -52,6 +52,8 @@ $certPresent = file_exists("$certFile"); $certSubject = $certPresent ? exec("openssl x509 -noout -subject -nameopt multiline -in $certFile 2>/dev/null|sed -n 's/ *commonName *= //p'") : ""; $isLEcert = $certPresent && preg_match('/.*\.unraid\.net$/', $certSubject); +$isRegistered = !empty($remote['username']); // signed in to unraid.net or not + if ($isLEcert) { exec("openssl x509 -checkend 2592000 -noout -in $certFile 2>/dev/null", $arrout, $retval_expired); $prot = $$ethX['PROTOCOL:0']=='ipv6' ? '-6' : '-4'; @@ -65,10 +67,11 @@ if ($isLEcert) { } $provisionlabel = $isLEcert ? _('Renew') : _('Provision'); -$disabled_provision = $keyfile===false || ($isLEcert && $retval_expired===0) ? 'disabled' : ''; -$disabled_updatedns = $keyfile!==false && $isLEcert ? '' : 'disabled'; +$disabled_provision = !$isRegistered || $keyfile===false || ($isLEcert && $retval_expired===0) ? 'disabled' : ''; +$disabled_updatedns = $isRegistered && $keyfile!==false && $isLEcert ? '' : 'disabled'; $disabled_delete = $certPresent && $var['USE_SSL']!='auto' ? '' : 'disabled'; -$disabled_auto = $isLEcert && !$dnsRebindingProtection && $dnsValid ? '' : 'disabled'; +$disabled_yes = !$isRegistered || $keyfile===false ? 'disabled' : ''; +$disabled_auto = $isRegistered && $isLEcert && !$dnsRebindingProtection && $dnsValid ? '' : 'disabled'; // Get ports in use $portsInUse = []; @@ -83,7 +86,19 @@ foreach ($output as $line) { } ?>