Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc server: fix host filter for localhost on ipv6 #6454

Merged
merged 5 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading