Elffuss BraidHub

utopia-ia/elffuss-code public

Tell bridge users that older bridges refuse the new address

Bridges downloaded before 1.1.1 accept only elffuss-code.utopiaia.com.
Once the old hosts redirect to code.elffuss.com, such a bridge answers
403: the background probe stays silent and Connect fails with a generic
"is it running?" message, so the user never learns to download again.

The settings card now says, next to the download link, that a bridge
that no longer connects has to be downloaded again (1.1.1), in Spanish
and English. The connect error says the same.

bridge/main_test.go is a table test over the accepted origins (the new
name, the two previous ones, localhost dev; nothing by suffix) and over
the loopback Host check.
Changeset99a5df28cf0fd2ef017eef93d4f67443bc93ae2d4eb08126b3b87584776165ee
AuthorKikoCis <kikocisneros@gmail.com> · 2026-10-07 17:53 +02:00
CommitterKikoCis <kikocisneros@gmail.com> · 2026-10-07 17:53 +02:00
Parents714cbf30ce4e

Browse the files at this changeset

4 files changed

added bridge/main_test.go +64 −0
@@ -0,0 +1,64 @@
1+package main
2+
3+import "testing"
4+
5+// Los orígenes son exactos: el nombre actual, los dos anteriores mientras dure
6+// el cambio de dominio y localhost de desarrollo. Nada por sufijo.
7+func TestAllowedOrigins(t *testing.T) {
8+ cases := []struct {
9+ origin string
10+ want bool
11+ }{
12+ {"https://code.elffuss.com", true},
13+ {"https://code.elffuss.utopiaia.com", true},
14+ {"https://elffuss-code.utopiaia.com", true},
15+ {"http://localhost:8799", true},
16+ {"http://127.0.0.1:8799", true},
17+
18+ {"", false},
19+ {"null", false},
20+ {"http://code.elffuss.com", false},
21+ {"https://code.elffuss.com:443", false},
22+ {"https://code.elffuss.com/", false},
23+ {"https://claw.elffuss.com", false},
24+ {"https://elffuss.com", false},
25+ {"https://git.elffuss.com", false},
26+ {"https://evil.code.elffuss.com", false},
27+ {"https://code.elffuss.com.evil.net", false},
28+ {"https://claw.elffuss.utopiaia.com", false},
29+ {"https://elffuss-claw.utopiaia.com", false},
30+ {"https://utopiaia.com", false},
31+ {"https://otra.utopiaia.com", false},
32+ {"http://localhost:8642", false},
33+ {"http://localhost", false},
34+ }
35+ for _, c := range cases {
36+ if got := allowedOrigins[c.origin]; got != c.want {
37+ t.Errorf("allowedOrigins[%q] = %v, want %v", c.origin, got, c.want)
38+ }
39+ }
40+}
41+
42+func TestHostIsLoopback(t *testing.T) {
43+ cases := []struct {
44+ host string
45+ want bool
46+ }{
47+ {"127.0.0.1:8765", true},
48+ {"localhost:8765", true},
49+ {"localhost", true},
50+ {"[::1]:8765", true},
51+ {"127.0.0.2:8765", true},
52+
53+ {"code.elffuss.com", false},
54+ {"evil.example:8765", false},
55+ {"0.0.0.0:8765", false},
56+ {"192.168.1.10:8765", false},
57+ {"", false},
58+ }
59+ for _, c := range cases {
60+ if got := hostIsLoopback(c.host); got != c.want {
61+ t.Errorf("hostIsLoopback(%q) = %v, want %v", c.host, got, c.want)
62+ }
63+ }
64+}
modified web/js/bridge.js +1 −1
@@ -38,7 +38,7 @@
3838 catch (e) { reject(e); return; }
3939 const timeout = setTimeout(() => { try { ws.close(); } catch { /* */ } reject(new Error('tiempo agotado — ¿está el bridge arrancado?')); }, 6000);
4040 ws.onopen = () => ws.send(JSON.stringify({ type: 'auth', token }));
41- ws.onerror = () => { clearTimeout(timeout); connected = false; authed = false; onStatus('error'); reject(new Error('no pude conectar — ¿está el bridge arrancado en este puerto?')); };
41+ ws.onerror = () => { clearTimeout(timeout); connected = false; authed = false; onStatus('error'); reject(new Error('no pude conectar — ¿está el bridge arrancado en este puerto? Si lo descargaste antes de la versión 1.1.1, descárgalo otra vez: los anteriores no aceptan la dirección nueva de Elffuss Code.')); };
4242 ws.onclose = () => { connected = false; authed = false; onStatus('disconnected'); };
4343 ws.onmessage = e => {
4444 let m; try { m = JSON.parse(e.data); } catch { return; }
modified web/js/i18n.js +2 −0
@@ -116,6 +116,7 @@
116116 setBridgeDesc: "Un pequeño programa que TÚ ejecutas en tu ordenador — le da a la elfa ejecución real (node, npm, python…) sin salir de tu máquina. Nada se instala en el navegador.",
117117 setBridgeDownload: "⬇ Descargar para {os}",
118118 setBridgeOtherOS: "otro sistema operativo",
119+ setBridgeOld: "¿Ya tenías un bridge y ahora no conecta? Descárgalo otra vez (versión 1.1.1): los anteriores no aceptan la dirección nueva de Elffuss Code.",
119120 setModelRulesName: "Básico (sin modelo)",
120121 },
121122 en: {
@@ -228,6 +229,7 @@
228229 setBridgeDesc: "A small program that YOU run on your computer — it gives the elf real execution (node, npm, python…) without leaving your machine. Nothing is installed in the browser.",
229230 setBridgeDownload: "⬇ Download for {os}",
230231 setBridgeOtherOS: "another operating system",
232+ setBridgeOld: "Already had a bridge and now it won't connect? Download it again (version 1.1.1): older ones don't accept Elffuss Code's new address.",
231233 setModelRulesName: "Basic (no model)",
232234 },
233235 };
modified web/js/main.js +1 −0
@@ -764,6 +764,7 @@
764764 brCard.innerHTML =
765765 `<div class="prov-head"><span id="br-dot" class="dot off"></span><b>Bridge local</b><span id="br-status" class="muted" style="margin-left:auto;font-size:.72rem">desconectado</span></div>` +
766766 `<p class="muted" style="font-size:.72rem;margin:6px 0">${t('setBridgeDesc')}</p>` +
767+ `<p class="muted" style="font-size:.7rem;margin:0 0 6px">${t('setBridgeOld')}</p>` +
767768 `<a class="prov-use" style="text-decoration:none;display:inline-block" href="bridge-dl/${primary}" download>${t('setBridgeDownload',{os:OTHER[primary]})}</a>` +
768769 `<details style="margin-top:6px"><summary class="muted" style="font-size:.7rem;cursor:pointer">${t('setBridgeOtherOS')}</summary>` +
769770 Object.entries(OTHER).filter(([f]) => f !== primary).map(([f, label]) => `<div><a href="bridge-dl/${f}" download style="color:var(--accent2);font-size:.72rem">${label}</a></div>`).join('') +