nx_iot_dashboard_gate.nx source
↩ module page · 26 lines · 1363 B
1// nx_iot_dashboard_gate.nx -- proves the sovereign Nishi-browser IoT dashboard:
2// zero <script> (works in any browser) · valid HTML · shows the real IoT-VLAN devices ·
3// carries the LAN-resilience promise ("available with internet down") · online status badge ·
4// real control forms POSTing to the local hub (no cloud). expect_exit: 0 license_tier: ORIGINAL
5import "nx_iot_dashboard.nx"
6
7func dg_has(h: *u8, n: i64, pat: *u8) -> i64 {
8 var pl: i64 = 0
9 while pat[pl] != (0 as u8) { pl = pl + 1 }
10 return cp_find(h, n, pat, pl)
11}
12
13func main() -> i64 {
14 let h: *u8 = sys_mmap(262144)
15 let n: i64 = db_render(h)
16 if n <= 0 { return 1 }
17 if dg_has(h, n, "<script" as *u8) != (0 - 1) { return 2 } // ZERO JavaScript
18 if dg_has(h, n, "<!doctype html>" as *u8) < 0 { return 3 }
19 if dg_has(h, n, "</html>" as *u8) < 0 { return 4 }
20 if dg_has(h, n, "192.168.10.166" as *u8) < 0 { return 5 } // real device 1
21 if dg_has(h, n, "192.168.10.242" as *u8) < 0 { return 6 } // real device 2
22 if dg_has(h, n, "available with internet down" as *u8) < 0 { return 7 } // the resilience promise
23 if dg_has(h, n, "#3fb950" as *u8) < 0 { return 8 } // online badge
24 if dg_has(h, n, "action=\"/home/cmd\"" as *u8) < 0 { return 9 } // real controls -> local hub
25 return 0
26}