diff options
| author | Shadowghost <Ghost_of_Stone@web.de> | 2022-07-21 09:26:18 +0200 |
|---|---|---|
| committer | Shadowghost <Ghost_of_Stone@web.de> | 2022-07-21 09:26:18 +0200 |
| commit | f6e41269d94e4c3096b136a47d3616cb0c5fe316 (patch) | |
| tree | 294a1cf013d3c52422db6769dc80e1d39cc6bdf6 /Emby.Server.Implementations/Net/SocketFactory.cs | |
| parent | 05458a4a4240d2b15db93de6c9ec25376677b5e1 (diff) | |
Enforce interface bindings on SSDP, add Loopback to LAN if no LAN defined
Diffstat (limited to 'Emby.Server.Implementations/Net/SocketFactory.cs')
| -rw-r--r-- | Emby.Server.Implementations/Net/SocketFactory.cs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Emby.Server.Implementations/Net/SocketFactory.cs b/Emby.Server.Implementations/Net/SocketFactory.cs index 21795c8f8..a1baf3006 100644 --- a/Emby.Server.Implementations/Net/SocketFactory.cs +++ b/Emby.Server.Implementations/Net/SocketFactory.cs @@ -61,13 +61,18 @@ namespace Emby.Server.Implementations.Net } /// <inheritdoc /> - public ISocket CreateUdpMulticastSocket(IPAddress ipAddress, int multicastTimeToLive, int localPort) + public ISocket CreateUdpMulticastSocket(IPAddress ipAddress, IPAddress bindIpAddress, int multicastTimeToLive, int localPort) { if (ipAddress == null) { throw new ArgumentNullException(nameof(ipAddress)); } + if (bindIpAddress == null) + { + bindIpAddress = IPAddress.Any; + } + if (multicastTimeToLive <= 0) { throw new ArgumentException("multicastTimeToLive cannot be zero or less.", nameof(multicastTimeToLive)); @@ -98,12 +103,10 @@ namespace Emby.Server.Implementations.Net // retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true); retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, multicastTimeToLive); - var localIp = IPAddress.Any; - - retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ipAddress, localIp)); + retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ipAddress, bindIpAddress)); retVal.MulticastLoopback = true; - return new UdpSocket(retVal, localPort, localIp); + return new UdpSocket(retVal, localPort, bindIpAddress); } catch { |
