This commit is contained in:
parent
7f29a1f315
commit
b0786a03a9
2 changed files with 75 additions and 1 deletions
35
index.html
35
index.html
|
|
@ -19,6 +19,7 @@
|
||||||
:root {
|
:root {
|
||||||
--background: #38383d;
|
--background: #38383d;
|
||||||
--text: #ececec;
|
--text: #ececec;
|
||||||
|
--text-alt: #868689;
|
||||||
--primary: #cc80ff;
|
--primary: #cc80ff;
|
||||||
--accent: #68b030;
|
--accent: #68b030;
|
||||||
::selection {
|
::selection {
|
||||||
|
|
@ -68,7 +69,20 @@
|
||||||
>adonis</a
|
>adonis</a
|
||||||
>
|
>
|
||||||
runs a tor relay node and a snowflake proxy.<br />
|
runs a tor relay node and a snowflake proxy.<br />
|
||||||
this helps people stay anonymous and circumvent censorship.
|
this helps people stay anonymous and circumvent censorship:<br />
|
||||||
|
<span
|
||||||
|
style="
|
||||||
|
color: var(--accent);
|
||||||
|
font-weight: bolder;
|
||||||
|
text-decoration: underline;
|
||||||
|
text-decoration-color: var(--accent);
|
||||||
|
"
|
||||||
|
id="snowflake_conns"
|
||||||
|
></span>
|
||||||
|
<span style="color: var(--text-alt); font-weight: bolder"
|
||||||
|
>snowflake connections since last restart</span
|
||||||
|
>
|
||||||
|
<br />
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -95,4 +109,23 @@
|
||||||
></iframe>
|
></iframe>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
<script>
|
||||||
|
async function fetchConnections() {
|
||||||
|
try {
|
||||||
|
const res = await fetch("https://tor.toufy.me/metrics.php", {
|
||||||
|
method: "GET",
|
||||||
|
headers: { Accept: "application/json" }
|
||||||
|
});
|
||||||
|
if (!res.ok) {
|
||||||
|
console.log(res);
|
||||||
|
snowflake_conns.innerHTML = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
snowflake_conns.innerHTML = (await res.json()).snowflake_connections;
|
||||||
|
} catch (_) {
|
||||||
|
snowflake_conns.innerHTML = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fetchConnections();
|
||||||
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
41
metrics.php
Normal file
41
metrics.php
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
|
||||||
|
http_response_code(405);
|
||||||
|
header('Allow: GET');
|
||||||
|
echo json_encode(['error' => 'method not allowed']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_snowflake_connections()
|
||||||
|
{
|
||||||
|
$metric = 'tor_snowflake_proxy_connections_total';
|
||||||
|
$body = file_get_contents(
|
||||||
|
'http://127.0.0.1:9999/internal/metrics',
|
||||||
|
false
|
||||||
|
);
|
||||||
|
if (!$body) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
$conns = 0;
|
||||||
|
foreach (preg_split('/\r\n|\n|\r/', $body) as $line) {
|
||||||
|
$line = trim($line);
|
||||||
|
if (!$line || $line[0] === '#')
|
||||||
|
continue;
|
||||||
|
if (preg_match(
|
||||||
|
'/^'
|
||||||
|
. preg_quote($metric, '/')
|
||||||
|
. '(?:\{[^}]*\})?\s+([0-9]+(?:\.[0-9]+)?)$/', $line, $m
|
||||||
|
)) {
|
||||||
|
$conns = $m[1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $conns;
|
||||||
|
}
|
||||||
|
|
||||||
|
$snowflake_connections = get_snowflake_connections();
|
||||||
|
|
||||||
|
echo json_encode(['snowflake_connections' => $snowflake_connections]);
|
||||||
Loading…
Add table
Add a link
Reference in a new issue