Commit 072e168b authored by Julien's avatar Julien

P2p: improve debug when rejecting peer connection

parent 319a4a8a
......@@ -852,24 +852,22 @@ and raw_authenticate pool ?point_info canceler fd point =
let acceptable_capacity =
let active = active_connections pool in
pool.config.max_connections > active in
let acceptable_point =
let acceptable_point, rejection_argument =
Option.unopt_map connection_point_info
~default:(not pool.config.private_mode)
~default:(not pool.config.private_mode, "unknown point in private mode")
~f:begin fun connection_point_info ->
match P2p_point_state.get connection_point_info with
| Requested _ -> not incoming
| Requested _ -> not incoming, "Requested status and incoming"
| Disconnected ->
let unexpected =
pool.config.private_mode
&& not (P2p_point_state.Info.trusted connection_point_info)
in
&& not (P2p_point_state.Info.trusted connection_point_info) in
if unexpected then
warn "[private node] incoming connection from untrused \
warn "[private node] incoming connection from untrusted \
peer rejected!";
not unexpected
| Accepted _ | Running _ -> false
end
in
(not unexpected, "unexpected connection in private mode")
| Accepted _ | Running _ -> (false, "already running or accepted point")
end in
let acceptable_peer_id =
match P2p_peer_state.get peer_info with
| Accepted _ ->
......@@ -935,10 +933,27 @@ and raw_authenticate pool ?point_info canceler fd point =
end
| _ -> begin
log pool (Rejecting_request (point, info.id_point, info.peer_id)) ;
lwt_debug "authenticate: %a -> kick %a point: %B peer_id: %B"
P2p_point.Id.pp point
P2p_peer.Id.pp info.peer_id
acceptable_point acceptable_peer_id >>= fun () ->
begin
match acceptable_version with
| None ->
lwt_debug "authenticate: %a -> kick %a,\
no compatible network (announced %a)"
P2p_point.Id.pp point
P2p_peer.Id.pp info.peer_id
Network_version.pp info.announced_version
| _ ->
lwt_debug "authenticate: %a -> kick %a enough slots:%B,\
point acceptable: %B%a, peer_id acceptable: %B"
P2p_point.Id.pp point
P2p_peer.Id.pp info.peer_id
acceptable_capacity
acceptable_point
(fun fmt (acceptable_point, rejection_argument) ->
if not acceptable_point then
Format.fprintf fmt "(%s)" rejection_argument)
(acceptable_point, rejection_argument)
acceptable_peer_id
end >>= fun () ->
P2p_socket.kick auth_fd >>= fun () ->
if not incoming then begin
Option.iter ~f:P2p_point_state.set_disconnected point_info ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment