From c71f41b2b18bab4aecd0c7095858e1cecc32ffa2 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 21 Mar 2019 21:38:47 -0700 Subject: [PATCH 1/3] [CI] updates pinned arvo commit --- .travis/pin-arvo-commit.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/pin-arvo-commit.txt b/.travis/pin-arvo-commit.txt index f0cd66fa3..27cc5175e 100644 --- a/.travis/pin-arvo-commit.txt +++ b/.travis/pin-arvo-commit.txt @@ -1 +1 @@ -e98c379405dc99506ae43392c4a019359e676e8a +e35c639b161799faad2fb55cde89c150e68b804f From d0401f0034e348ec1db498f2c7884194d99b6de4 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 21 Mar 2019 21:37:43 -0700 Subject: [PATCH 2/3] restores tcp proxy (by sending notifications directly over %ames) --- include/c/motes.h | 2 ++ include/vere/vere.h | 2 +- vere/http.c | 46 ++++++++++++++++++++++++--------------------- vere/reck.c | 33 ++++++++++++++++++++++++-------- 4 files changed, 53 insertions(+), 30 deletions(-) diff --git a/include/c/motes.h b/include/c/motes.h index b7b0430a0..0c5a4bd42 100644 --- a/include/c/motes.h +++ b/include/c/motes.h @@ -1192,6 +1192,7 @@ # define c3__wail c3_s4('w','a','i','l') # define c3__wake c3_s4('w','a','k','e') # define c3__wamp c3_s4('w','a','m','p') +# define c3__want c3_s4('w','a','n','t') # define c3__warm c3_s4('w','a','r','m') # define c3__warn c3_s4('w','a','r','n') # define c3__warx c3_s4('w','a','r','x') @@ -1213,6 +1214,7 @@ # define c3__with c3_s4('w','i','t','h') # define c3__wnut c3_s4('w','n','u','t') # define c3__wood c3_s4('w','o','o','d') +# define c3__woot c3_s4('w','o','o','t') # define c3__work c3_s4('w','o','r','k') # define c3__wost c3_s4('w','o','s','t') # define c3__wrap c3_s4('w','r','a','p') diff --git a/include/vere/vere.h b/include/vere/vere.h index 931b1fa2a..8ef1b71ef 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -1058,7 +1058,7 @@ /* u3_http_ef_that: send %that effect to http. */ void - u3_http_ef_that(u3_noun tat); + u3_http_ef_that(u3_noun sip, u3_noun tat); /* u3_http_ef_http_server(): dispatch an %http-server effect from %light. */ diff --git a/vere/http.c b/vere/http.c index 4376a6d1b..5b30a41f9 100644 --- a/vere/http.c +++ b/vere/http.c @@ -2583,7 +2583,7 @@ _proxy_ward_timer_cb(uv_timer_t* tim_u) static void _proxy_ward_plan(u3_ward* rev_u) { - u3_noun non; + u3_noun non, cad; { c3_w* non_w = c3_malloc(64); @@ -2600,17 +2600,19 @@ _proxy_ward_plan(u3_ward* rev_u) rev_u->non_u = uv_buf_init((c3_c*)non_w, len_w); } - // TODO: all this forwarding stuff doesn't work with %light/http-server. - - // XX confirm duct - u3_noun pax = u3nq(u3_blip, c3__http, c3__prox, - u3nc(u3k(u3A->sen), u3_nul)); + { + u3_noun who = u3i_chubs(2, rev_u->who_d); + u3_noun cha = u3nq(c3__a, c3__give, c3__prox, u3_nul); + u3_noun dat = u3nc(c3__that, u3nt(rev_u->por_s, + u3k(rev_u->con_u->sec), + non)); - u3_noun wis = u3nc(c3__wise, u3nq(u3i_chubs(2, rev_u->who_d), - rev_u->por_s, - u3k(rev_u->con_u->sec), - non)); - u3v_plan(pax, wis); + cad = u3nq(c3__want, who, cha, dat); + } + + // XX s/b c3__ames? + // + u3v_plan(u3nt(u3_blip, c3__newt, u3_nul), cad); } /* _proxy_ward_start(): start ward (ship-specific listener). @@ -3163,18 +3165,19 @@ _proxy_serv_start(u3_prox* lis_u) /* u3_http_ef_that(): reverse proxy requested connection notification. */ void -u3_http_ef_that(u3_noun tat) +u3_http_ef_that(u3_noun sip, u3_noun tat) { - u3_noun sip, por, sec, non; + u3_noun por, sec, non; - if ( ( c3n == u3r_qual(tat, &sip, &por, &sec, &non) ) || - ( c3n == u3ud(sip) ) || - ( c3n == u3a_is_cat(por) ) || - !( c3y == sec || c3n == sec ) || - ( c3n == u3ud(non) ) ) { - uL(fprintf(uH, "http: that: invalid card\n")); - } - else { + u3x_trel(tat, &por, &sec, &non); + c3_assert( c3y == u3a_is_cat(por) ); + c3_assert( c3y == sec || c3n == sec ); + c3_assert( c3y == u3ud(non) ); + + // XX sip s/b validated -- could be *any* ship + // + + { u3_http* htp_u; u3_warc* cli_u; @@ -3207,5 +3210,6 @@ u3_http_ef_that(u3_noun tat) } } + u3z(sip); u3z(tat); } diff --git a/vere/reck.c b/vere/reck.c index 629c66fae..80a54ec24 100644 --- a/vere/reck.c +++ b/vere/reck.c @@ -152,14 +152,6 @@ _reck_kick_http(u3_noun pox, return c3y; } - case c3__that: p_fav = u3t(fav); - { - u3_http_ef_that(u3k(p_fav)); - - u3z(pox); u3z(fav); - return c3y; - } - case c3__thus: p_fav = u3h(u3t(fav)); q_fav = u3t(u3t(fav)); { u3_cttp_ef_thus(u3r_word(0, p_fav), u3k(q_fav)); @@ -230,6 +222,7 @@ _reck_kick_newt(u3_noun pox, u3_noun fav) { switch ( u3h(fav) ) { default: break; + case c3__send: { u3_noun lan = u3k(u3h(u3t(fav))); u3_noun pac = u3k(u3t(u3t(fav))); @@ -242,7 +235,31 @@ _reck_kick_newt(u3_noun pox, u3_noun fav) u3_ames_ef_turf(u3k(u3t(fav))); u3z(pox); u3z(fav); return c3y; } break; + + case c3__west: { + u3_noun who, cha, dat; + u3x_trel(u3t(fav), &who, &cha, &dat); + + // XX route by cha path? + // s/b //give/prox + // + switch ( u3h(dat) ) { + default: break; + + case c3__that: { + u3_http_ef_that(u3k(who), u3k(u3t(dat))); + u3z(pox); u3z(fav); return c3y; + } + } + } + + case c3__woot: { + // XX print tang if nack? + // + u3z(pox); u3z(fav); return c3y; + } } + u3z(pox); u3z(fav); return c3n; } From eb0bd01dc400204c881505dc9ec9e960bbe2b9d8 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 21 Mar 2019 22:25:01 -0700 Subject: [PATCH 3/3] removes obsolete http effect routing and handlers --- include/vere/vere.h | 24 +-------- vere/cttp.c | 125 ++------------------------------------------ vere/http.c | 45 ---------------- vere/reck.c | 43 --------------- 4 files changed, 6 insertions(+), 231 deletions(-) diff --git a/include/vere/vere.h b/include/vere/vere.h index 8ef1b71ef..0b678481f 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -1068,25 +1068,6 @@ c3_l seq_l, u3_noun cad); - /* u3_http_ef_thou(): send %thou effect to http. - */ - void - u3_http_ef_thou(c3_l sev_l, - c3_l coq_l, - c3_l seq_l, - u3_noun rep); - - /* u3_cttp_ef_thus(): send %thus effect to cttp. - */ - void - u3_cttp_ef_thus(c3_l num_l, - u3_noun req); - - /* u3_cttp_ef_http_client(): send %http-client effect to cttp. - */ - void - u3_cttp_ef_http_client(u3_noun fav); - /* u3_http_ef_bake(): create new http server. */ void @@ -1197,11 +1178,10 @@ /** HTTP client. **/ - /* u3_cttp_ef_thus(): send %thus effect to cttp. + /* u3_cttp_ef_http_client(): send %http-client effect to cttp. */ void - u3_cttp_ef_thus(c3_l num_l, - u3_noun req); + u3_cttp_ef_http_client(u3_noun fav); /* u3_cttp_ef_back(): initialization event on restart. */ diff --git a/vere/cttp.c b/vere/cttp.c index 19ec16fe4..9e8e78f11 100644 --- a/vere/cttp.c +++ b/vere/cttp.c @@ -208,36 +208,6 @@ _cttp_hed_new(u3_atom nam, u3_atom val) return hed_u; } -// XX vv similar to _http_heds_from_noun -/* _cttp_heds_math(): create headers from +math -*/ -static u3_hhed* -_cttp_heds_math(u3_noun mah) -{ - u3_noun hed = u3kdi_tap(mah); - u3_noun deh = hed; - - u3_hhed* hed_u = 0; - - while ( u3_nul != hed ) { - u3_noun nam = u3h(u3h(hed)); - u3_noun lit = u3t(u3h(hed)); - - while ( u3_nul != lit ) { - u3_hhed* nex_u = _cttp_hed_new(nam, u3h(lit)); - nex_u->nex_u = hed_u; - - hed_u = nex_u; - lit = u3t(lit); - } - - hed = u3t(hed); - } - - u3z(deh); - return hed_u; -} - // XX deduplicate with _http_heds_from_noun /* _cttp_heds_from_noun(): convert (list (pair @t @t)) to u3_hhed */ @@ -559,14 +529,14 @@ _cttp_creq_free(u3_creq* ceq_u) free(ceq_u); } -/* _cttp_creq_new_from_request(): create a request from an +http-request +/* _cttp_creq_new(): create a u3_creq from an +http-request * * If we were rewriting all of this from scratch, this isn't how we'd do it. * - * We start with the + * We start with the (?? - JB) */ static u3_creq* -_cttp_creq_new_from_request(c3_l num_l, u3_noun hes) +_cttp_creq_new(c3_l num_l, u3_noun hes) { u3_creq* ceq_u = c3_calloc(sizeof(*ceq_u)); @@ -612,8 +582,6 @@ _cttp_creq_new_from_request(c3_l num_l, u3_noun hes) ceq_u->met_c = u3r_string(method); ceq_u->url_c = _cttp_creq_url(u3k(pul)); - // TODO: mah is a semiparsed header format, which is not what we were passed in. - /* ceq_u->hed_u = _cttp_heds_math(u3k(mah)); */ ceq_u->hed_u = _cttp_heds_from_noun(u3k(headers)); if ( u3_nul != body ) { @@ -628,57 +596,6 @@ _cttp_creq_new_from_request(c3_l num_l, u3_noun hes) return ceq_u; } -/* _cttp_creq_new(): create a request from a +hiss noun -** -** XX obsolete, remove -*/ -static u3_creq* -_cttp_creq_new(c3_l num_l, u3_noun hes) -{ - u3_creq* ceq_u = c3_calloc(sizeof(*ceq_u)); - - u3_noun pul = u3h(hes); // +purl - u3_noun hat = u3h(pul); // +hart - u3_noun sec = u3h(hat); - u3_noun por = u3h(u3t(hat)); - u3_noun hot = u3t(u3t(hat)); // +host - u3_noun moh = u3t(hes); // +moth - u3_noun met = u3h(moh); // +meth - u3_noun mah = u3h(u3t(moh)); // +math - u3_noun bod = u3t(u3t(moh)); - - ceq_u->sat_e = u3_csat_init; - ceq_u->num_l = num_l; - ceq_u->sec = sec; - - if ( c3y == u3h(hot) ) { - ceq_u->hot_c = _cttp_creq_host(u3k(u3t(hot))); - } else { - ceq_u->ipf_w = u3r_word(0, u3t(hot)); - ceq_u->ipf_c = _cttp_creq_ip(ceq_u->ipf_w); - } - - if ( u3_nul != por ) { - ceq_u->por_s = u3t(por); - ceq_u->por_c = _cttp_creq_port(ceq_u->por_s); - } - - // XX should be capitalized - // - ceq_u->met_c = u3r_string(met); - ceq_u->url_c = _cttp_creq_url(u3k(pul)); - ceq_u->hed_u = _cttp_heds_math(u3k(mah)); - - if ( u3_nul != bod ) { - ceq_u->bod_u = _cttp_bod_from_octs(u3k(u3t(bod))); - } - - _cttp_creq_link(ceq_u); - - u3z(hes); - return ceq_u; -} - /* _cttp_creq_fire_body(): attach body to request buffers. */ static void @@ -781,16 +698,6 @@ _cttp_creq_quit(u3_creq* ceq_u) _cttp_creq_free(ceq_u); } -/* /\* _cttp_httr(): dispatch http response to %eyre */ -/* *\/ */ -/* static void */ -/* _cttp_httr(c3_l num_l, c3_w sas_w, u3_noun mes, u3_noun uct) */ -/* { */ -/* u3_noun htr = u3nt(sas_w, mes, uct); */ -/* u3_noun pox = u3nt(u3_blip, c3__http, u3_nul); */ -/* u3v_plan(pox, u3nt(c3__they, num_l, htr)); */ -/* } */ - static void _cttp_http_client_receive(c3_l num_l, c3_w sas_w, u3_noun mes, u3_noun uct) { @@ -818,7 +725,6 @@ _cttp_creq_fail(u3_creq* ceq_u, const c3_c* err_c) uL(fprintf(uH, "http: fail (%d, %d): %s\r\n", ceq_u->num_l, cod_w, err_c)); // XX include err_c as response body? - /* _cttp_httr(ceq_u->num_l, cod_w, u3_nul, u3_nul); */ _cttp_http_client_receive(ceq_u->num_l, cod_w, u3_nul, u3_nul); _cttp_creq_free(ceq_u); } @@ -830,7 +736,6 @@ _cttp_creq_respond(u3_creq* ceq_u) { u3_cres* res_u = ceq_u->res_u; - /* _cttp_httr(ceq_u->num_l, res_u->sas_w, res_u->hed, */ _cttp_http_client_receive(ceq_u->num_l, res_u->sas_w, res_u->hed, ( !res_u->bod_u ) ? u3_nul : u3nc(u3_nul, _cttp_bods_to_octs(res_u->bod_u))); @@ -1058,28 +963,6 @@ _cttp_init_h2o() return ctx_u; }; -/* u3_cttp_ef_thus(): send %thus effect (outgoing request) to cttp. -*/ -void -u3_cttp_ef_thus(c3_l num_l, - u3_noun cuq) -{ - u3_creq* ceq_u; - - if ( u3_nul == cuq ) { - ceq_u =_cttp_creq_find(num_l); - - if ( ceq_u ) { - _cttp_creq_quit(ceq_u); - } - } - else { - ceq_u = _cttp_creq_new(num_l, u3k(u3t(cuq))); - _cttp_creq_start(ceq_u); - } - u3z(cuq); -} - /* u3_cttp_ef_http_client(): send an %http-client (outgoing request) to cttp. */ void @@ -1091,7 +974,7 @@ u3_cttp_ef_http_client(u3_noun fav) u3_noun p_fav, q_fav; u3x_cell(u3t(fav), &p_fav, &q_fav); - ceq_u = _cttp_creq_new_from_request(u3r_word(0, p_fav), u3k(q_fav)); + ceq_u = _cttp_creq_new(u3r_word(0, p_fav), u3k(q_fav)); if ( ceq_u ) { _cttp_creq_start(ceq_u); diff --git a/vere/http.c b/vere/http.c index 5b30a41f9..0264db544 100644 --- a/vere/http.c +++ b/vere/http.c @@ -1522,51 +1522,6 @@ u3_http_ef_bake(void) u3v_plan(pax, u3nc(c3__born, ipf)); } -/* u3_http_ef_thou(): send %thou from %eyre as http response. -*/ -void -u3_http_ef_thou(c3_l sev_l, - c3_l coq_l, - c3_l seq_l, - u3_noun rep) -{ - u3_http* htp_u; - u3_hcon* hon_u; - u3_hreq* req_u; - c3_w bug_w = u3C.wag_w & u3o_verbose; - - if ( !(htp_u = _http_serv_find(sev_l)) ) { - if ( bug_w ) { - uL(fprintf(uH, "http: server not found: %x\r\n", sev_l)); - } - } - else if ( !(hon_u = _http_conn_find(htp_u, coq_l)) ) { - if ( bug_w ) { - uL(fprintf(uH, "http: connection not found: %x/%d\r\n", sev_l, coq_l)); - } - } - else if ( !(req_u = _http_req_find(hon_u, seq_l)) ) { - if ( bug_w ) { - uL(fprintf(uH, "http: request not found: %x/%d/%d\r\n", - sev_l, coq_l, seq_l)); - } - } - else { - /* u3_noun p_rep, q_rep, r_rep; */ - - fprintf(stderr, "Old %%thou not used anymore\n"); - - /* if ( c3n == u3r_trel(rep, &p_rep, &q_rep, &r_rep) ) { */ - /* uL(fprintf(uH, "http: strange response\n")); */ - /* } */ - /* else { */ - /* _http_req_respond(req_u, u3k(p_rep), u3k(q_rep), u3k(r_rep)); */ - /* } */ - } - - u3z(rep); -} - static u3_hreq* _http_search_req(c3_l sev_l, c3_l coq_l, diff --git a/vere/reck.c b/vere/reck.c index 80a54ec24..5cff465ed 100644 --- a/vere/reck.c +++ b/vere/reck.c @@ -127,49 +127,6 @@ _reck_kick_term(u3_noun pox, c3_l tid_l, u3_noun fav) c3_assert(!"not reached"); return 0; } -/* _reck_kick_http(): apply http effects. -*/ -static u3_noun -_reck_kick_http(u3_noun pox, - c3_l sev_l, - c3_l coq_l, - c3_l seq_l, - u3_noun fav) -{ - u3_noun p_fav, q_fav; - - if ( c3n == u3du(fav) ) { - u3z(pox); u3z(fav); return c3n; - } - else switch ( u3h(fav) ) { - default: u3z(pox); u3z(fav); return c3n; - - case c3__form: p_fav = u3t(fav); - { - u3_http_ef_form(u3k(p_fav)); - - u3z(pox); u3z(fav); - return c3y; - } - - case c3__thus: p_fav = u3h(u3t(fav)); q_fav = u3t(u3t(fav)); - { - u3_cttp_ef_thus(u3r_word(0, p_fav), u3k(q_fav)); - - u3z(pox); u3z(fav); - return c3y; - } - case c3__thou: p_fav = u3t(fav); - { - u3_http_ef_thou(sev_l, coq_l, seq_l, u3k(p_fav)); - - u3z(pox); u3z(fav); - return c3y; - } break; - } - c3_assert(!"not reached"); return c3n; -} - /* _reck_kick_behn(): apply packet network outputs. */ static u3_noun