Skip to content

Commit

Permalink
[stable2409] Backport #6454 (#6458)
Browse files Browse the repository at this point in the history
Backport #6454 into `stable2409` from niklasad1.

See the
[documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md)
on how to use this bot.

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

Co-authored-by: Niklas Adolfsson <[email protected]>
  • Loading branch information
1 parent 68cb923 commit ffc3f2f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
7 changes: 7 additions & 0 deletions prdoc/pr_6454.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: 'rpc server: fix ipv6 host filter for localhost'
doc:
- audience: Node Operator
description: "This PR fixes that ipv6 connections to localhost was faulty rejected by the host filter because only [::1] was allowed"
crates:
- name: sc-rpc-server
bump: minor
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 ffc3f2f

Please sign in to comment.