Commit 319a4a8a authored by Grégoire Henry's avatar Grégoire Henry Committed by Julien

P2p: earlier detection of "public" nodes.

Tag nodes as public/private even if we reject the connection.
parent 2203ee13
......@@ -168,9 +168,12 @@ let set_accepted
point_info.state <- Accepted { current_peer_id ; cancel } ;
Info.log point_info ~timestamp (Accepting_request current_peer_id)
let set_private point_info known_private =
point_info.Info.known_public <- not known_private
let set_running
?(timestamp = Time.now ())
~known_private point_info peer_id data =
point_info peer_id data =
assert begin
match point_info.Info.state with
| Disconnected -> true (* request to unknown peer_id. *)
......@@ -179,7 +182,6 @@ let set_running
| Requested _ -> true
end ;
point_info.state <- Running { data ; current_peer_id = peer_id } ;
point_info.known_public <- not known_private ;
point_info.last_established_connection <- Some (peer_id, timestamp) ;
Info.log point_info ~timestamp (Connection_established peer_id)
......
......@@ -129,9 +129,10 @@ val set_accepted :
val set_running :
?timestamp:Time.t ->
known_private: bool ->
'conn Info.t -> P2p_peer.Id.t -> 'conn -> unit
val set_private : 'conn Info.t -> bool -> unit
val set_disconnected :
?timestamp:Time.t -> ?requested:bool -> 'conn Info.t -> unit
......@@ -886,8 +886,10 @@ and raw_authenticate pool ?point_info canceler fd point =
incoming connections, thus giving an entry point for dos attack
by giving late Nack.
*)
if incoming then
P2p_point.Table.remove pool.incoming point ;
if incoming then P2p_point.Table.remove pool.incoming point ;
Option.iter connection_point_info
~f:(fun point_info ->
P2p_point_state.set_private point_info info.private_node) ;
match acceptable_version with
| Some version
when acceptable_capacity && acceptable_peer_id && acceptable_point -> begin
......@@ -1022,7 +1024,6 @@ and create_connection pool p2p_conn id_point point_info peer_info negotiated_ver
Option.iter point_info ~f:begin fun point_info ->
let point = P2p_point_state.Info.point point_info in
P2p_point_state.set_running
~known_private:(pool.conn_meta_config.private_node conn_meta)
point_info peer_id conn;
P2p_point.Table.add pool.connected_points point point_info ;
end ;
......
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