nx_lib_verify_probe.nx source
↩ module page · 35 lines · 1669 B
1// nx_lib_verify_probe.nx -- END-TO-END LIVE verify of the deploy: fetch the
2// PUBLIC nishifamily.com/research reader page through the real edge (TLS-1.3),
3// proving edge -> nx_http_proxy -> nx_lib_httpd (:8095) -> real taxon works live.
4import "nx_syscalls.nx"
5import "nx_lib_fetch.nx"
6const K_MAGIC_262144: i64 = 262144
7const K_MAGIC_1400: i64 = 1400
8
9func vp_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
10func vp_wr(p: *u8, n: i64) -> i64 { sys_write(1, p, n); return 0 }
11func vp_putn(v: i64) -> i64 {
12 let bb: *u8 = sys_mmap(28); var m: i64 = v
13 if m < 0 { m = 0 - m; sys_write(1, "-" as *u8, 1) }
14 let t: *u8 = sys_mmap(28); var k: i64 = 0
15 if m == 0 { t[0] = 48 as u8; k = 1 }
16 while m > 0 { t[k] = (48 + (m - (m/10)*10)) as u8; m = m / 10; k = k + 1 }
17 var i: i64 = 0; while i < k { bb[i] = t[k - 1 - i]; i = i + 1 } sys_write(1, bb, k); return 0
18}
19
20func main() -> i64 {
21 let store: *TrustStore = nx_lib_fetch_store()
22 if store == 0 as *TrustStore { vp_puts("no CA store\n"); return 1 }
23 let url: *u8 = "https://nishifamily.com:8443/research/?q=Archaea\x00"
24 let cap: i64 = K_MAGIC_262144
25 let buf: *u8 = sys_mmap(cap)
26 vp_puts("GET https://nishifamily.com:8443/research/work/GBIF_1000003 (public edge, sovereign TLS-1.3)...\n")
27 let gc: i64 = nx_lib_fetch(store, url, buf, cap)
28 vp_puts("fetch bytes/err="); vp_putn(gc); vp_puts("\n")
29 if gc < 0 { return 2 }
30 vp_puts("=== PUBLIC response (edge -> proxy -> library) ===\n")
31 var w: i64 = gc; if w > K_MAGIC_1400 { w = K_MAGIC_1400 }
32 vp_wr(buf, w)
33 vp_puts("\n=== end ===\n")
34 return 0
35}