Release
This commit is contained in:
23
web/api/now.php
Normal file
23
web/api/now.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?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()]);
|
||||
}
|
||||
Reference in New Issue
Block a user