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