From 55afb9d0b5a1bc477de7df865ed94b3f102d1ad6 Mon Sep 17 00:00:00 2001 From: pkova Date: Tue, 21 Feb 2023 20:48:56 +0200 Subject: [PATCH] lull, eyre: add intermediate type for /~/name endpoint The previous changes implementing the /~/name endpoint were breaking, since we changed the type of `$action:eyre`. This commit keeps the /~/name endpoint functional, but adds adapters to eyre scries that returns the old `$action:eyre` type. These adapters and their associated intermediate types can be removed the next time we burn a kelvin. --- pkg/arvo/sys/lull.hoon | 3 +- pkg/arvo/sys/vane/eyre.hoon | 85 +++++++++++++++++++++++++++++-------- 2 files changed, 70 insertions(+), 18 deletions(-) diff --git a/pkg/arvo/sys/lull.hoon b/pkg/arvo/sys/lull.hoon index 8527f3994..9856f9311 100644 --- a/pkg/arvo/sys/lull.hoon +++ b/pkg/arvo/sys/lull.hoon @@ -1555,8 +1555,9 @@ :: [%scry ~] :: respond with the @p the requester is authenticated as + :: TODO: put this back in when we burn the next kelvin :: - [%name ~] + :: [%name ~] :: respond with the default file not found page :: [%four-oh-four ~] diff --git a/pkg/arvo/sys/vane/eyre.hoon b/pkg/arvo/sys/vane/eyre.hoon index 9aabcda8a..e1716c624 100644 --- a/pkg/arvo/sys/vane/eyre.hoon +++ b/pkg/arvo/sys/vane/eyre.hoon @@ -75,6 +75,32 @@ :: =server-state == +:: +:: +outstanding-connection-new: intermediate type to enable +:: /~/name endpoint without +:: breaking type change in lull +:: ++$ outstanding-connection-new + $: :: action: the action that had matched + :: + action=action-new + :: inbound-request: the original request which caused this connection + :: + =inbound-request + :: response-header: set when we get our first %start + :: + response-header=(unit response-header:http) + :: bytes-sent: the total bytes sent in response + :: + bytes-sent=@ud + == +:: +action-new: intermediate type to enable /~/name endpoint +:: without breaking type change in lull +:: ++$ action-new + $% action + [%name ~] + == :: +server-state: state relating to open inbound HTTP connections :: +$ server-state @@ -87,13 +113,13 @@ :: TODO: It would be nice if we had a path trie. We could decompose :: the :binding into a (map (unit @t) (trie knot =action)). :: - bindings=(list [=binding =duct =action]) + bindings=(list [=binding =duct action=action-new]) :: cors-registry: state used and managed by the +cors core :: =cors-registry :: connections: open http connections not fully complete :: - connections=(map duct outstanding-connection) + connections=(map duct outstanding-connection-new) :: authentication-state: state managed by the +authentication core :: =authentication-state @@ -580,7 +606,7 @@ :: =/ act [%app app=%lens] :: - =/ connection=outstanding-connection + =/ connection=outstanding-connection-new [act [& secure address request] ~ 0] :: =. connections.state @@ -604,13 +630,13 @@ (fall (forwarded-for u.forwards) address) :: =/ host (get-header:http 'host' headers) - =/ [=action suburl=@t] + =/ [action=action-new suburl=@t] (get-action-for-binding host url.request) :: =/ authenticated (request-is-logged-in:authentication request) :: record that we started an asynchronous response :: - =/ connection=outstanding-connection + =/ connection=outstanding-connection-new [action [authenticated secure address request] ~ 0] =. connections.state (~(put by connections.state) duct connection) @@ -1935,7 +1961,7 @@ (session-cookie-string u.session-id &) headers.response-header.http-event :: - =/ connection=outstanding-connection + =/ connection=outstanding-connection-new (~(got by connections.state) duct) :: if the request was a simple cors request from an approved origin :: append the necessary cors headers to the response @@ -1971,7 +1997,7 @@ :: =. connections.state %+ ~(jab by connections.state) duct - |= connection=outstanding-connection + |= connection=outstanding-connection-new =+ size=?~(data.http-event 0 p.u.data.http-event) connection(bytes-sent (add bytes-sent.connection size)) :: @@ -2024,7 +2050,7 @@ :: Adds =binding =action if there is no conflicting bindings. :: ++ add-binding - |= [=binding =action] + |= [=binding action=action-new] ^- [(list move) server-state] =^ success bindings.state :: prevent binding in reserved namespaces @@ -2045,7 +2071,7 @@ %_ state bindings %+ skip bindings.state - |= [item-binding=^binding item-duct=^duct =action] + |= [item-binding=^binding item-duct=^duct action=action-new] ^- ? &(=(item-binding binding) =(item-duct duct)) == @@ -2053,7 +2079,7 @@ :: ++ get-action-for-binding |= [raw-host=(unit @t) url=@t] - ^- [=action suburl=@t] + ^- [action=action-new suburl=@t] :: process :raw-host :: :: If we are missing a 'Host:' header, if that header is a raw IP @@ -2159,8 +2185,8 @@ :: +insert-binding: add a new binding, replacing any existing at its path :: ++ insert-binding - |= $: new=[=binding =duct =action] - bindings=(list [=binding =duct =action]) + |= $: new=[=binding =duct action=action-new] + bindings=(list [=binding =duct action=action-new]) == ^+ bindings ?~ bindings [new]~ @@ -2223,7 +2249,7 @@ :: =. bindings.server-state.ax =- (roll - insert-binding) - ^- (list [binding ^duct action]) + ^- (list [binding ^duct action-new]) :~ [[~ /~/login] duct [%authentication ~]] [[~ /~/logout] duct [%logout ~]] [[~ /~/channel] duct [%channel ~]] @@ -2596,6 +2622,31 @@ -- :: ++ http-server-gate ..$ +:: +bindings-old: filter /~/name endpoint from bindings +:: +++ bindings-old + |= new=(list [b=binding d=duct a=action-new]) + =| old=(list [binding duct action]) + |- ^+ old + ?~ new old + =/ l + ?: ?=([%name ~] a.i.new) + old + (snoc old [b.i.new d.i.new a.i.new]) + $(new t.new, old l) +:: +connections-old: filter /~/name endpoint from connections +:: +++ connections-old + |= new=(map duct outstanding-connection-new) + =| old=(map duct outstanding-connection) + =/ l=(list [d=duct o=outstanding-connection-new]) ~(tap by new) + |- ^+ old + ?~ l old + =/ x + ?: ?=([%name ~] -.o.i.l) + old + (~(put by old) d.i.l o.i.l) + $(l t.l, old x) :: +load: migrate old state to new state (called on vane reload) :: ++ load @@ -2650,9 +2701,9 @@ =* who p.why ?: =(tyl /whey) =/ maz=(list mass) - :~ bindings+&+bindings.server-state.ax + :~ bindings+&+(bindings-old bindings.server-state.ax) auth+&+authentication-state.server-state.ax - connections+&+connections.server-state.ax + connections+&+(connections-old connections.server-state.ax) channels+&+channel-state.server-state.ax axle+&+ax == @@ -2692,8 +2743,8 @@ ?. ?=(%$ ren) [~ ~] ?+ syd [~ ~] - %bindings ``noun+!>(bindings.server-state.ax) - %connections ``noun+!>(connections.server-state.ax) + %bindings ``noun+!>((bindings-old bindings.server-state.ax)) + %connections ``noun+!>((connections-old connections.server-state.ax)) %authentication-state ``noun+!>(authentication-state.server-state.ax) %channel-state ``noun+!>(channel-state.server-state.ax) ::