23 lines
806 B
PHP
23 lines
806 B
PHP
<?php
|
|
require __DIR__ . '/../lib/app.php'; auth_require();
|
|
require __DIR__ . '/../lib/torctl.php';
|
|
header('Content-Type: application/json');
|
|
try {
|
|
$info = torctl([
|
|
"GETINFO traffic/read",
|
|
"GETINFO traffic/written",
|
|
"GETINFO status/circuit-established",
|
|
"GETINFO version",
|
|
"GETINFO status/bootstrap-phase"
|
|
]);
|
|
echo json_encode([
|
|
"ok" => true,
|
|
"read" => (int)($info["traffic/read"] ?? 0),
|
|
"written" => (int)($info["traffic/written"] ?? 0),
|
|
"circuits" => (($info["status/circuit-established"] ?? "0") === "1"),
|
|
"version" => ($info["version"] ?? "unknown"),
|
|
"bootstrap" => ($info["status/bootstrap-phase"] ?? "")
|
|
]);
|
|
} catch (Throwable $e) {
|
|
echo json_encode(["ok"=>false,"error"=>$e->getMessage()]);
|
|
} |