mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-26 18:48:21 +01:00
Refactor URI overrides (#10051)
This commit is contained in:
@@ -52,7 +52,10 @@ namespace Emby.Server.Implementations.Udp
|
||||
|
||||
_endpoint = new IPEndPoint(bindAddress, port);
|
||||
|
||||
_udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||
_udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)
|
||||
{
|
||||
MulticastLoopback = false,
|
||||
};
|
||||
_udpSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
|
||||
}
|
||||
|
||||
@@ -74,6 +77,7 @@ namespace Emby.Server.Implementations.Udp
|
||||
|
||||
try
|
||||
{
|
||||
_logger.LogDebug("Sending AutoDiscovery response");
|
||||
await _udpSocket.SendToAsync(JsonSerializer.SerializeToUtf8Bytes(response), SocketFlags.None, endpoint, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (SocketException ex)
|
||||
@@ -99,7 +103,8 @@ namespace Emby.Server.Implementations.Udp
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _udpSocket.ReceiveFromAsync(_receiveBuffer, SocketFlags.None, _endpoint, cancellationToken).ConfigureAwait(false);
|
||||
var endpoint = (EndPoint)new IPEndPoint(IPAddress.Any, 0);
|
||||
var result = await _udpSocket.ReceiveFromAsync(_receiveBuffer, endpoint, cancellationToken).ConfigureAwait(false);
|
||||
var text = Encoding.UTF8.GetString(_receiveBuffer, 0, result.ReceivedBytes);
|
||||
if (text.Contains("who is JellyfinServer?", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -112,7 +117,7 @@ namespace Emby.Server.Implementations.Udp
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
// Don't throw
|
||||
_logger.LogDebug("Broadcast socket operation cancelled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user