code wiki / _hdl_build / nx_library_gate_handle.nx
nx_library_gate_handle.nx
buildroot/runtime/_hdl_build/nx_library_gate_handle.nx
about
nx_library_gate_handle.nx -- the LOGIN-GATE for /library on the live sites daemon (operator 2026-06-13:
login-gate FIRST, then deploy). A dynamic handler the daemon calls for GET /library (mirrors the
nx_wiki_queue_handle dispatch pattern): extract the OPAQUE session token from the request
"X-Nishi-Session: <hex>" header, validate it (nx_ncs_validate_token, Ed25519), and:
valid -> serve the worldwide scholarly library (knowledge/library.html) as 200 (SERVED=0)
absent/forged/expired -> 302 -> /wiki/login (REDIRECT=1); data NEVER served unauthenticated.
Library (no main) so the daemon imports it + one dispatch line. license_tier: ORIGINAL
dependencies 3 imports · 1 importers
imports: nx_syscalls.nxnx_ed25519_signature.nxnx_no_cookie_session.nx
imported by: nx_library_gate_test.nx
structs
| none |
consts
| 11 | const LG_MAGIC_262144: i64 = 262144 |
| 12 | const LG_MAGIC_262143: i64 = 262143 |
| 14 | const LG_SERVED: i64 = 0 |
| 15 | const LG_REDIRECT: i64 = 1 |
| 16 | const LG_TOKBYTES: i64 = 152 |
functions
| 18 | func lg_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 19 | func lg_contains(hay: *u8, hlen: i64, needle: *u8) -> i64 |
| 24 | func lg_hexval(c: i64) -> i64 called by 1: lg_hexdecode |
| 31 | func lg_hexdecode(hay: *u8, off: i64, hlen: i64, tok: *u8) -> i64 |
| 46 | func lg_app(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){dst[off+i]=s[i];i=i+1} return off+lg_strlen(s) } |
| 47 | func lg_readfile(path: *u8, buf: *u8, cap: i64) -> i64 { let fd: i64=sys_openat_rd(path); if fd<0{return 0} var tot: i64=0; var r: i64=1; while r>0 { let d: *u8=((buf as i64)+tot) as *u8; r=sys_read(fd,d,cap-tot); if r>0{tot=tot+r} } sys_close(fd); return tot } |
| 48 | func lg_wn(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;k=1} while m>0{t[k]=48+(m%10);m=m/10;k=k+1} var i: i64=0; while i<k{dst[off+i]=t[k-1-i];i=i+1} return off+k } |
| 52 | func nx_library_gate_handle(req: *u8, reqn: i64, server_pub_32: *u8, now: i64, libpath: *u8, out: *u8, cap: i64, out_n: *i64) -> i64 |