mirror of
https://github.com/dyzulk/trustlab-api.git
synced 2026-01-26 13:22:05 +07:00
Feat: Add post-install telemetry ping (CORS enabled)
This commit is contained in:
@@ -162,4 +162,18 @@ class PublicCaController extends Controller
|
|||||||
'Content-Disposition' => 'attachment; filename="' . $filename . '"',
|
'Content-Disposition' => 'attachment; filename="' . $filename . '"',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Track download/installation count (Telemetry).
|
||||||
|
* Used by installer scripts to perform a "Ping" after successful installation.
|
||||||
|
*/
|
||||||
|
public function trackDownload($serial)
|
||||||
|
{
|
||||||
|
$cert = CaCertificate::where('serial_number', $serial)->firstOrFail();
|
||||||
|
$cert->increment('download_count');
|
||||||
|
$cert->update(['last_downloaded_at' => now()]);
|
||||||
|
|
||||||
|
return response()->json(['success' => true])
|
||||||
|
->header('Access-Control-Allow-Origin', '*')
|
||||||
|
->header('Access-Control-Allow-Methods', 'POST');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ class CaInstallerService
|
|||||||
")\r\n" .
|
")\r\n" .
|
||||||
"call :printSuccess \"Certificate installed successfully!\"\r\n" .
|
"call :printSuccess \"Certificate installed successfully!\"\r\n" .
|
||||||
"\r\n" .
|
"\r\n" .
|
||||||
|
"powershell -Command \"Invoke-WebRequest -Uri 'https://pki.trustlab.local/api/public/ca-certificates/{$cert->serial_number}/track' -Method POST -ErrorAction SilentlyContinue\" >nul 2>&1\r\n" .
|
||||||
|
"\r\n" .
|
||||||
"del \"%TEMP_CERT%\"\r\n" .
|
"del \"%TEMP_CERT%\"\r\n" .
|
||||||
"echo.\r\n" .
|
"echo.\r\n" .
|
||||||
"call :printInfo \"Press any key to close...\"\r\n" .
|
"call :printInfo \"Press any key to close...\"\r\n" .
|
||||||
@@ -202,6 +204,7 @@ class CaInstallerService
|
|||||||
"msg_info \"Updating certificate store...\"\n" .
|
"msg_info \"Updating certificate store...\"\n" .
|
||||||
"if \$UPDATE_CMD >/dev/null 2>&1; then\n" .
|
"if \$UPDATE_CMD >/dev/null 2>&1; then\n" .
|
||||||
" msg_ok \"Store updated successfully.\"\n" .
|
" msg_ok \"Store updated successfully.\"\n" .
|
||||||
|
" curl -X POST -s \"https://pki.trustlab.local/api/public/ca-certificates/{$cert->serial_number}/track\" >/dev/null 2>&1\n" .
|
||||||
"else\n" .
|
"else\n" .
|
||||||
" msg_err \"Failed to update certificate store.\"\n" .
|
" msg_err \"Failed to update certificate store.\"\n" .
|
||||||
" exit 1\n" .
|
" exit 1\n" .
|
||||||
@@ -379,6 +382,8 @@ class CaInstallerService
|
|||||||
|
|
||||||
$shContent .= "msg_info \"Processing: {$cert->common_name}\"\n";
|
$shContent .= "msg_info \"Processing: {$cert->common_name}\"\n";
|
||||||
$shContent .= "curl -sL \"{$cdnUrl}\" -o \"\$TARGET_DIR/{$filename}\"\n";
|
$shContent .= "curl -sL \"{$cdnUrl}\" -o \"\$TARGET_DIR/{$filename}\"\n";
|
||||||
|
// Telemetry Ping (Silent)
|
||||||
|
$shContent .= "curl -X POST -s \"https://pki.trustlab.local/api/public/ca-certificates/{$cert->serial_number}/track\" >/dev/null 2>&1\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$shContent .= "\nmsg_info \"Updating certificate store...\"\n" .
|
$shContent .= "\nmsg_info \"Updating certificate store...\"\n" .
|
||||||
@@ -418,6 +423,7 @@ class CaInstallerService
|
|||||||
"call :printAction \"Installing {$cert->common_name}...\"\r\n" .
|
"call :printAction \"Installing {$cert->common_name}...\"\r\n" .
|
||||||
"powershell -Command \"Invoke-WebRequest -Uri '{$cdnUrl}' -OutFile '%TEMP_CERT%'\"\r\n" .
|
"powershell -Command \"Invoke-WebRequest -Uri '{$cdnUrl}' -OutFile '%TEMP_CERT%'\"\r\n" .
|
||||||
"certutil -addstore -f \"{$store}\" \"%TEMP_CERT%\" >nul 2>&1\r\n" .
|
"certutil -addstore -f \"{$store}\" \"%TEMP_CERT%\" >nul 2>&1\r\n" .
|
||||||
|
"powershell -Command \"Invoke-WebRequest -Uri 'https://pki.trustlab.local/api/public/ca-certificates/{$cert->serial_number}/track' -Method POST -ErrorAction SilentlyContinue\" >nul 2>&1\r\n" .
|
||||||
"del \"%TEMP_CERT%\"\r\n";
|
"del \"%TEMP_CERT%\"\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ Route::get('/public/ca-certificates/{serial}/download', [PublicCaController::cla
|
|||||||
Route::get('/public/ca-certificates/{serial}/download/windows', [PublicCaController::class, 'downloadWindows']);
|
Route::get('/public/ca-certificates/{serial}/download/windows', [PublicCaController::class, 'downloadWindows']);
|
||||||
Route::get('/public/ca-certificates/{serial}/download/mac', [PublicCaController::class, 'downloadMac']);
|
Route::get('/public/ca-certificates/{serial}/download/mac', [PublicCaController::class, 'downloadMac']);
|
||||||
Route::get('/public/ca-certificates/{serial}/download/linux', [PublicCaController::class, 'downloadLinux']);
|
Route::get('/public/ca-certificates/{serial}/download/linux', [PublicCaController::class, 'downloadLinux']);
|
||||||
|
Route::post('/public/ca-certificates/{serial}/track', [PublicCaController::class, 'trackDownload']);
|
||||||
Route::post('/public/inquiries', [\App\Http\Controllers\Api\InquiryController::class, 'store']);
|
Route::post('/public/inquiries', [\App\Http\Controllers\Api\InquiryController::class, 'store']);
|
||||||
Route::get('/public/legal-pages', [\App\Http\Controllers\Api\LegalPageController::class, 'index']);
|
Route::get('/public/legal-pages', [\App\Http\Controllers\Api\LegalPageController::class, 'index']);
|
||||||
Route::get('/public/legal-pages/{slug}', [\App\Http\Controllers\Api\LegalPageController::class, 'show']);
|
Route::get('/public/legal-pages/{slug}', [\App\Http\Controllers\Api\LegalPageController::class, 'show']);
|
||||||
|
|||||||
Reference in New Issue
Block a user