code wiki / (root) / nx_ng_verify_live.nx

nx_ng_verify_live.nx source

↩ module page · 81 lines · 4807 B

1// nx_ng_verify_live.nx -- verify the PUBLIC audio page is LIVE on nishifamily.com via our OWN sovereign TLS-1.3 2// client, AND that adding it did NOT break the rest of the site (family landing, the /wiki gate, andelinwest). 3// The audio is served as a public hot file (sites.conf docroot) -- the gated sections are matched BEFORE the 4// file-server, so they stay gated. license_tier: ORIGINAL expect_exit: 0 5import "nx_syscalls.nx" 6import "nx_x509_trust_store.nx" 7import "nx_trust_store_load_from_certdata.nx" 8import "nx_https_fetch_follow.nx" 9const K_MAGIC_4194304: i64 = 4194304 10 11func vp(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 12func vpn(v: i64) -> i64 { 13 let b: *u8=sys_mmap(28); var x: i64=v; if x<0 {b[0]=45;sys_write(1,b,1);x=0-x} 14 if x==0 {b[0]=48;sys_write(1,b,1);return 0} 15 var d: i64=0; var y: i64=x; while y>0 {d=d+1;y=y/10} 16 var i: i64=d-1; y=x; while i>=0 {b[i]=(48+(y%10)) as u8; y=y/10; i=i-1} 17 sys_write(1,b,d); return 0 18} 19func contains(buf: *u8, n: i64, needle: *u8) -> i64 { 20 var nl: i64=0; while needle[nl]!=(0 as u8){nl=nl+1} 21 if nl==0 { return 0 } 22 var i: i64=0 23 while i + nl <= n { 24 var j: i64=0; var ok: i64=1 25 while j<nl { if buf[i+j]!=needle[j] { ok=0; j=nl } else { j=j+1 } } 26 if ok==1 { return 1 } 27 i=i+1 28 } 29 return 0 30} 31 32func main() -> i64 { 33 let r: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt" as *u8, 512, K_MAGIC_4194304) 34 if r <= 0 { vp("certdata load failed\n" as *u8); sys_exit(1); return 1 } 35 let store: *TrustStore = r as *TrustStore 36 let cap: i64 = K_MAGIC_4194304 37 let out: *u8 = sys_mmap(cap) 38 let status: *i64 = sys_mmap(8) as *i64 39 var allok: i64 = 1 40 41 // [1] the PLAYER must be LIVE + PUBLIC (no login) at the CLEAN url /listen (no .html) 42 vp("[1] GET https://nishifamily.com/listen (clean URL, player LIVE + public, no login)\n" as *u8) 43 let n1: i64 = nx_https_fetch_follow("https://nishifamily.com/listen" as *u8, store, out, cap, 6, status) 44 let s1: i64 = status[0] 45 var m_player: i64 = 0; var m_audio: i64 = 0; var m_bowl: i64 = 0; var m_login: i64 = 0 46 if n1 > 0 { m_player = contains(out, n1, "New one" as *u8); m_audio = contains(out, n1, "<audio" as *u8); m_bowl = contains(out, n1, "Tibetan Singing Bowl" as *u8); m_login = contains(out, n1, "OPAQUE login" as *u8) } 47 vp(" status=" as *u8); vpn(s1); vp(" bytes=" as *u8); vpn(n1); vp(" player(New one)=" as *u8); vpn(m_player); vp(" <audio=" as *u8); vpn(m_audio); vp(" bowl=" as *u8); vpn(m_bowl); vp(" login-wall=" as *u8); vpn(m_login); vp("\n" as *u8) 48 var c1: i64 = 0; if s1 == 200 { if m_player == 1 { if m_audio == 1 { c1 = 1 } } } 49 if c1 == 0 { allok = 0 } 50 51 // [2] the family landing must still serve (audio must NOT bleed onto /) 52 vp("[2] GET https://nishifamily.com/ (family landing intact, no audio bleed)\n" as *u8) 53 let n2: i64 = nx_https_fetch_follow("https://nishifamily.com/" as *u8, store, out, cap, 6, status) 54 let s2: i64 = status[0] 55 var bleed2: i64 = 0; if n2 > 0 { bleed2 = contains(out, n2, "Tibetan Singing Bowl" as *u8) } 56 vp(" status=" as *u8); vpn(s2); vp(" bytes=" as *u8); vpn(n2); vp(" audio-bleed=" as *u8); vpn(bleed2); vp("\n" as *u8) 57 var c2: i64 = 0; if s2 == 200 { if bleed2 == 0 { c2 = 1 } } 58 if c2 == 0 { allok = 0 } 59 60 // [3] the /wiki gate must stay gated (audio must NOT bleed onto a gated path) 61 vp("[3] GET https://nishifamily.com/wiki/projects (gate intact, no audio bleed)\n" as *u8) 62 let n3: i64 = nx_https_fetch_follow("https://nishifamily.com/wiki/projects" as *u8, store, out, cap, 6, status) 63 let s3: i64 = status[0] 64 var bleed3: i64 = 0; if n3 > 0 { bleed3 = contains(out, n3, "Tibetan Singing Bowl" as *u8) } 65 vp(" status=" as *u8); vpn(s3); vp(" bytes=" as *u8); vpn(n3); vp(" audio-bleed=" as *u8); vpn(bleed3); vp("\n" as *u8) 66 var c3: i64 = 0; if bleed3 == 0 { c3 = 1 } 67 if c3 == 0 { allok = 0 } 68 69 // [4] the other sovereign site (andelinwest.com) must still serve 70 vp("[4] GET https://andelinwest.com/ (other sovereign site intact)\n" as *u8) 71 let n4: i64 = nx_https_fetch_follow("https://andelinwest.com/" as *u8, store, out, cap, 6, status) 72 let s4: i64 = status[0] 73 vp(" status=" as *u8); vpn(s4); vp(" bytes=" as *u8); vpn(n4); vp("\n" as *u8) 74 var c4: i64 = 0; if s4 == 200 { c4 = 1 } 75 if c4 == 0 { allok = 0 } 76 77 vp(" verdict=" as *u8) 78 if allok == 1 { vp("GREEN -- audio LIVE + public at https://nishifamily.com/listen.html; landing + /wiki gate + andelinwest ALL intact (wall not broken)\n" as *u8); sys_exit(0); return 0 } 79 vp("RED -- a check failed above (audio not live, OR something broke); inspect before relying on it\n" as *u8) 80 sys_exit(1); return 1 81}