Skip to content

Commit 4b14606

Browse files
committed
fix(rlpx): gate IPv6 dual-stack TCP binding on DiscV5
DiscV4 cannot advertise IPv6 addresses so binding a second RLPx TCP socket with DiscV4 serves no useful purpose and could surprise operators expecting unchanged behaviour. Only enable the IPv6 RLPx socket when both discovery and DiscV5 are active. The guard can be removed once DiscV4 is deprecated and removed. Signed-off-by: Usman Saleem <usman@usmans.info>
1 parent d75269d commit 4b14606

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

app/src/main/java/org/hyperledger/besu/RunnerBuilder.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,12 +706,20 @@ public Runner build() {
706706
.flatMap(protocolManager -> protocolManager.getSupportedCapabilities().stream())
707707
.collect(Collectors.toSet());
708708

709+
// Only enable RLPx IPv6 dual-stack when DiscV5 is active. DiscV4 cannot advertise IPv6
710+
// addresses, so binding a second TCP socket would serve no purpose and could surprise
711+
// operators. When DiscV4 is eventually removed this guard can be dropped.
712+
final boolean rlpxDualStackEnabled =
713+
discoveryEnabled && networkingConfiguration.discoveryConfiguration().isDiscoveryV5Enabled();
709714
final RlpxConfiguration rlpxConfiguration =
710715
RlpxConfiguration.create()
711716
.setBindHost(p2pListenInterface)
712717
.setBindPort(p2pListenPort)
713-
.setBindHostIpv6(p2pListenInterfaceIpv6)
714-
.setBindPortIpv6(p2pListenInterfaceIpv6.map(ignored -> p2pListenPortIpv6))
718+
.setBindHostIpv6(rlpxDualStackEnabled ? p2pListenInterfaceIpv6 : Optional.empty())
719+
.setBindPortIpv6(
720+
rlpxDualStackEnabled
721+
? p2pListenInterfaceIpv6.map(ignored -> p2pListenPortIpv6)
722+
: Optional.empty())
715723
.setSupportedProtocols(subProtocols)
716724
.setClientId(BesuVersionUtils.nodeName(identityString));
717725
networkingConfiguration =

0 commit comments

Comments
 (0)