diff options
author | Matthieu Gallien <matthieu_gallien@yahoo.fr> | 2021-05-03 19:54:02 +0300 |
---|---|---|
committer | Matthieu Gallien <matthieu_gallien@yahoo.fr> | 2021-05-05 16:59:51 +0300 |
commit | 74936654835db5d3d5a66847dd41a4916b6a2544 (patch) | |
tree | 80b650dffe40b5d6cea23d4b677d01ae657773c9 | |
parent | c1fdcf21517684dd1ae39e3755abde804984832f (diff) |
detect some legacy Windows versions and return legacy update version
should allow to serve old desktop client versions to legacy operating
systems
Signed-off-by: Matthieu Gallien <matthieu_gallien@yahoo.fr>
-rw-r--r-- | config/config.php | 15 | ||||
-rw-r--r-- | index.php | 6 | ||||
-rw-r--r-- | src/Response.php | 39 |
3 files changed, 60 insertions, 0 deletions
diff --git a/config/config.php b/config/config.php index 2f9e847..736e691 100644 --- a/config/config.php +++ b/config/config.php @@ -23,18 +23,24 @@ declare(strict_types=1); $rel = '2021-04-29 16:00'; $ver = '3.2.1'; +$legacy_ver = '3.1.3'; $ver_str = 'Nextcloud Client ' . $ver; +$legacy_ver_str = 'Nextcloud Client ' . $legacy_ver; if (version_compare($version, '3.0.3') < 0) { $url = 'https://download.nextcloud.com/desktop/releases/'; + $legacyurl = 'https://download.nextcloud.com/desktop/releases/'; $linux_url = $url . 'Linux/'; $windows_url = $url . 'Windows/'; + $legacy_windows_url = $legacyurl; $mac_url = $url . 'Mac/Installer/'; } else { $url = 'https://github.com/nextcloud/desktop/releases/download/v' . $ver . '/'; + $legacyurl = 'https://github.com/nextcloud/desktop/releases/download/v' . $legacy_ver . '/'; $linux_url = $url; $windows_url = $url; + $legacy_windows_url = $legacyurl; $mac_url = $url; } @@ -58,19 +64,28 @@ return [ 'linux' => [ 'version' => $ver, 'versionstring' => $ver_str, + 'legacyversion' => null, + 'legacyversionstring' => null, 'downloadurl' => $linux_url . 'Nextcloud-' . $ver . '-x86_64.AppImage', + 'legacydownloadurl' => null, 'web' => 'https://nextcloud.com/install/?pk_campaign=clientupdate#install-clients', ], 'win32' => [ 'version' => $ver, 'versionstring' => $ver_str, + 'legacyversion' => $legacy_ver, + 'legacyversionstring' => $legacy_ver_str, 'downloadurl' => $windows_url . 'Nextcloud-' . $ver . $windows_suffix, + 'legacydownloadurl' => $legacy_windows_url . 'Nextcloud-' . $legacy_ver . $windows_suffix, 'web' => 'https://nextcloud.com/install/?pk_campaign=clientupdate#install-clients', ], 'macos' => [ 'version' => $ver, 'versionstring' => $ver_str, + 'legacyversion' => null, + 'legacyversionstring' => null, 'downloadurl' => $mac_url . 'Nextcloud-' . $ver . '.pkg', + 'legacydownloadurl' => null, 'web' => 'https://nextcloud.com/install/?pk_campaign=clientupdate#install-clients', ], ], @@ -86,6 +86,9 @@ $currentArch = isset($_GET['currentArch']) ? (string)$_GET['currentArch'] : "x86 $version = isset($_GET['version']) ? (string)$_GET['version'] : null; $isSparkle = isset($_GET['sparkle']) ? true : false; $updateSegment = isset($_GET['updatesegment']) ? (int)$_GET['updatesegment'] : -1; +$osRelease = isset($_GET['osRelease']) ? (string)$_GET['osRelease'] : ''; +$osVersion = isset($_GET['osVersion']) ? (string)$_GET['osVersion'] : ''; +$kernelVersion = isset($_GET['kernelVersion']) ? (string)$_GET['kernelVersion'] : ''; if($oem === null || $platform === null || $version === null) { die(); @@ -100,6 +103,9 @@ $response = new \ClientUpdateServer\Response( $version, $isSparkle, $updateSegment, + $osRelease, + $osVersion, + $kernelVersion, $config ); echo $response->buildResponse(); diff --git a/src/Response.php b/src/Response.php index edec1a3..d8b1dd2 100644 --- a/src/Response.php +++ b/src/Response.php @@ -33,6 +33,12 @@ class Response { private $isSparkle; /** @var int */ private $updateSegment; + /** @var string */ + private $osRelease; + /** @var string */ + private $osVersion; + /** @var string */ + private $kernelVersion; /** @var array */ private $config; @@ -41,12 +47,18 @@ class Response { string $version, bool $isSparkle, int $updateSegment, + string $osRelease, + string $osVersion, + string $kernelVersion, array $config) { $this->oem = $oem; $this->platform = $platform; $this->version = $version; $this->isSparkle = $isSparkle; $this->updateSegment = $updateSegment; + $this->osRelease = $osRelease; + $this->osVersion = $osVersion; + $this->kernelVersion = $kernelVersion; $this->config = $config; } @@ -89,12 +101,39 @@ class Response { $this->updateSegment = random_int(0, 99); } + $useNewerVersion = true; + if ($this->platform === 'win32') { + if ($this->osVersion === '10') { + switch ($this->kernelVersion) { + case '10.0.10240': + case '10.0.10586': + case '10.0.14393': + case '10.0.15063': + case '': + $useNewerVersion = false; + break; + } + } else { + $useNewerVersion = false; + } + } + // updateSegment is 0-99, so even fine grained control would possible $chunks = floor($this->updateSegment / 10); $throttleDate->sub(new \DateInterval('PT' . (12 * $chunks) . 'H')); if ($throttleDate >= $releaseDate) { $values = $this->config[$this->oem][$this->platform]; + + if ($useNewerVersion === false) { + $values['version'] = $values['legacyversion']; + $values['versionstring'] = $values['legacyversionstring']; + $values['downloadurl'] = $values['legacydownloadurl']; + } + unset($values['legacyversion']); + unset($values['legacyversionstring']); + unset($values['legacydownloadurl']); + if(version_compare($this->version, $values['version']) === -1) { return $values; } |