mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 20:57:59 +00:00
client: Replace unsafe_rpc_expose with an RpcMethods enum (#5729)
* client: Replace `unsafe_rpc_expose` with an `RpcMethods` enum which can be either Default, Safe or Unsafe. The idea is to have the following: | | --rpc-external=false | --rpc-external=true | |--------------------- |------------------- |----------------- | | --rpc-methods=Default | | unsafe calls denied | | --rpc-methods=Safe | unsafe calls denied | unsafe calls denied | | --rpc-methods=Unsafe | | | Since the previous `unsafe-rpc-expose` option was confusing. * client: Only warn against exposing externally unsafe RPC method set * Apply suggestions from code review Co-Authored-By: Cecile Tonglet <cecile.tonglet@cecton.com> * cli: Rephrase doc comment for rpc_methods config * Improve debuggability of build_spec_works ...by printing to stderr the stderr of the command. This is normally suppressed for succesful tests but not for failing ones - if that's the case then it's useful to see the test failure reason inline rather than having to execute the command separately ourselves. * Rename RpcMethods::{Default => Auto} variant * Update bin/node/cli/tests/build_spec_works.rs Co-authored-by: Benjamin Kampmann <ben.kampmann@googlemail.com> Co-authored-by: Cecile Tonglet <cecile.tonglet@cecton.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -122,6 +122,31 @@ impl ExecutionStrategy {
|
||||
}
|
||||
}
|
||||
|
||||
arg_enum! {
|
||||
/// Available RPC methods.
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
pub enum RpcMethods {
|
||||
// Expose every RPC method only when RPC is listening on `localhost`,
|
||||
// otherwise serve only safe RPC methods.
|
||||
Auto,
|
||||
// Allow only a safe subset of RPC methods.
|
||||
Safe,
|
||||
// Expose every RPC method (even potentially unsafe ones).
|
||||
Unsafe,
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<sc_service::config::RpcMethods> for RpcMethods {
|
||||
fn into(self) -> sc_service::config::RpcMethods {
|
||||
match self {
|
||||
RpcMethods::Auto => sc_service::config::RpcMethods::Auto,
|
||||
RpcMethods::Safe => sc_service::config::RpcMethods::Safe,
|
||||
RpcMethods::Unsafe => sc_service::config::RpcMethods::Unsafe,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
arg_enum! {
|
||||
/// Database backend
|
||||
#[allow(missing_docs)]
|
||||
|
||||
Reference in New Issue
Block a user