Handle case where connection meta-data are faulty

This commit is contained in:
Ulf Wiger
2025-10-14 13:02:38 +02:00
parent 570f31ab3c
commit 1e60f35dd3
3 changed files with 17 additions and 4 deletions
+14 -1
View File
@@ -452,7 +452,20 @@ protocol_connect(Opts, #st{econn = EConn} = S) ->
, nonces => gmhc_server:total_nonces()
, signature => ""},
?LOG_DEBUG("ConnectReq = ~p", [ConnectReq]),
Msg = gmhp_msgs:encode_connect(ConnectReq, RId),
try gmhp_msgs:encode_connect(ConnectReq, RId) of
Msg ->
send_connect(EConn, RId, Msg, ConnectReq, Opts, S)
catch error:Error ->
ErrMsg = unicode:characters_to_binary(io_lib:fwrite("~p", [Error])),
disconnected(S#st.id, #{error =>
#{code => gmhp_msgs:error_code(invalid_input),
message => ErrMsg}}, S)
end.
send_connect(EConn, RId, Msg, #{pubkey := Pubkey,
extra_pubkeys := Extra,
pool_id := PoolId,
type := Type}, Opts, S) ->
enoise:send(EConn, Msg),
receive
{noise, EConn, Data} ->