utopia-ia/elffuss-code public
Changesets · Branches · Tags · Compare
| Changeset | 99a5df28cf0fd2ef017eef93d4f67443bc93ae2d4eb08126b3b87584776165ee |
|---|---|
| Author | KikoCis <kikocisneros@gmail.com> · 2026-10-07 17:53 +02:00 |
| Committer | KikoCis <kikocisneros@gmail.com> · 2026-10-07 17:53 +02:00 |
| Parents | 714cbf30ce4e |
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 @@ | ||
| 38 | 38 | catch (e) { reject(e); return; } |
| 39 | 39 | const timeout = setTimeout(() => { try { ws.close(); } catch { /* */ } reject(new Error('tiempo agotado — ¿está el bridge arrancado?')); }, 6000); |
| 40 | 40 | 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.')); }; | |
| 42 | 42 | ws.onclose = () => { connected = false; authed = false; onStatus('disconnected'); }; |
| 43 | 43 | ws.onmessage = e => { |
| 44 | 44 | let m; try { m = JSON.parse(e.data); } catch { return; } |
modified web/js/i18n.js +2 −0
| @@ -116,6 +116,7 @@ | ||
| 116 | 116 | 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.", |
| 117 | 117 | setBridgeDownload: "⬇ Descargar para {os}", |
| 118 | 118 | 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.", | |
| 119 | 120 | setModelRulesName: "Básico (sin modelo)", |
| 120 | 121 | }, |
| 121 | 122 | en: { |
| @@ -228,6 +229,7 @@ | ||
| 228 | 229 | 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.", |
| 229 | 230 | setBridgeDownload: "⬇ Download for {os}", |
| 230 | 231 | 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.", | |
| 231 | 233 | setModelRulesName: "Basic (no model)", |
| 232 | 234 | }, |
| 233 | 235 | }; |
modified web/js/main.js +1 −0
| @@ -764,6 +764,7 @@ | ||
| 764 | 764 | brCard.innerHTML = |
| 765 | 765 | `<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>` + |
| 766 | 766 | `<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>` + | |
| 767 | 768 | `<a class="prov-use" style="text-decoration:none;display:inline-block" href="bridge-dl/${primary}" download>${t('setBridgeDownload',{os:OTHER[primary]})}</a>` + |
| 768 | 769 | `<details style="margin-top:6px"><summary class="muted" style="font-size:.7rem;cursor:pointer">${t('setBridgeOtherOS')}</summary>` + |
| 769 | 770 | 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('') + |