interplane.Get Omega
Read in your language

aienos.com

Source of www.aienos.com, served from my own hardware

Brought by drakestapleton

branch main Branches Tags History

aienos.com / om / agora / test / https-probe.om

82 lines · 2135 bytes Raw Blame History
1note https-probe: one GET through agora-sync's peer transport (sy_burl, sy_tread, sy_hparse: TLS 1.3,
2note chain, dates and host name checked against a PEM trust store). Read only.
3note Usage: https-probe BASE PATH [CA] (CA defaults to /etc/ssl/certs/ca-certificates.crt). BASE takes
4note the peer base grammar ("https://HOST[:PORT]").
5note Prints "status <status line>" and "body <n>". Exit 0 on status 200, 1 usage, 2 a base outside the
6note https grammar, 3 the transport failed (the TLS error is logged as agora-sync logs it), 4 another status.
7note With PATH "-" it only classifies BASE with sy_burl and prints "grammar <0|1|2>" (0 refused, 1 https,
8note 2 loopback http), exit 0; test/net.sh compares that with the server's announce check.
9note Built by test/net.sh from agora-sync.om with its main renamed, so the code under test is the sync's.
10
11text prst "status "
12text prbd "body "
13text prgr "grammar "
14text prdash "-"
15
16note pr_num: "<label><v>" and a newline on stdout
17fn pr_num l view uchar * v ulong to void
18m = new uchar 64 0
19q = ac_cat m 0 l
20q = ac_catu m q v
21ac_say view part m 0 q
22ac_say sylnl
23end
24
25note pr_get: GET pa from the https base b (o from sy_burl) and print the status line and body length
26fn pr_get o edit ulong 8 b view uchar * pa view uchar 128 to int
27raw = new uchar 327680 0
28d = new uchar 262144 0
29n = sy_tread o b pa raw
30if lt n 0
31ret 3
32end
33e = ac_lend view part raw 0 ulong n 0 ulong n
34f = e
35if and gt e 0 eq get raw sub e 1 13
36f = sub e 1
37end
38ac_say prst
39ac_say view part raw 0 f
40ac_say sylnl
41r = sy_hparse view part raw 0 ulong n get o 5 d
42if lt r 0
43ret 4
44end
45pr_num prbd ulong r
46ret 0
47end
48
49fn main to int
50ab = new uchar 512 0
51pa = new uchar 128 0
52o = new ulong 8 0
53if lt ulong argcnt 3
54ret 1
55end
56k = argread 1 ab 0 256
57p = argread 2 pa 0 128
58if or lt k 1 lt p 1
59ret 1
60end
61put gcf 7 len syca
62for j ulong len syca
63put gca j get syca j
64end
65if gt ulong argcnt 3
66c = argread 3 gca 0 256
67if lt c 1
68ret 1
69end
70put gcf 7 ulong c
71end
72g = sy_burl view part ab 0 ulong k o
73if ac_peq view pa 0 ulong p prdash
74pr_num prgr g
75ret 0
76end
77if ne g 1
78ret 2
79end
80put o 4 ulong p
81ret pr_get o view part ab 0 ulong k pa
82end