Fix: PlayTo using external ip not internal

This commit is contained in:
BaronGreenback 2021-04-15 18:36:47 +01:00
parent 557a2ad715
commit 3199d1c902
5 changed files with 18 additions and 16 deletions

View File

@ -183,7 +183,7 @@ namespace Emby.Dlna.PlayTo
_sessionManager.UpdateDeviceName(sessionInfo.Id, deviceName); _sessionManager.UpdateDeviceName(sessionInfo.Id, deviceName);
string serverAddress = _appHost.GetSmartApiUrl(info.LocalIpAddress); string serverAddress = _appHost.GetSmartApiUrl(info.RemoteIpAddress);
controller = new PlayToController( controller = new PlayToController(
sessionInfo, sessionInfo,

View File

@ -104,7 +104,7 @@ namespace Emby.Dlna.Ssdp
{ {
Location = e.DiscoveredDevice.DescriptionLocation, Location = e.DiscoveredDevice.DescriptionLocation,
Headers = headers, Headers = headers,
LocalIpAddress = e.LocalIpAddress RemoteIpAddress = e.RemoteIpAddress
}); });
DeviceDiscoveredInternal?.Invoke(this, args); DeviceDiscoveredInternal?.Invoke(this, args);

View File

@ -16,5 +16,7 @@ namespace MediaBrowser.Model.Dlna
public IPAddress LocalIpAddress { get; set; } public IPAddress LocalIpAddress { get; set; }
public int LocalPort { get; set; } public int LocalPort { get; set; }
public IPAddress RemoteIpAddress { get; set; }
} }
} }

View File

