Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
szysas committed Aug 29, 2024
1 parent fd2a329 commit 034885d
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,19 @@ public void start() {
init(bootstrap.bind().syncUninterruptibly().channel());

// for random port update bootstrap with actual port but only if SO_REUSEPORT is enabled
if (((InetSocketAddress) bootstrap.config().localAddress()).getPort() == 0 && bootstrap.config().options().getOrDefault(UnixChannelOption.SO_REUSEPORT, Boolean.FALSE) == Boolean.TRUE) {
if (bindToRandomPort() && reusePortIsEnabled()) {
bootstrap.localAddress(channel.localAddress());
}
}

private Boolean reusePortIsEnabled() {
return (Boolean) bootstrap.config().options().getOrDefault(UnixChannelOption.SO_REUSEPORT, Boolean.FALSE);
}

private boolean bindToRandomPort() {
return ((InetSocketAddress) bootstrap.config().localAddress()).getPort() == 0;
}

void init(Channel channel) {
this.channel = channel;
this.channel.pipeline()
Expand Down

0 comments on commit 034885d

Please sign in to comment.