Handle case where connection meta-data are faulty
This commit is contained in:
+14
-1
@@ -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} ->
|
||||
|
||||
Reference in New Issue
Block a user