@ -8,7 +8,7 @@ namespace Rssdp
/// </summary> /// </summary>
public sealed class DeviceAvailableEventArgs : EventArgs public sealed class DeviceAvailableEventArgs : EventArgs
{ {
public IPAddress LocalIpAddress { get; set; } public IPAddress RemoteIpAddress { get; set; }
private readonly DiscoveredSsdpDevice _DiscoveredDevice; private readonly DiscoveredSsdpDevice _DiscoveredDevice;

View File

@ -208,7 +208,7 @@ namespace Rssdp.Infrastructure
/// Raises the <see cref="DeviceAvailable"/> event. /// Raises the <see cref="DeviceAvailable"/> event.
/// </summary> /// </summary>
/// <seealso cref="DeviceAvailable"/> /// <seealso cref="DeviceAvailable"/>
protected virtual void OnDeviceAvailable(DiscoveredSsdpDevice device, bool isNewDevice, IPAddress localIpAddress) protected virtual void OnDeviceAvailable(DiscoveredSsdpDevice device, bool isNewDevice, IPAddress IpAddress)
{ {
if (this.IsDisposed) if (this.IsDisposed)
{ {
@ -220,7 +220,7 @@ namespace Rssdp.Infrastructure
{ {
handlers(this, new DeviceAvailableEventArgs(device, isNewDevice) handlers(this, new DeviceAvailableEventArgs(device, isNewDevice)
{ {
LocalIpAddress = localIpAddress RemoteIpAddress = IpAddress
}); });
} }
} }
@ -286,7 +286,7 @@ namespace Rssdp.Infrastructure
} }
} }
private void AddOrUpdateDiscoveredDevice(DiscoveredSsdpDevice device, IPAddress localIpAddress) private void AddOrUpdateDiscoveredDevice(DiscoveredSsdpDevice device, IPAddress IpAddress)
{ {
bool isNewDevice = false; bool isNewDevice = false;
lock (_Devices) lock (_Devices)
@ -304,17 +304,17 @@ namespace Rssdp.Infrastructure
} }
} }
DeviceFound(device, isNewDevice, localIpAddress); DeviceFound(device, isNewDevice, IpAddress);
} }
private void DeviceFound(DiscoveredSsdpDevice device, bool isNewDevice, IPAddress localIpAddress) private void DeviceFound(DiscoveredSsdpDevice device, bool isNewDevice, IPAddress IpAddress)
{ {
if (!NotificationTypeMatchesFilter(device)) if (!NotificationTypeMatchesFilter(device))
{ {
return; return;
} }
OnDeviceAvailable(device, isNewDevice, localIpAddress); OnDeviceAvailable(device, isNewDevice, IpAddress);
} }
private bool NotificationTypeMatchesFilter(DiscoveredSsdpDevice device) private bool NotificationTypeMatchesFilter(DiscoveredSsdpDevice device)
@ -347,7 +347,7 @@ namespace Rssdp.Infrastructure
return _CommunicationsServer.SendMulticastMessage(message, null, cancellationToken); return _CommunicationsServer.SendMulticastMessage(message, null, cancellationToken);
} }
private void ProcessSearchResponseMessage(HttpResponseMessage message, IPAddress localIpAddress) private void ProcessSearchResponseMessage(HttpResponseMessage message, IPAddress IpAddress)
{ {
if (!message.IsSuccessStatusCode) if (!message.IsSuccessStatusCode)
{ {
@ -367,11 +367,11 @@ namespace Rssdp.Infrastructure
ResponseHeaders = message.Headers ResponseHeaders = message.Headers
}; };
AddOrUpdateDiscoveredDevice(device, localIpAddress); AddOrUpdateDiscoveredDevice(device, IpAddress);
} }
} }
private void ProcessNotificationMessage(HttpRequestMessage message, IPAddress localIpAddress) private void ProcessNotificationMessage(HttpRequestMessage message, IPAddress IpAddress)
{ {
if (String.Compare(message.Method.Method, "Notify", StringComparison.OrdinalIgnoreCase) != 0) if (String.Compare(message.Method.Method, "Notify", StringComparison.OrdinalIgnoreCase) != 0)
{ {
@ -381,7 +381,7 @@ namespace Rssdp.Infrastructure
var notificationType = GetFirstHeaderStringValue("NTS", message); var notificationType = GetFirstHeaderStringValue("NTS", message);
if (String.Compare(notificationType, SsdpConstants.SsdpKeepAliveNotification, StringComparison.OrdinalIgnoreCase) == 0) if (String.Compare(notificationType, SsdpConstants.SsdpKeepAliveNotification, StringComparison.OrdinalIgnoreCase) == 0)
{ {
ProcessAliveNotification(message, localIpAddress); ProcessAliveNotification(message, IpAddress);
} }
else if (String.Compare(notificationType, SsdpConstants.SsdpByeByeNotification, StringComparison.OrdinalIgnoreCase) == 0) else if (String.Compare(notificationType, SsdpConstants.SsdpByeByeNotification, StringComparison.OrdinalIgnoreCase) == 0)
{ {
@ -389,7 +389,7 @@ namespace Rssdp.Infrastructure
} }
} }
private void ProcessAliveNotification(HttpRequestMessage message, IPAddress localIpAddress) private void ProcessAliveNotification(HttpRequestMessage message, IPAddress IpAddress)
{ {
var location = GetFirstHeaderUriValue("Location", message); var location = GetFirstHeaderUriValue("Location", message);
if (location != null) if (location != null)
@ -404,7 +404,7 @@ namespace Rssdp.Infrastructure
ResponseHeaders = message.Headers ResponseHeaders = message.Headers
}; };
AddOrUpdateDiscoveredDevice(device, localIpAddress); AddOrUpdateDiscoveredDevice(device, IpAddress);
} }
} }
@ -630,7 +630,7 @@ namespace Rssdp.Infrastructure
private void CommsServer_RequestReceived(object sender, RequestReceivedEventArgs e) private void CommsServer_RequestReceived(object sender, RequestReceivedEventArgs e)
{ {
ProcessNotificationMessage(e.Message, e.LocalIpAddress); ProcessNotificationMessage(e.Message, e.ReceivedFrom.Address);
} }
} }
} }