mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
ipv6 fixes
This commit is contained in:
parent
c3ad2c47db
commit
aa23da0dc4
@ -79,5 +79,12 @@ namespace MediaBrowser.Controller
|
|||||||
/// <param name="host">The host.</param>
|
/// <param name="host">The host.</param>
|
||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
string GetLocalApiUrl(string host);
|
string GetLocalApiUrl(string host);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the local API URL.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ipAddress">The ip address.</param>
|
||||||
|
/// <returns>System.String.</returns>
|
||||||
|
string GetLocalApiUrl(IPAddress ipAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ namespace MediaBrowser.Dlna.Main
|
|||||||
|
|
||||||
var descriptorURI = "/dlna/" + udn + "/description.xml";
|
var descriptorURI = "/dlna/" + udn + "/description.xml";
|
||||||
|
|
||||||
var uri = new Uri(_appHost.GetLocalApiUrl(addressString) + descriptorURI);
|
var uri = new Uri(_appHost.GetLocalApiUrl(address) + descriptorURI);
|
||||||
|
|
||||||
var services = new List<string>
|
var services = new List<string>
|
||||||
{
|
{
|
||||||
|
@ -171,7 +171,7 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||||||
|
|
||||||
private string GetServerAddress(IPAddress localIp)
|
private string GetServerAddress(IPAddress localIp)
|
||||||
{
|
{
|
||||||
return _appHost.GetLocalApiUrl(localIp.ToString());
|
return _appHost.GetLocalApiUrl(localIp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
@ -81,6 +81,12 @@ namespace MediaBrowser.Server.Implementations.Connect
|
|||||||
if (!ip.StartsWith("http://", StringComparison.OrdinalIgnoreCase) &&
|
if (!ip.StartsWith("http://", StringComparison.OrdinalIgnoreCase) &&
|
||||||
!ip.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
|
!ip.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
|
// Handle ipv6
|
||||||
|
if (ip.IndexOf(':') != -1)
|
||||||
|
{
|
||||||
|
ip = "[" + ip + "]";
|
||||||
|
}
|
||||||
|
|
||||||
ip = (_appHost.EnableHttps ? "https://" : "http://") + ip;
|
ip = (_appHost.EnableHttps ? "https://" : "http://") + ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,7 +322,7 @@ namespace MediaBrowser.Server.Implementations.Connect
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
|
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
|
||||||
|
|
||||||
var json = _json.SerializeToString(_data);
|
var json = _json.SerializeToString(_data);
|
||||||
|
|
||||||
@ -324,7 +330,7 @@ namespace MediaBrowser.Server.Implementations.Connect
|
|||||||
|
|
||||||
lock (_dataFileLock)
|
lock (_dataFileLock)
|
||||||
{
|
{
|
||||||
_fileSystem.WriteAllText(path, encrypted, Encoding.UTF8);
|
_fileSystem.WriteAllText(path, encrypted, Encoding.UTF8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -341,7 +347,7 @@ namespace MediaBrowser.Server.Implementations.Connect
|
|||||||
{
|
{
|
||||||
lock (_dataFileLock)
|
lock (_dataFileLock)
|
||||||
{
|
{
|
||||||
var encrypted = _fileSystem.ReadAllText(path, Encoding.UTF8);
|
var encrypted = _fileSystem.ReadAllText(path, Encoding.UTF8);
|
||||||
|
|
||||||
var json = _encryption.DecryptString(encrypted);
|
var json = _encryption.DecryptString(encrypted);
|
||||||
|
|
||||||
@ -381,7 +387,7 @@ namespace MediaBrowser.Server.Implementations.Connect
|
|||||||
{
|
{
|
||||||
await UpdateConnectInfo().ConfigureAwait(false);
|
await UpdateConnectInfo().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
await _operationLock.WaitAsync().ConfigureAwait(false);
|
await _operationLock.WaitAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -480,7 +486,7 @@ namespace MediaBrowser.Server.Implementations.Connect
|
|||||||
{
|
{
|
||||||
await UpdateConnectInfo().ConfigureAwait(false);
|
await UpdateConnectInfo().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
await _operationLock.WaitAsync().ConfigureAwait(false);
|
await _operationLock.WaitAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -97,6 +97,7 @@ using System.Globalization;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -322,7 +323,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|||||||
{
|
{
|
||||||
TaskManager.SuspendTriggers = true;
|
TaskManager.SuspendTriggers = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
await base.RunStartupTasks().ConfigureAwait(false);
|
await base.RunStartupTasks().ConfigureAwait(false);
|
||||||
|
|
||||||
Logger.Info("ServerId: {0}", SystemId);
|
Logger.Info("ServerId: {0}", SystemId);
|
||||||
@ -1134,7 +1135,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|||||||
|
|
||||||
if (address != null)
|
if (address != null)
|
||||||
{
|
{
|
||||||
return GetLocalApiUrl(address.ToString());
|
return GetLocalApiUrl(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -1148,6 +1149,16 @@ namespace MediaBrowser.Server.Startup.Common
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetLocalApiUrl(IPAddress ipAddress)
|
||||||
|
{
|
||||||
|
if (ipAddress.AddressFamily == AddressFamily.InterNetworkV6)
|
||||||
|
{
|
||||||
|
return GetLocalApiUrl("[" + ipAddress + "]");
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetLocalApiUrl(ipAddress.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
public string GetLocalApiUrl(string host)
|
public string GetLocalApiUrl(string host)
|
||||||
{
|
{
|
||||||
return string.Format("http://{0}:{1}",
|
return string.Format("http://{0}:{1}",
|
||||||
@ -1180,7 +1191,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var apiUrl = GetLocalApiUrl(address.ToString());
|
var apiUrl = GetLocalApiUrl(address);
|
||||||
apiUrl += "/system/ping";
|
apiUrl += "/system/ping";
|
||||||
|
|
||||||
if ((DateTime.UtcNow - _lastAddressCacheClear).TotalMinutes >= 5)
|
if ((DateTime.UtcNow - _lastAddressCacheClear).TotalMinutes >= 5)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user