Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d962ec8
feat: port router node onto kernelized edge
Lucifer0x17 Jun 12, 2026
66a9e08
fix: manifest rendering on #915 (lowercase peer headers, inline b32 e…
Lucifer0x17 Jun 14, 2026
9462da6
perf: drop eager request-event load and parallelize peer-response ver…
Lucifer0x17 Jun 17, 2026
767b85e
fix: restore signed admissible-response push dropped in edge port
Lucifer0x17 Jun 19, 2026
a7a3f14
fix: carry serving node's http-reference on admissible-response
Lucifer0x17 Jun 19, 2026
9d29ec7
fix: restore device-scoped hook resolution
Lucifer0x17 Jun 19, 2026
5dd9d15
impr: remove chance device and use it as a remote device
Lucifer0x17 Jun 20, 2026
f80f66a
fix: resolve admissible-response hook against the node default store
Lucifer0x17 Jun 24, 2026
396af73
impr: Handle errors in logs better
speeddragon Jun 24, 2026
48f7e87
impr: Handle expired certificate error
speeddragon Aug 17, 2026
01eba92
fix: verify remote response before commitment filtering
speeddragon Aug 21, 2026
bb4c85c
fix: dev_manifest test, adding subdomain
speeddragon Aug 25, 2026
7776619
feat: Allow to set the store remote node scope
speeddragon Aug 26, 2026
8e79fc4
fix: Loading manifest asset via hb_store_remote_node
speeddragon Aug 26, 2026
cc71d2f
impr: Revert genesis wasm change, not needed
speeddragon Aug 27, 2026
9a51012
impr: Remove subdomain redirect from dev_manifest
speeddragon Aug 27, 2026
0f199d8
impr: Make request host to have both hostname and port
speeddragon Aug 21, 2026
44274e7
impr: Move comment
speeddragon Aug 28, 2026
2089041
impr: Reuse lower_case_keys
speeddragon Aug 28, 2026
8884841
impr: Make variable name more readable
speeddragon Aug 28, 2026
a920e78
impr: Refactor multi_read functionality in hb_store_remote_node
speeddragon Aug 28, 2026
d73c958
impr: Make code more modular, extract some functionality to devices
speeddragon Aug 31, 2026
46a6ac4
impr: decorator code
speeddragon Aug 31, 2026
d64a34f
impr: Update code based on CONTRIBUTING file
speeddragon Sep 1, 2026
d2225bc
fix: Revert http header lowercase
speeddragon Sep 1, 2026
3560e35
impr: Remove external devices
speeddragon Sep 1, 2026
3880e40
fix: New line
speeddragon Sep 1, 2026
93c1cad
impr: Add logs
speeddragon Sep 7, 2026
771aefb
fix: Make store_remote_node to use local-store cache
speeddragon Sep 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions src/core/http/hb_http.erl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ request(Method, #{ <<"opts">> := ReqOpts, <<"uri">> := URI }, _Path, Message, Op
MergedOpts
),
request(NewMethod, Node, NewPath, NewMsg, NewOpts);
request(Method, #{ <<"prefix">> := Prefix }, Path, RawMessage, Opts) ->
% A configured remote node carrying a `prefix' URL (its per-node `opts' are
% read elsewhere). Use the prefix as the peer, preserving the request path.
request(Method, Prefix, Path, RawMessage, Opts);
request(Method, Peer, Path, RawMessage, Opts) ->
?event({request, {method, Method}, {peer, Peer}, {path, Path}, {priv_message, RawMessage}}),
Req =
Expand Down Expand Up @@ -329,9 +333,10 @@ http_response_to_httpsig(Status, HeaderMap, Body, Opts) ->
0 -> #{};
_ -> #{ <<"body">> => Body }
end,
ConvertFrom =
NormalizedHeaders = lowercase_header_keys(HeaderMap),
ConvertFrom =
hb_maps:merge(
HeaderMap#{ <<"status">> => BinStatus },
NormalizedHeaders#{ <<"status">> => BinStatus },
BodyMap,
Opts
),
Expand All @@ -342,6 +347,18 @@ http_response_to_httpsig(Status, HeaderMap, Body, Opts) ->
Opts
))#{ <<"status">> => hb_util:int(Status) }.

%% @doc Lowercase binary header keys from peer responses before the httpsig
%% codec runs, so committed component names (signed lowercase per RFC 9421)
%% match regardless of the peer's HTTP/1.1 header casing. Values are untouched.
lowercase_header_keys(Headers) when is_map(Headers) ->
maps:fold(
fun(K, V, Acc) when is_binary(K) -> Acc#{ string:lowercase(K) => V };
(K, V, Acc) -> Acc#{ K => V }
end,
#{},
Headers
).

%% @doc Given a message, return the information needed to make the request.
message_to_request(M, Opts) ->
% Get the route for the message.
Expand Down Expand Up @@ -1145,10 +1162,9 @@ normalize_unsigned(PrimMsg, Req = #{ headers := RawHeaders }, Msg, Opts) ->
not_found -> WithPrivIP;
Device -> WithPrivIP#{<<"device">> => Device}
end,
Host = cowboy_req:host(Req),
Host = cowboy_req:header(<<"host">>, Req, cowboy_req:host(Req)),

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From #1097

WithDevice#{<<"host">> => Host}.


%% @doc Determine the caller, honoring the `x-real-ip' header if present.
real_ip(Req = #{ headers := RawHeaders }, Opts) ->
case hb_maps:get(<<"x-real-ip">>, RawHeaders, undefined, Opts) of
Expand Down
27 changes: 27 additions & 0 deletions src/core/http/hb_http_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
-include("include/hb.hrl").
-include("include/hb_opts.hrl").
-include("include/hb_http_client.hrl").
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
-endif.
%% Public API
-export([request/2, response_status_to_atom/1, setup_conn/1]).
%% GenServer
Expand Down Expand Up @@ -790,6 +793,12 @@ get_status_class({error, {down, noproc}}) ->
<<"noproc">>;
get_status_class({error, {stream_error, {closed, normal}}}) ->
<<"stream-closed">>;
get_status_class({error, {tls_alert, {internal_error, _}}}) ->
<<"tls-alert-internal-error">>;
get_status_class({error, {tls_alert, {handshake_failure, _}}}) ->
<<"tls-alert-handshake-failure">>;
get_status_class({error, {tls_alert, {certificate_expired, _}}}) ->
<<"tls-alert-certificate-expired">>;
get_status_class({error, Error}) when is_atom(Error) ->
hb_util:atom_to_dashed_binary(Error);
get_status_class(208) ->
Expand Down Expand Up @@ -829,3 +838,21 @@ path_to_category(Path) ->
undefined -> <<"unknown">>;
_ -> <<"unknown">>
end.

-ifdef(TEST).

tls_alert_status_class_test() ->
?assertEqual(
<<"tls-alert-internal-error">>,
get_status_class({error, {tls_alert, {internal_error, test}}})
),
?assertEqual(
<<"tls-alert-handshake-failure">>,
get_status_class({error, {tls_alert, {handshake_failure, test}}})
),
?assertEqual(
<<"tls-alert-certificate-expired">>,
get_status_class({error, {tls_alert, {certificate_expired, test}}})
).

-endif.
Loading