From 5e1cb67f9a44c09f81eeb71816cc6499e62a8a66 Mon Sep 17 00:00:00 2001 From: Lethonium Dev Server <38733902+RalfLeonFasler@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:55:23 +0000 Subject: [PATCH] Show live usage on the landing page, and add routes and privacy The landing page now shows who is on the shared routes right now, the last 30 days of rider-minutes, a per-app usage table and the routes the server serves. Add GET /privacy with what the public server stores and what it never stores. Update the README status, routes and apps. The landing test checks the route table and the privacy link; a new test checks the privacy page. --- README.md | 26 ++++++++++++- crates/server/src/landing.html | 63 ++++++++++++++++++++++++++++++ crates/server/src/presence.rs | 5 +++ crates/server/src/privacy.html | 71 ++++++++++++++++++++++++++++++++++ crates/server/src/routes.rs | 5 +++ crates/server/src/ws.rs | 18 ++++++++- crates/server/tests/ws.rs | 14 +++++++ 7 files changed, 199 insertions(+), 3 deletions(-) create mode 100644 crates/server/src/privacy.html diff --git a/README.md b/README.md index 62be3fc..856d06a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # OpenBikeNet Server -**Status: early draft, implements protocol v0.** +**Status: implements protocol v0.2. A public instance runs at +[openbikenet.cloud](https://openbikenet.cloud).** This is the reference server for the [OpenBikeNet protocol](https://github.com/OpenBikeNet/protocol): a shared, neutral server that lets riders of different indoor cycling apps see each other on @@ -14,6 +15,29 @@ Ideas and feedback are welcome in its Discussions. A public instance runs at [openbikenet.cloud](https://openbikenet.cloud). Apps connect to `wss://openbikenet.cloud/v0`, and `https://openbikenet.cloud/v0/stats` shows which apps are on. +## Shared routes + +The server serves every route file in `protocol/routes`. A position on a route is a distance in +metres from its start, so the same distance means the same spot in every app. + +| Route ID | Length | Notes | +| --- | --- | --- | +| `velodrome-250` | 250 m | A flat velodrome, the first shared route | +| `herne-hill-450` | 450 m | Herne Hill Velodrome, anticlockwise as raced | +| `herne-hill-450-clockwise` | 450 m | The same track the other way round | + +## Apps + +- [OpenRadlr](https://openradlr.com): the first app on the network and the reference + implementation. +- [VeloPopuli](https://velopopuli.com): has the shared Herne Hill track; the OpenBikeNet link is + in review. + +## Privacy + +`GET /privacy` describes what the public server stores. In short: per-app counts and dates, never +rider names, positions or IP addresses. The landing page shows live usage and the last 30 days. + ## Running it With Docker (nothing else needed): diff --git a/crates/server/src/landing.html b/crates/server/src/landing.html index a9096ac..a45a361 100644 --- a/crates/server/src/landing.html +++ b/crates/server/src/landing.html @@ -44,6 +44,16 @@

● OpenBikeNet server

A neutral relay that lets riders of different indoor cycling apps meet on the same route.

This is a backend for apps. There is nothing to use here in a browser.

+

Live

+

Loading the live numbers…

+

+ + +

Shared routes

+ + {{ROUTES}} +
+

Endpoints

@@ -62,6 +72,14 @@

Apps using it

WS/v0Protocol v0: presence on shared routes
+ +

Links

+ diff --git a/crates/server/src/presence.rs b/crates/server/src/presence.rs index 9f8105c..911535b 100644 --- a/crates/server/src/presence.rs +++ b/crates/server/src/presence.rs @@ -71,6 +71,11 @@ impl Presence { } } + /// The routes this server offers, for the landing page. + pub fn route_list(&self) -> Vec<(String, f64)> { + self.routes.list().map(|r| (r.id.clone(), r.length)).collect() + } + pub fn connect(&mut self, conn: ConnId, app: AppInfo) { self.conns.insert( conn, diff --git a/crates/server/src/privacy.html b/crates/server/src/privacy.html new file mode 100644 index 0000000..3fca9a0 --- /dev/null +++ b/crates/server/src/privacy.html @@ -0,0 +1,71 @@ + + + + + +Privacy · OpenBikeNet server + + + +
+

