Admin/P2P: register forget and kick RPC
This commit is contained in:
parent
705a779d76
commit
57fa653c5e
@ -109,19 +109,31 @@ let commands () =
|
||||
@@ param ~name:"address" ~desc:"IPv4 or IPV6 address" addr_parameter
|
||||
@@ stop)
|
||||
(fun port address (cctxt : #Client_context.full) ->
|
||||
P2p_services.connect cctxt ~timeout:10. (address, port)
|
||||
P2p_services.connect cctxt ~timeout:10. (address, port) >>=? fun () ->
|
||||
cctxt#message "Connection to %a:%d established." P2p_addr.pp address port >>= return
|
||||
) ;
|
||||
|
||||
command ~group ~desc: "Kick a peer."
|
||||
no_options
|
||||
(prefixes [ "kick" ; "peer" ]
|
||||
@@ P2p_peer.Id.param ~name:"peer" ~desc:"peer network identity"
|
||||
@@ stop)
|
||||
(fun () peer (cctxt : #Client_context.full) ->
|
||||
P2p_services.Connections.kick cctxt peer >>=? fun () ->
|
||||
cctxt#message "Connection to %a interrupted." P2p_peer.Id.pp peer >>= fun () ->
|
||||
return_unit
|
||||
) ;
|
||||
|
||||
command ~group ~desc: "Remove an IP address from the blacklist and whitelist."
|
||||
no_options
|
||||
(args1 (port_arg ()))
|
||||
(prefixes [ "forget" ; "address" ]
|
||||
@@ param ~name:"address" ~desc:"IPv4 or IPV6 address" addr_parameter
|
||||
@@ stop)
|
||||
(fun () address (cctxt : #Client_context.full) ->
|
||||
P2p_services.Points.forget cctxt (address, 0)
|
||||
(fun port address (cctxt : #Client_context.full) ->
|
||||
P2p_services.Points.forget cctxt (address, port)
|
||||
) ;
|
||||
|
||||
command ~group ~desc: "Add an IP address to the blacklist."
|
||||
command ~group ~desc: "Add an IP address to the blacklist and kicks it."
|
||||
no_options
|
||||
(prefixes [ "ban" ; "address" ]
|
||||
@@ param ~name:"address" ~desc:"IPv4 or IPV6 address" addr_parameter
|
||||
@ -161,7 +173,7 @@ let commands () =
|
||||
P2p_services.Peers.forget cctxt peer
|
||||
) ;
|
||||
|
||||
command ~group ~desc: "Add a peer ID to the blacklist."
|
||||
command ~group ~desc: "Add a peer ID to the blacklist and kicks it."
|
||||
no_options
|
||||
(prefixes [ "ban" ; "peer" ]
|
||||
@@ P2p_peer.Id.param ~name:"peer" ~desc:"peer network identity"
|
||||
|
@ -711,6 +711,16 @@ let build_rpc_directory net =
|
||||
RPC_answer.return_stream { next ; shutdown }
|
||||
end in
|
||||
|
||||
let dir =
|
||||
RPC_directory.gen_register1 dir P2p_services.Peers.S.forget
|
||||
begin fun peer_id () () ->
|
||||
match net.pool with
|
||||
| None -> RPC_answer.not_found
|
||||
| Some pool ->
|
||||
P2p_pool.Peers.forget pool peer_id ;
|
||||
RPC_answer.return ()
|
||||
end in
|
||||
|
||||
let dir =
|
||||
RPC_directory.gen_register1 dir P2p_services.Peers.S.ban
|
||||
begin fun peer_id () () ->
|
||||
@ -806,6 +816,16 @@ let build_rpc_directory net =
|
||||
RPC_answer.return_stream { next ; shutdown }
|
||||
end in
|
||||
|
||||
let dir =
|
||||
RPC_directory.gen_register1 dir P2p_services.Points.S.forget
|
||||
begin fun point () () ->
|
||||
match net.pool with
|
||||
| None -> RPC_answer.not_found
|
||||
| Some pool ->
|
||||
P2p_pool.Points.forget pool point ;
|
||||
RPC_answer.return ()
|
||||
end in
|
||||
|
||||
let dir =
|
||||
RPC_directory.gen_register1 dir P2p_services.Points.S.ban
|
||||
begin fun point () () ->
|
||||
|
Loading…
Reference in New Issue
Block a user