change controller project targeting

This commit is contained in:
Luke Pulverenti 2016-10-25 21:57:58 -04:00
parent 23d7afdf68
commit 675b643115
10 changed files with 69 additions and 17502 deletions

View File

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Net;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Net;
namespace MediaBrowser.Controller.Dlna
{
@ -15,6 +15,7 @@ namespace MediaBrowser.Controller.Dlna
{
public Uri Location { get; set; }
public Dictionary<string, string> Headers { get; set; }
public IPEndPoint LocalEndPoint { get; set; }
public IpAddressInfo LocalIpAddress { get; set; }
public int LocalPort { get; set; }
}
}

View File

@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using MediaBrowser.Model.Net;
namespace MediaBrowser.Controller
{
@ -66,7 +67,7 @@ namespace MediaBrowser.Controller
/// Gets the local ip address.
/// </summary>
/// <value>The local ip address.</value>
Task<List<IPAddress>> GetLocalIpAddresses();
Task<List<IpAddressInfo>> GetLocalIpAddresses();
/// <summary>
/// Gets the local API URL.
@ -84,9 +85,7 @@ namespace MediaBrowser.Controller
/// <summary>
/// Gets the local API URL.
/// </summary>
/// <param name="ipAddress">The ip address.</param>
/// <returns>System.String.</returns>
string GetLocalApiUrl(IPAddress ipAddress);
string GetLocalApiUrl(string ipAddress, bool isIpv6);
void LaunchUrl(string url);

View File

@ -12,9 +12,8 @@
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile7</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>

View File

@ -1,16 +1,7 @@
{
"supports": {
"net46.app": {},
"uwp.10.0.app": {},
"dnxcore50.app": {}
},
"dependencies": {
"Microsoft.NETCore": "5.0.0",
"Microsoft.NETCore.Portable.Compatibility": "1.0.0"
},
{
"supports": {},
"dependencies": {},
"frameworks": {
"dotnet": {
"imports": "portable-net452+win81"
}
".NETPortable,Version=v4.5,Profile=Profile7": {}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -249,7 +249,7 @@ namespace MediaBrowser.Dlna.Main
_logger.Info("Registering publisher for {0} on {1}", fullService, addressString);
var descriptorUri = "/dlna/" + udn + "/description.xml";
var uri = new Uri(_appHost.GetLocalApiUrl(address) + descriptorUri);
var uri = new Uri(_appHost.GetLocalApiUrl(addressString, address.IsIpv6) + descriptorUri);
var device = new SsdpRootDevice
{

View File

@ -11,6 +11,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Threading.Tasks;
using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Model.Events;
@ -124,7 +125,16 @@ namespace MediaBrowser.Dlna.PlayTo
if (controller == null)
{
var serverAddress = await GetServerAddress(info.LocalEndPoint == null ? null : info.LocalEndPoint.Address).ConfigureAwait(false);
string serverAddress;
if (info.LocalIpAddress == null)
{
serverAddress = await GetServerAddress(null, false).ConfigureAwait(false);
}
else
{
serverAddress = await GetServerAddress(info.LocalIpAddress.Address, info.LocalIpAddress.IsIpv6).ConfigureAwait(false);
}
string accessToken = null;
sessionInfo.SessionController = controller = new PlayToController(sessionInfo,
@ -176,14 +186,14 @@ namespace MediaBrowser.Dlna.PlayTo
}
}
private Task<string> GetServerAddress(IPAddress localIp)
private Task<string> GetServerAddress(string ipAddress, bool isIpv6)
{
if (localIp == null)
if (string.IsNullOrWhiteSpace(ipAddress))
{
return _appHost.GetLocalApiUrl();
}
return Task.FromResult(_appHost.GetLocalApiUrl(localIp));
return Task.FromResult(_appHost.GetLocalApiUrl(ipAddress, isIpv6));
}
public void Dispose()

View File

@ -166,6 +166,7 @@
<Compile Include="MediaInfo\SubtitleTrackInfo.cs" />
<Compile Include="Net\EndPointInfo.cs" />
<Compile Include="Net\HttpResponse.cs" />
<Compile Include="Net\IpAddressInfo.cs" />
<Compile Include="Services\ApiMemberAttribute.cs" />
<Compile Include="Services\IAsyncStreamWriter.cs" />
<Compile Include="Services\IHasHeaders.cs" />

View File

@ -0,0 +1,15 @@
using System;
namespace MediaBrowser.Model.Net
{
public class IpAddressInfo
{
public string Address { get; set; }
public bool IsIpv6 { get; set; }
public override String ToString()
{
return Address;
}
}
}

View File

@ -109,6 +109,7 @@ using MediaBrowser.Controller.Extensions;
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.Activity;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Net;
using MediaBrowser.Model.News;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Social;
@ -1333,7 +1334,7 @@ namespace MediaBrowser.Server.Startup.Common
try
{
// Return the first matched address, if found, or the first known local address
var address = (await GetLocalIpAddresses().ConfigureAwait(false)).FirstOrDefault(i => !IPAddress.IsLoopback(i));
var address = (await GetLocalIpAddressesInternal().ConfigureAwait(false)).FirstOrDefault(i => !IPAddress.IsLoopback(i));
if (address != null)
{
@ -1352,12 +1353,17 @@ namespace MediaBrowser.Server.Startup.Common
public string GetLocalApiUrl(IPAddress ipAddress)
{
if (ipAddress.AddressFamily == AddressFamily.InterNetworkV6)
return GetLocalApiUrl(ipAddress.ToString(), ipAddress.AddressFamily == AddressFamily.InterNetworkV6);
}
public string GetLocalApiUrl(string ipAddress, bool isIpv6)
{
if (isIpv6)
{
return GetLocalApiUrl("[" + ipAddress + "]");
}
return GetLocalApiUrl(ipAddress.ToString());
return GetLocalApiUrl(ipAddress);
}
public string GetLocalApiUrl(string host)
@ -1367,7 +1373,19 @@ namespace MediaBrowser.Server.Startup.Common
HttpPort.ToString(CultureInfo.InvariantCulture));
}
public async Task<List<IPAddress>> GetLocalIpAddresses()
public async Task<List<IpAddressInfo>> GetLocalIpAddresses()
{
var list = await GetLocalIpAddressesInternal().ConfigureAwait(false);
return list.Select(i => new IpAddressInfo
{
Address = i.ToString(),
IsIpv6 = i.AddressFamily == AddressFamily.InterNetworkV6
}).ToList();
}
private async Task<List<IPAddress>> GetLocalIpAddressesInternal()
{
// Need to do this until Common will compile with this method
var nativeNetworkManager = (BaseNetworkManager)NetworkManager;