OpenBikeNet server · Privacy

+

OpenBikeNet is a relay for shared presence. This page describes what the public server at + openbikenet.cloud stores. If you run your own server, + you decide what it stores.

+ +

What is stored

+ +

That is all. The counts are what makes the public usage statistics possible.

+ +

What is not stored

+ + +

How long it is kept

+

Per-app rider counts are stored per day. The public statistics only read the last 30 days. + There is no rider history to delete, because none is kept.

+ +

Questions

+

Ask in the discussions, + or open an issue in the server repository.

+ + +
+ + diff --git a/crates/server/src/routes.rs b/crates/server/src/routes.rs index 476133c..0b89b82 100644 --- a/crates/server/src/routes.rs +++ b/crates/server/src/routes.rs @@ -76,6 +76,11 @@ impl Routes { pub fn ids(&self) -> impl Iterator { self.by_id.keys().map(String::as_str) } + + /// Every route, sorted by ID. + pub fn list(&self) -> impl Iterator { + self.by_id.values() + } } /// Checks one route against the profile rules of spec 4.1. diff --git a/crates/server/src/ws.rs b/crates/server/src/ws.rs index c000727..973b3d0 100644 --- a/crates/server/src/ws.rs +++ b/crates/server/src/ws.rs @@ -169,6 +169,7 @@ pub fn spawn_tickers(state: Arc) { pub fn router(state: Arc) -> Router { Router::new() .route("/", get(landing)) + .route("/privacy", get(privacy)) .route("/v0", get(ws_handler)) .route("/v0/stats", get(stats_handler)) .route("/healthz", get(healthz)) @@ -180,8 +181,21 @@ pub fn router(state: Arc) -> Router { static LANDING: LazyLock = LazyLock::new(|| include_str!("landing.html").replace("{{VERSION}}", env!("CARGO_PKG_VERSION"))); -async fn landing() -> Html<&'static str> { - Html(LANDING.as_str()) +async fn landing(State(state): State>) -> Html { + let rows = lock(&state.presence) + .route_list() + .into_iter() + .map(|(id, length)| format!("{id}{length:.0} m")) + .collect::(); + Html(LANDING.replace("{{ROUTES}}", &rows)) +} + +/// What the public server stores, and what it never stores. +static PRIVACY: LazyLock = + LazyLock::new(|| include_str!("privacy.html").replace("{{VERSION}}", env!("CARGO_PKG_VERSION"))); + +async fn privacy() -> Html<&'static str> { + Html(PRIVACY.as_str()) } async fn healthz() -> &'static str { diff --git a/crates/server/tests/ws.rs b/crates/server/tests/ws.rs index 3dab2ed..9be985f 100644 --- a/crates/server/tests/ws.rs +++ b/crates/server/tests/ws.rs @@ -398,4 +398,18 @@ async fn landing_page() { assert!(body.contains("/v0/stats"), "{body}"); assert!(body.contains("https://github.com/OpenBikeNet"), "{body}"); assert!(body.contains(env!("CARGO_PKG_VERSION")), "{body}"); + assert!(body.contains("velodrome-250"), "{body}"); + assert!(body.contains("herne-hill-450"), "{body}"); + assert!(body.contains("/privacy"), "{body}"); +} + +#[tokio::test] +async fn privacy_page() { + let addr = start(test_config()).await; + let (head, body) = http_get(addr, "/privacy").await; + assert!(head.starts_with("HTTP/1.1 200"), "{head}"); + assert!(head.to_lowercase().contains("content-type: text/html"), "{head}"); + assert!(body.contains("IP addresses"), "{body}"); + assert!(body.contains("Rider names"), "{body}"); + assert!(body.contains(env!("CARGO_PKG_VERSION")), "{body}"); }