diff --git a/src/lib_p2p/p2p.ml b/src/lib_p2p/p2p.ml index 4669ef5dd..5b564922a 100644 --- a/src/lib_p2p/p2p.ml +++ b/src/lib_p2p/p2p.ml @@ -543,9 +543,6 @@ let build_rpc_directory net = match net.pool with | None -> failwith "The P2P layer is disabled." | Some pool -> - fail_when - (P2p_pool.Points.banned pool point) - (P2p_errors.Point_banned point) >>=? fun () -> P2p_pool.connect ~timeout pool point >>=? fun _conn -> return () end in @@ -674,9 +671,10 @@ let build_rpc_directory net = begin fun peer_id () () -> match net.pool with | None -> return false + | Some pool when (P2p_pool.Peers.get_trusted pool peer_id) -> + return false | Some pool -> - if P2p_pool.Peers.get_trusted pool peer_id then return false - else return (P2p_pool.Peers.banned pool peer_id) + return (P2p_pool.Peers.banned pool peer_id) end in (* Network : Point *) @@ -766,12 +764,11 @@ let build_rpc_directory net = RPC_directory.gen_register1 dir P2p_services.Points.S.banned begin fun point () () -> match net.pool with - | None -> RPC_answer.return false + | None -> RPC_answer.not_found + | Some pool when (P2p_pool.Points.get_trusted pool point) -> + RPC_answer.return false | Some pool -> - if P2p_pool.Points.get_trusted pool point then - RPC_answer.return false - else - RPC_answer.return (P2p_pool.Points.banned pool point) + RPC_answer.return (P2p_pool.Points.banned pool point) end in (* Network : Greylist *) diff --git a/src/lib_p2p/p2p_acl.ml b/src/lib_p2p/p2p_acl.ml index 3d551f55e..9444da75e 100644 --- a/src/lib_p2p/p2p_acl.ml +++ b/src/lib_p2p/p2p_acl.ml @@ -1,6 +1,6 @@ (**************************************************************************) (* *) -(* Copyright (c) 2014 - 2016. *) +(* Copyright (c) 2014 - 2018. *) (* Dynamic Ledger Solutions, Inc. *) (* *) (* All rights reserved. No warranty, explicit or implicit, provided. *) @@ -112,7 +112,7 @@ module IpSet = struct type result = Time.t let default = Time.now() let map _t _key value = value - let reduce _t left right = Time.(max left right) + let reduce _t left right = Time.(min left right) end in let module MR = M.Map_Reduce(MI) in diff --git a/src/lib_p2p/p2p_acl.mli b/src/lib_p2p/p2p_acl.mli index 3a9f5e02b..e2add6c6b 100644 --- a/src/lib_p2p/p2p_acl.mli +++ b/src/lib_p2p/p2p_acl.mli @@ -9,10 +9,12 @@ (** This module implements four Access Control Lists: - - ip greylist used to automatically ban a given ip address. - - peer_id greylist used to automatically ban a given peer_id. - - ip blacklist used to manually ban a given ip addr. - - peers blacklist used to manually trust a given peer_id. + - ip greylist is a set of banned ip addresses automatically added by + the p2p layer. + - peer_id greylist is a set of banned peers ids automatically added by + the p2p layer. + - ip blacklist is a set of ip addresses manually added by the node admin. + - peers blacklist is a set of peers ids manually added by the node admin. IP greylists use a time based GC to periodically remove entries from the table, while peer_id grey lists are built using a ring structure, diff --git a/src/lib_shell_services/p2p_services.mli b/src/lib_shell_services/p2p_services.mli index 3f826e8a4..1d938bd25 100644 --- a/src/lib_shell_services/p2p_services.mli +++ b/src/lib_shell_services/p2p_services.mli @@ -132,12 +132,10 @@ module Points : sig unit * P2p_point.Id.t, unit, unit, bool) RPC_service.t - end end - module Peers : sig val list: