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
|
@Override
|
||||||
public ChannelFuture joinGroup(InetAddress multicastAddress, ChannelPromise promise) {
|
public ChannelFuture joinGroup(InetAddress multicastAddress, ChannelPromise promise) {
|
||||||
try {
|
try {
|
||||||
return joinGroup(
|
NetworkInterface iface = config().getNetworkInterface();
|
||||||
multicastAddress,
|
if (iface == null) {
|
||||||
NetworkInterface.getByInetAddress(localAddress().getAddress()), null, promise);
|
iface = NetworkInterface.getByInetAddress(localAddress().getAddress());
|
||||||
|
}
|
||||||
|
return joinGroup(multicastAddress, iface, null, promise);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
promise.setFailure(e);
|
promise.setFailure(e);
|
||||||
}
|
}
|
||||||
|
@ -99,10 +99,11 @@ public final class KQueueDatagramChannel extends AbstractKQueueDatagramChannel i
|
|||||||
@Override
|
@Override
|
||||||
public ChannelFuture joinGroup(InetAddress multicastAddress, ChannelPromise promise) {
|
public ChannelFuture joinGroup(InetAddress multicastAddress, ChannelPromise promise) {
|
||||||
try {
|
try {
|
||||||
return joinGroup(
|
NetworkInterface iface = config().getNetworkInterface();
|
||||||
multicastAddress,
|
if (iface == null) {
|
||||||
NetworkInterface.getByInetAddress(localAddress().getAddress()),
|
iface = NetworkInterface.getByInetAddress(localAddress().getAddress());
|
||||||
null, promise);
|
}
|
||||||
|
return joinGroup(multicastAddress, iface, null, promise);
|
||||||
} catch (SocketException e) {
|
} catch (SocketException e) {
|
||||||
promise.setFailure(e);
|
promise.setFailure(e);
|
||||||
}
|
}
|
||||||
|
@ -369,10 +369,12 @@ public final class NioDatagramChannel
|
|||||||
@Override
|
@Override
|
||||||
public ChannelFuture joinGroup(InetAddress multicastAddress, ChannelPromise promise) {
|
public ChannelFuture joinGroup(InetAddress multicastAddress, ChannelPromise promise) {
|
||||||
try {
|
try {
|
||||||
|
NetworkInterface iface = config.getNetworkInterface();
|
||||||
|
if (iface == null) {
|
||||||
|
iface = NetworkInterface.getByInetAddress(localAddress().getAddress());
|
||||||
|
}
|
||||||
return joinGroup(
|
return joinGroup(
|
||||||
multicastAddress,
|
multicastAddress, iface, null, promise);
|
||||||
NetworkInterface.getByInetAddress(localAddress().getAddress()),
|
|
||||||
null, promise);
|
|
||||||
} catch (SocketException e) {
|
} catch (SocketException e) {
|
||||||
promise.setFailure(e);
|
promise.setFailure(e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user