Skip to content

Commit

Permalink
rpc server: fix host filter for localhost
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasad1 committed Nov 12, 2024
1 parent 872d949 commit 649c50d
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions substrate/client/rpc-servers/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,11 @@ pub(crate) fn host_filtering(enabled: bool, addr: SocketAddr) -> Option<HostFilt
if enabled {
// NOTE: The listening addresses are whitelisted by default.

let mut hosts = Vec::new();

if addr.is_ipv4() {
hosts.push(format!("localhost:{}", addr.port()));
hosts.push(format!("127.0.0.1:{}", addr.port()));
} else {
hosts.push(format!("[::1]:{}", addr.port()));
}
let hosts = [
format!("localhost:{}", addr.port()),
format!("127.0.0.1:{}", addr.port()),
format!("[::1]:{}", addr.port())
];

Some(HostFilterLayer::new(hosts).expect("Valid hosts; qed"))
} else {
Expand Down

0 comments on commit 649c50d

Please sign in to comment.