conn: add port request

Also make peel requests respond with $unit.
This commit is contained in:
Jōshin 2022-02-05 09:05:37 -06:00
parent f47b77faae
commit 3e3f9c553c
No known key found for this signature in database
GPG Key ID: A8BE5A9A521639D0

View File

@ -488,12 +488,12 @@ _conn_moor_poke(void* ptr_v, c3_d len_d, c3_y* byt_y)
case c3__peel: { case c3__peel: {
u3_noun i_dat, t_dat; u3_noun i_dat, t_dat;
if ( (c3n == u3r_cell(dat, &i_dat, &t_dat)) || if ( (c3n == u3r_cell(dat, &i_dat, &t_dat)) ) {
(u3_nul != t_dat) )
{
can_u->mor_u.bal_f(can_u, -5, "peel-bad"); can_u->mor_u.bal_f(can_u, -5, "peel-bad");
} }
else { else {
// TODO require u3_nul == t_dat where appropriate
//
switch (i_dat) { switch (i_dat) {
default: { default: {
can_u->mor_u.bal_f(can_u, -6, "peel-unknown"); can_u->mor_u.bal_f(can_u, -6, "peel-unknown");
@ -502,19 +502,51 @@ _conn_moor_poke(void* ptr_v, c3_d len_d, c3_y* byt_y)
// simple health check. // simple health check.
// //
case c3__live: { case c3__live: {
_conn_send_noun(can_u, u3nc(u3k(rid), c3y)); _conn_send_noun(can_u, u3nt(u3k(rid), u3_nul, c3y));
break; break;
} }
// say whether the %khan vane is working. // say whether the %khan vane is working.
// //
case c3__khan: { case c3__khan: {
_conn_send_noun(can_u, u3nc(u3k(rid), con_u->kan_o)); _conn_send_noun(can_u, u3nt(u3k(rid), u3_nul, con_u->kan_o));
break; break;
} }
// get vere version. // get vere version.
// //
case c3__v: { case c3__v: {
_conn_send_noun(can_u, u3nc(u3k(rid), u3i_string(URBIT_VERSION))); _conn_send_noun(can_u, u3nt(u3k(rid), u3_nul,
u3i_string(URBIT_VERSION)));
break;
}
// get port.
//
case c3__port: {
u3_noun it_dat, tt_dat;
if ( (c3n == u3r_cell(t_dat, &it_dat, &tt_dat))
|| (u3_nul != tt_dat) )
{
can_u->mor_u.bal_f(can_u, -8, "port-bad");
}
else {
switch (it_dat) {
default: {
can_u->mor_u.bal_f(can_u, -9, "port-unknown");
break;
}
case c3__ames: {
_conn_send_noun(can_u, u3nt(u3k(rid), u3_nul,
u3_Host.ops_u.por_s));
break;
}
case c3__http: {
// TODO get http configuration
//
_conn_send_noun(can_u, u3nc(u3k(rid), u3_nul));
break;
}
}
}
break; break;
} }
// TODO: fill in rest of %peel namespace. // TODO: fill in rest of %peel namespace.