Add option to provide optional fetch flags

This commit is contained in:
2023-11-03 20:13:28 +01:00
parent d0bad95c11
commit d597a83422
3 changed files with 50 additions and 27 deletions

View File

@ -16,7 +16,7 @@ limitations under the License.
*/
function uupApiVersion() {
return '1.42.1';
return '1.43.0-dev';
}
require_once dirname(__FILE__).'/auths.php';

View File

@ -16,7 +16,7 @@ limitations under the License.
*/
// Composes DeviceAttributes parameter needed to fetch data
function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type) {
function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $flags) {
$branch = branchFromBuild($build);
$blockUpgrades = 0;
$flightEnabled = 1;
@ -216,11 +216,11 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type) {
'WuClientVer='.$build,
);
if(uupApiConfigIsTrue('fetch_sync_current_only')) {
if(in_array('thisonly', $flags)) {
$attrib[] = 'MediaBranch='.$branch;
}
if($ring == 'MSIT' && uupApiConfigIsTrue('allow_corpnet')) {
if(in_array('corpnet', $flags) && uupApiConfigIsTrue('allow_corpnet')) {
$attrib[] = 'DUInternal=1';
}
@ -316,7 +316,8 @@ function composeFileGetRequest($updateId, $info, $rev = 1, $type = 'Production')
isset($info['checkBuild']) ? $info['checkBuild'] : '10.0.19041.1',
isset($info['arch']) ? $info['arch'] : 'amd64',
isset($info['sku']) ? $info['sku'] : 48,
$type
$type,
isset($info['flags']) ? $info['flags'] : [],
);
return <<<XML
@ -360,7 +361,7 @@ XML;
}
// Composes POST data for fetching the latest update information from Windows Update
function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type = 'Production') {
function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type = 'Production', $flags = []) {
$device = uupDevice();
$encData = uupEncryptedData();
$uuid = genUUID();
@ -448,11 +449,11 @@ function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type
$build,
$arch,
$sku,
$type
$type,
$flags
);
$syncCurrent = uupApiConfigIsTrue('fetch_sync_current_only');
$syncCurrentStr = $syncCurrent ? 'true' : 'false';
$syncCurrent = in_array('thisonly', $flags) ? 'true' : 'false';
return <<<XML
<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
@ -575,7 +576,7 @@ function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type
</ExtendedUpdateInfoParameters>
<ClientPreferredLanguages/>
<ProductsParameters>
<SyncCurrentVersionOnly>$syncCurrentStr</SyncCurrentVersionOnly>
<SyncCurrentVersionOnly>$syncCurrent</SyncCurrentVersionOnly>
<DeviceAttributes>$deviceAttributes</DeviceAttributes>
<CallerAttributes>$callerAttrib</CallerAttributes>
<Products>$products</Products>