code wiki / _hdl_build / nx_lan_signup_routes.nx
nx_lan_signup_routes.nx
buildroot/runtime/_hdl_build/nx_lan_signup_routes.nx
about
nx_lan_signup_routes.nx -- the SHARED router for the family signup + HR admin surface (no main, no sockets), so
BOTH the daemon (nx_lan_signup_daemon) and a referee (nx_lan_signup_socket_gate) drive ONE table (rule #15 DRY,
mirroring nx_opaque_login_routes / olg_route). lsd_route builds + writes the response on cfd given the request,
the real peer IP (from accept()), and the OPAQUE ctx + HR store. Routes + gating documented on the daemon.
dependencies 6 imports · 2 importers
imports: nx_opaque_login.nxnx_lan_signup.nxnx_hr_admin.nxnx_hr_admin_page.nxnx_hr_audit.nxnx_http_form.nx
imported by: nx_lan_signup_daemon.nxnx_lan_signup_socket_gate.nx
structs
| none |
consts
| 11 | const LSD_MAGIC_524288: i64 = 524288 |
| 12 | const LSD_MAGIC_262144: i64 = 262144 |
| 14 | const LSD_REALM: *u8 = "nishi_site_admin" as *u8 |
| 15 | const LSD_REALM_N: i64 = 16 |
| 16 | const LSD_FAMILY: *u8 = "andelin" as *u8 |
| 61 | const LSD_PAGE: *u8 = "<!doctype html><html><head><meta charset=utf-8><meta name=viewport content=\"width=device-width,initial-scale=1\"><title>Nishi Family — sign up</title><style>body{font-family:system-ui,sans-serif;max-width:460px;margin:6vh auto;padding:0 18px;color:#16202e}h1{font-size:1.25rem}input{width:100%;padding:9px;margin:5px 0;box-sizing:border-box;border:1px solid #b9c2d6;border-radius:5px}button{padding:9px 16px;background:#0b2545;color:#fff;border:0;border-radius:5px;cursor:pointer}#m{margin:14px 0;padding:12px;background:#f1f4fa;border-left:3px solid #0b2545;word-break:break-all;min-height:1.2em}</style></head><body><h1>Nishi Family — sign up</h1><p style=\"color:#667;font-size:.9rem\">Home-network only, by invitation. Use the handle elderwesto gave you (your first name) and choose a passphrase the server never sees (full OPAQUE).</p><div id=m>Enter your invited handle + a passphrase.</div><input id=h placeholder=\"handle (your first name)\"><input id=p type=password placeholder=\"passphrase\"><button onclick=reg()>Sign up</button><details style=\"margin-top:16px\"><summary style=\"cursor:pointer;color:#0b2545\">Forgot your passphrase?</summary><p style=\"color:#667;font-size:.85rem\">Enter your handle, your 24-word recovery phrase, and a new passphrase.</p><input id=rh placeholder=\"handle\"><input id=rm placeholder=\"recovery phrase (24 words)\"><input id=rp2 type=password placeholder=\"new passphrase\"><button onclick=rec()>Recover</button></details><script>function M(t){document.getElementById('m').textContent=t}async function reg(){M('Creating your account\\u2026 (a moment)');try{var r=await fetch('/register',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:'handle='+encodeURIComponent(document.getElementById('h').value)+'&pw='+encodeURIComponent(document.getElementById('p').value)});var j={};try{j=await r.json()}catch(e){}if(r.ok){M('Welcome! SAVE THIS RECOVERY PHRASE: '+j.mnemonic)}else{M('Cannot sign up ('+r.status+'): '+(j.error||'denied'))}}catch(e){M('network: '+e)}}async function rec(){M('Recovering\\u2026 (a moment)');try{var r=await fetch('/recover',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:'handle='+encodeURIComponent(document.getElementById('rh').value)+'&mn='+encodeURIComponent(document.getElementById('rm').value)+'&pw='+encodeURIComponent(document.getElementById('rp2').value)});var j={};try{j=await r.json()}catch(e){}if(r.ok){M('Recovered! Your NEW recovery phrase (save it): '+j.mnemonic)}else{M('Recovery failed ('+r.status+'): '+(j.error||'denied'))}}catch(e){M('network: '+e)}}</script></body></html>" as *u8 |
functions
| 18 | func lsd_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 19 | func lsd_atoi(s: *u8) -> i64 { var v: i64=0; var i: i64=0; while s[i]!=(0 as u8){ let c: i64=s[i] as i64; if c<48{return v} if c>57{return v} v=v*10+(c-48); i=i+1 } return v } |
| 20 | func lsd_starts(buf: *u8, n: i64, pre: *u8) -> i64 { var i: i64=0; while pre[i]!=(0 as u8){ if i>=n {return 0} if buf[i]!=pre[i]{return 0} i=i+1 } return 1 } called by 1: lsd_route |
| 21 | func lsd_find(buf: *u8, n: i64, needle: *u8, nl: i64) -> i64 { if nl==0 {return 0} var i: i64=0; while i+nl<=n { var j: i64=0; var ok: i64=1; while j<nl { if buf[i+j]!=needle[j]{ok=0;j=nl} else {j=j+1} } if ok==1 {return i} i=i+1 } return 0-1 } |
| 22 | func lsd_cat(dst: *u8, off: i64, s: *u8) -> i64 { var o: i64=off; var i: i64=0; while s[i]!=(0 as u8){dst[o]=s[i]; o=o+1; i=i+1} return o } |
| 23 | func lsd_catb(dst: *u8, off: i64, src: *u8, n: i64) -> i64 { var o: i64=off; var i: i64=0; while i<n {dst[o]=src[i]; o=o+1; i=i+1} return o } |
| 24 | func lsd_itoa(dst: *u8, off: i64, v: i64) -> i64 { let t: *u8=sys_mmap(28); var m: i64=v; var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var o: i64=off; var q: i64=k-1; while q>=0{dst[o]=t[q];o=o+1;q=q-1} return o } called by 1: lsd_send |
| 25 | func lsd_hex(dst: *u8, off: i64, src: *u8, n: i64) -> i64 { let hx: *u8="0123456789abcdef" as *u8; var o: i64=off; var i: i64=0; while i<n { let c: i64=(src[i] as i64)&0xff; dst[o]=hx[(c>>4)&15]; dst[o+1]=hx[c&15]; o=o+2; i=i+1 } return o } called by 1: lsd_caller_super |
| 26 | func lsd_hdr_val(req: *u8, hend: i64, name: *u8, nl: i64, out: *u8, cap: i64) -> i64 |
| 35 | func lsd_send(cfd: i64, status: *u8, ctype: *u8, body: *u8, blen: i64) -> i64 |
| 44 | func lsd_send303(cfd: i64, loc: *u8) -> i64 |
| 51 | func lsd_caller_super(ctx: *NxAuthContext, req: *u8, hend: i64, now: i64, hr_store: *u8) -> i64 |
| 66 | func lsd_route(ctx: *NxAuthContext, realm: *u8, realm_n: i64, ip4: *u8, req: *u8, rn: i64, hend: i64, body: *u8, bn: i64, now: i64, hr_store: *u8, cfd: i64) -> i64 called by 2: mainserve_one calls 18: lsd_startsnx_http_form_get_fieldls_signup_allowedolg_registerhra_claimlsd_cat+12 |