Use StandardSocketOptions#IP_MULTICAST_IF as default source when joing multicast groups (#11585)
Motivation: We should use StandardSocketOptions#IP_MULTICAST_IF as default source when joing multicast groups and only try to use the localAddress if this returns null. Modifications: First check if StandardSocketOptions#IP_MULTICAST_IF was set and if so use the network interface when joining mulicast groups Result: Fixes https://github.com/netty/netty/issues/11541
This commit is contained in:
parent
cafc669436
commit
228a01e268
@ -141,9 +141,11 @@ public final class EpollDatagramChannel extends AbstractEpollChannel implements
|
||||
@Override
|
||||
public ChannelFuture joinGroup(InetAddress multicastAddress, ChannelPromise promise) {
|
||||
try {
|
||||
return joinGroup(
|
||||
multicastAddress,
|
||||
NetworkInterface.getByInetAddress(localAddress().getAddress()), null, promise);
|
||||
NetworkInterface iface = config().getNetworkInterface();
|
||||
if (iface == null) {
|
||||
iface = NetworkInterface.getByInetAddress(localAddress().getAddress());
|
||||
}
|
||||
return joinGroup(multicastAddress, iface, null, promise);
|
||||
} catch (IOException e) {
|
||||
promise.setFailure(e);
|
||||
}
|
||||
|
@ -99,10 +99,11 @@ public final class KQueueDatagramChannel extends AbstractKQueueDatagramChannel i
|
||||
@Override
|
||||
public ChannelFuture joinGroup(InetAddress multicastAddress, ChannelPromise promise) {
|
||||
try {
|
||||
return joinGroup(
|
||||
multicastAddress,
|
||||
NetworkInterface.getByInetAddress(localAddress().getAddress()),
|
||||
null, promise);
|
||||
NetworkInterface iface = config().getNetworkInterface();
|
||||
if (iface == null) {
|
||||
iface = NetworkInterface.getByInetAddress(localAddress().getAddress());
|
||||
}
|
||||
return joinGroup(multicastAddress, iface, null, promise);
|
||||
} catch (SocketException e) {
|
||||
promise.setFailure(e);
|
||||
}
|
||||
|
@ -369,10 +369,12 @@ public final class NioDatagramChannel
|
||||
@Override
|
||||
public ChannelFuture joinGroup(InetAddress multicastAddress, ChannelPromise promise) {
|
||||
try {
|
||||
NetworkInterface iface = config.getNetworkInterface();
|
||||
if (iface == null) {
|
||||
iface = NetworkInterface.getByInetAddress(localAddress().getAddress());
|
||||
}
|
||||
return joinGroup(
|
||||
multicastAddress,
|
||||
NetworkInterface.getByInetAddress(localAddress().getAddress()),
|
||||
null, promise);
|
||||
multicastAddress, iface, null, promise);
|
||||
} catch (SocketException e) {
|
||||
promise.setFailure(e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user