Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
service: fix RPC unsafe exposed address detection (#6070)
Browse files Browse the repository at this point in the history
  • Loading branch information
andresilva authored May 19, 2020
1 parent bc413d1 commit 0947c5b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions client/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,8 @@ fn start_rpc_servers<H: FnMut(sc_rpc::DenyUnsafe) -> sc_rpc_server::RpcHandler<s
})
}

fn deny_unsafe(addr: &Option<SocketAddr>, methods: &RpcMethods) -> sc_rpc::DenyUnsafe {
let is_exposed_addr = addr.map(|x| x.ip().is_loopback()).unwrap_or(false);
fn deny_unsafe(addr: &SocketAddr, methods: &RpcMethods) -> sc_rpc::DenyUnsafe {
let is_exposed_addr = !addr.ip().is_loopback();
match (is_exposed_addr, methods) {
| (_, RpcMethods::Unsafe)
| (false, RpcMethods::Auto) => sc_rpc::DenyUnsafe::No,
Expand All @@ -568,7 +568,7 @@ fn start_rpc_servers<H: FnMut(sc_rpc::DenyUnsafe) -> sc_rpc_server::RpcHandler<s
|address| sc_rpc_server::start_http(
address,
config.rpc_cors.as_ref(),
gen_handler(deny_unsafe(&config.rpc_http, &config.rpc_methods)),
gen_handler(deny_unsafe(&address, &config.rpc_methods)),
),
)?.map(|s| waiting::HttpServer(Some(s))),
maybe_start_server(
Expand All @@ -577,7 +577,7 @@ fn start_rpc_servers<H: FnMut(sc_rpc::DenyUnsafe) -> sc_rpc_server::RpcHandler<s
address,
config.rpc_ws_max_connections,
config.rpc_cors.as_ref(),
gen_handler(deny_unsafe(&config.rpc_ws, &config.rpc_methods)),
gen_handler(deny_unsafe(&address, &config.rpc_methods)),
),
)?.map(|s| waiting::WsServer(Some(s))),
)))
Expand Down

0 comments on commit 0947c5b

Please sign in to comment.