From b0786a03a9886e5b212da135432c5410de6305cb Mon Sep 17 00:00:00 2001 From: toufic ar Date: Thu, 5 Feb 2026 22:19:32 +0200 Subject: [PATCH] add metrics --- index.html | 35 ++++++++++++++++++++++++++++++++++- metrics.php | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 metrics.php diff --git a/index.html b/index.html index eb71f91..2e77b2e 100644 --- a/index.html +++ b/index.html @@ -19,6 +19,7 @@ :root { --background: #38383d; --text: #ececec; + --text-alt: #868689; --primary: #cc80ff; --accent: #68b030; ::selection { @@ -68,7 +69,20 @@ >adonis runs a tor relay node and a snowflake proxy.
- this helps people stay anonymous and circumvent censorship. + this helps people stay anonymous and circumvent censorship:
+ + snowflake connections since last restart +

@@ -95,4 +109,23 @@ > + diff --git a/metrics.php b/metrics.php new file mode 100644 index 0000000..f4f7b50 --- /dev/null +++ b/metrics.php @@ -0,0 +1,41 @@ + '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]);