-
Notifications
You must be signed in to change notification settings - Fork 784
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
IPv6 By Default #6808
base: unstable
Are you sure you want to change the base?
IPv6 By Default #6808
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -224,6 +224,13 @@ pub fn cli_app() -> Command { | |
.action(ArgAction::Set) | ||
.display_order(0) | ||
) | ||
.arg( | ||
Arg::new("disable-ipv6") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. taking into consideration the description you wrote on the PR, should we then update this PR to make this optional? I.e add instead an option to enable ipv6 |
||
.long("disable-ipv6") | ||
.help("If 0.0.0.0 is set as the IPv4 listening address and the host has a globally routeable IPv6 address, Lighthouse will listen on :: by default, in dual-stack mode. This flag prevents this.") | ||
.action(ArgAction::SetTrue) | ||
.display_order(0) | ||
) | ||
.arg( | ||
Arg::new("target-peers") | ||
.long("target-peers") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -899,6 +899,7 @@ pub fn parse_listening_addresses( | |
// parse the possible ips | ||
let mut maybe_ipv4 = None; | ||
let mut maybe_ipv6 = None; | ||
|
||
for addr_str in listen_addresses_str { | ||
let addr = addr_str.parse::<IpAddr>().map_err(|parse_error| { | ||
format!("Failed to parse listen-address ({addr_str}) as an Ip address: {parse_error}") | ||
|
@@ -926,6 +927,19 @@ pub fn parse_listening_addresses( | |
} | ||
} | ||
|
||
// If we have specified an IPv4 listen address and not an IPv6 address and the | ||
// host has a globally routeable IPv6 address and the CLI doesn't expressly disable IPv6, | ||
// then we also listen on IPv6. | ||
// Note that we will only listen on all interfaces if the IPv4 counterpart is also listening on | ||
// all interfaces, to prevent accidental exposure of ports. | ||
if maybe_ipv4 == Some(Ipv4Addr::UNSPECIFIED) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we could then also re-write this logic to log when user enables ipv6 but doesn't support it |
||
&& maybe_ipv6.is_none() | ||
&& !cli_args.get_flag("disable_ipv6") | ||
&& NetworkConfig::is_ipv6_supported() | ||
{ | ||
maybe_ipv6 = Some(Ipv6Addr::UNSPECIFIED); | ||
} | ||
|
||
// parse the possible tcp ports | ||
let port = cli_args | ||
.get_one::<String>("port") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we already depend on
rtnetlink
viarust-libp2p
andif-watch
.There's an example on how to do it here, we could implement it here, or upsteam it as they mention in the discussion