This commit is contained in:
devdatt 2026-01-10 11:00:44 +05:30
parent 91e51e42f1
commit c7b5d7d3c0
3 changed files with 18 additions and 26 deletions

View File

@ -162,7 +162,7 @@ EwIDAQAB
$zip = new ZipArchive(); $zip = new ZipArchive();
if ($zip->open($zipFile) !== true) { if ($zip->open($zipFile) !== true) {
error_log("zip unzip problem"); error_log("zip unzip problem");
fail('Unable to open ZIP'); fail('Unable to open ZIP');
} }
for ($i = 0; $i < $zip->numFiles; $i++) { for ($i = 0; $i < $zip->numFiles; $i++) {
@ -220,7 +220,6 @@ EwIDAQAB
exec('sudo reboot'); exec('sudo reboot');
break; break;
case 'backup': case 'backup':
$jsonFiles = [ $jsonFiles = [
'input.json', 'input.json',
'output.json', 'output.json',
@ -230,16 +229,12 @@ EwIDAQAB
]; ];
$tmpZip = sys_get_temp_dir() . '/backup.zip'; $tmpZip = sys_get_temp_dir() . '/backup.zip';
$outputFile = __DIR__ . '/universal_encoder_decoder.bin';
$publicKey = file_get_contents('/var/www/backup_private.pem');
$publicKey = file_get_contents('/var/www/backup_public.pem'); $publicKey = file_get_contents('/var/www/backup_public.pem');
$zip = new ZipArchive(); $zip = new ZipArchive();
$zip->open($tmpZip, ZipArchive::CREATE | ZipArchive::OVERWRITE); $zip->open($tmpZip, ZipArchive::CREATE | ZipArchive::OVERWRITE);
/* Add JSON files if exist */
foreach ($jsonFiles as $json) { foreach ($jsonFiles as $json) {
if (file_exists($json)) { if (file_exists($json)) {
$zip->addFile($json, basename($json)); $zip->addFile($json, basename($json));
@ -249,11 +244,9 @@ EwIDAQAB
$zip->close(); $zip->close();
$data = file_get_contents($tmpZip); $data = file_get_contents($tmpZip);
/* Generate AES key */
$aesKey = random_bytes(32); $aesKey = random_bytes(32);
$iv = random_bytes(16); $iv = random_bytes(16);
/* Encrypt ZIP */
$encryptedData = openssl_encrypt( $encryptedData = openssl_encrypt(
$data, $data,
'AES-256-CBC', 'AES-256-CBC',
@ -262,31 +255,28 @@ EwIDAQAB
$iv $iv
); );
/* Encrypt AES key using RSA public key */
openssl_public_encrypt($aesKey, $encryptedKey, $publicKey); openssl_public_encrypt($aesKey, $encryptedKey, $publicKey);
/* Final binary format */ $binary = pack('N', strlen($encryptedKey));
$payload = json_encode([ $binary .= $encryptedKey;
'key' => base64_encode($encryptedKey), $binary .= $iv;
'iv' => base64_encode($iv), $binary .= $encryptedData;
'data' => base64_encode($encryptedData)
]);
/* Headers */
$filename = 'universal_encoder_decoder.bin'; $filename = 'universal_encoder_decoder.bin';
header('Content-Description: File Transfer'); header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream'); header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $filename . '"'); header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Content-Length: ' . strlen($payload)); header('Content-Length: ' . strlen($binary));
header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: no-store, no-cache, must-revalidate');
header('Pragma: no-cache'); header('Pragma: no-cache');
header('Expires: 0'); header('Expires: 0');
echo $payload; echo $binary;
flush(); flush();
unlink($tmpZip); unlink($tmpZip);
break; break;
case 'restore': case 'restore':

View File

@ -375,18 +375,19 @@ function update_service($which_service)
case "copy_input": case "copy_input":
switch ($input_source) { switch ($input_source) {
case "hdmi": case "hdmi":
$input .= "ffmpeg -init_hw_device qsv=hw -filter_hw_device hw -hide_banner -f v4l2 -thread_queue_size 1024 -input_format mjpeg " $input .= "ffmpeg -init_hw_device qsv=hw -filter_hw_device hw -hide_banner -hwaccel qsv -hwaccel_output_format qsv -f v4l2 -thread_queue_size 2048 -input_format mjpeg "
. " -video_size " . $data['hdmi']['resolution'] . " -video_size " . $data['hdmi']['resolution']
. " -framerate " . $data['hdmi']['framerate'] . " -framerate " . $data['hdmi']['framerate']
. " -f alsa -thread_queue_size 1024 -i " . $data['hdmi']['audio_source'] . " -f alsa -thread_queue_size 1024 -i " . $data['hdmi']['audio_source']
. " -c:v h264_qsv -pix_fmt yuv420p -profile:v high -b:v 5M -maxrate 5M -bufsize 12M -c:a aac -b:a 265k -ar 48000 -tune zerolatency "; . " -c:v h264_qsv -profile:v high -level:v 4.2 -b:v 5M -maxrate 5M -bufsize 12M -tune zerolatency -muxrate 0 -pat_period 0.1 -pkt_size 1316 "
. " -c:a aac -b:a 265k -ar 48000 ";
if ($hdmi_delay_video != "") if ($hdmi_delay_video != "")
$input .= "-vf " . setptsFromMs($hdmi_delay_video); $input .= "-vf " . setptsFromMs($hdmi_delay_video);
if ($hdmi_delay_audio != "") if ($hdmi_delay_audio != "")
$input .= adelayFromMs($hdmi_delay_audio, 2); $input .= adelayFromMs($hdmi_delay_audio, 2);
$input .= " -f mpegts " . ' "udp://@239.255.254.254:39000?localaddr=127.0.0.1"'; $input .= " -f mpegts " . ' "udp://239.255.254.254:39000?reuse=1&localaddr=127.0.0.1"';
break; break;
case "url": case "url":
$input .= "ffmpeg -hwaccel auto -hide_banner -stream_loop -1 -re -i " . $data['url'] . " -c:v copy -c:a copy -f mpegts " . ' "udp://@239.255.254.254:39000?localaddr=127.0.0.1"'; $input .= "ffmpeg -hwaccel auto -hide_banner -stream_loop -1 -re -i " . $data['url'] . " -c:v copy -c:a copy -f mpegts " . ' "udp://@239.255.254.254:39000?localaddr=127.0.0.1"';
@ -405,9 +406,9 @@ function update_service($which_service)
case "use_common_backend": case "use_common_backend":
switch ($input_source) { switch ($input_source) {
case "hdmi": case "hdmi":
$input .= "ffmpeg -init_hw_device qsv=hw -filter_hw_device hw -hide_banner -f v4l2 -thread_queue_size 1024 -input_format mjpeg -video_size " . $data['hdmi']['resolution'] $input .= "ffmpeg -init_hw_device qsv=hw -filter_hw_device hw -hide_banner -hwaccel qsv -hwaccel_output_format qsv -f v4l2 -thread_queue_size 2048 -input_format mjpeg -video_size " . $data['hdmi']['resolution']
. " -framerate " . $data['hdmi']['framerate'] . " -i /dev/video0 -f alsa -thread_queue_size 1024 -i " . $data['hdmi']['audio_source'] . " -framerate " . $data['hdmi']['framerate'] . " -i /dev/video0 -f alsa -thread_queue_size 1024 -i " . $data['hdmi']['audio_source']
. " -c:v h264_qsv "; . " -c:v h264_qsv -profile:v high -level:v 4.2 ";
if ($hdmi_delay_video != "") if ($hdmi_delay_video != "")
$input .= ' -vf "scale=' . $common_backend_resolution . ',' . setptsFromMs($hdmi_delay_video) . '"'; $input .= ' -vf "scale=' . $common_backend_resolution . ',' . setptsFromMs($hdmi_delay_video) . '"';
else else
@ -425,8 +426,8 @@ function update_service($which_service)
$input .= ' -af "volume=' . $common_backend_audio_db_gain . ',' . adelayFromMs($hdmi_delay_audio, 2) . '"'; $input .= ' -af "volume=' . $common_backend_audio_db_gain . ',' . adelayFromMs($hdmi_delay_audio, 2) . '"';
else else
$input .= ' -af "volume=' . $common_backend_audio_db_gain . '"'; $input .= ' -af "volume=' . $common_backend_audio_db_gain . '"';
$input .= " -tune zerolatency -pkt_size 1316 -f mpegts " $input .= " -tune zerolatency -muxrate 0 -pat_period 0.1 -pkt_size 1316 -f mpegts "
. ' "udp://@239.255.254.254:39000?localaddr=127.0.0.1"'; . ' "udp://239.255.254.254:39000?reuse=1&localaddr=127.0.0.1"';
break; break;
case "url": case "url":
$input .= "ffmpeg -hwaccel auto -hide_banner -stream_loop -1 -re -i " . $data['url'] $input .= "ffmpeg -hwaccel auto -hide_banner -stream_loop -1 -re -i " . $data['url']

View File

@ -4,4 +4,5 @@ sudo cp users.json /var/www/users.json
sudo cp attempts.json /var/www/attempts.json sudo cp attempts.json /var/www/attempts.json
DEVICE_ID="$(sudo cat /sys/class/dmi/id/product_uuid | tr -d '\n')" DEVICE_ID="$(sudo cat /sys/class/dmi/id/product_uuid | tr -d '\n')"
sudo sed -i 's/certificatecertificatecertificatecertificate/'$DEVICE_ID'/g' /var/www/html/certification.html sudo sed -i 's/certificatecertificatecertificatecertificate/'$DEVICE_ID'/g' /var/www/html/certification.html
sudo chown -R www-data:www-data /var/www/*
sudo reboot sudo reboot