Initial commit of update-proxy

This commit is contained in:
Richard Blair
2023-01-21 01:31:25 -05:00
commit 35741bc99c
6 changed files with 97 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
vendor/
composer.lock
BUILD-DATA

2
TODO.txt Normal file
View File

@@ -0,0 +1,2 @@
(B) Provide mechanism for verifying GPG signatures on requested pages. note:"[Todo] Secure Mechanism.md"
(A)

View File

@@ -0,0 +1 @@
This may allow us to create a GPG-encrypted transmission mode between the update-server and client.

15
composer.json Normal file
View File

@@ -0,0 +1,15 @@
{
"name": "tononixos/update-proxy",
"description": "Update proxy for the tononixOS Bootloader to add device authentication information to requests",
"type": "project",
"authors": [
{
"name": "Richard Blair",
"email": "dreamcaster23@gmail.com"
}
],
"require": {
"symfony/yaml": "^6.2",
"hassankhan/config": "^3.1"
}
}

73
index.php Normal file
View File

@@ -0,0 +1,73 @@
<?php
$SelfUpdateUrl = "https://tonoxisisle.services/tononixOS/recovery/BUILD-DATA";
$SelfUpdateZipUrl = "https://tonoxisisle.services/tononixOS/recovery/recovery.zip";
$SerialNumber = file_get_contents("/sys/firmware/devicetree/base/serial-number");
#$SerialNumber = "000019292900aTEST";
$SerialNumber = str_replace("\r","",$SerialNumber);
$SerialNumber = str_replace("\n","",$SerialNumber);
$RecoveryVersionInfo = file("/mnt/BUILD-DATA");
$RecoveryVersion = str_replace("PINN Version: ", "", $RecoveryVersionInfo[1]);
$RecoveryVersion = str_replace("\r","",$RecoveryVersion);
$RecoveryVersion = str_replace("\n","",$RecoveryVersion);
$UpdateServiceHeaders = [
'X-Device-Serial-Number' => $SerialNumber,
'X-Device-Bootloader-Version' => $RecoveryVersion
];
switch($_GET['file'])
{
case 'BUILD-DATA':
$vars = [
"action"=> "selfupdate_check"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $SelfUpdateUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $UpdateServiceHeaders);
#curl_setopt($ch, CURLOPT_POST, 1);
#curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CRLF, 1);
$buildData = curl_exec($ch);
if(curl_errno($ch)) {
print "Error ". curl_errno($ch);
exit();
}
curl_close($ch);
$version = $buildData;
## Begin Processing and Outputting of the data file.
print($version."\r\n");
## End Processing and Outputting of the data file.
break;
case 'recovery.zip':
$vars = [
"action" => "selfupdate_file"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $SelfUpdateZipUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $UpdateServiceHeaders);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$recoveryZipData = curl_exec($ch);
if(curl_errno($ch)) {
print "Error ". curl_errno($ch);
exit();
}
curl_close($ch);
# BEGIN Processing and Outputting of ZIP file
echo($recoveryZipData);
# END Processing and Outputting of ZIP file
break;
}

3
update-proxy.ini Normal file
View File

@@ -0,0 +1,3 @@
[proxy-urls]
self-update-file=https://tonoxisisle.services/tononixOS/recovery/BUILD-DATA
self-update-zip=https://tonoxisisle.services/tononixOS/recovery/recovery.zip