mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-22 18:14:42 +01:00
update connection
This commit is contained in:
@@ -19,6 +19,7 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -53,7 +54,7 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||
get { return _data.AccessKey; }
|
||||
}
|
||||
|
||||
public string DiscoveredWanIpAddress { get; private set; }
|
||||
private IPAddress DiscoveredWanIpAddress { get; set; }
|
||||
|
||||
public string WanIpAddress
|
||||
{
|
||||
@@ -61,9 +62,16 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||
{
|
||||
var address = _config.Configuration.WanDdns;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(address))
|
||||
if (string.IsNullOrWhiteSpace(address) && DiscoveredWanIpAddress != null)
|
||||
{
|
||||
address = DiscoveredWanIpAddress;
|
||||
if (DiscoveredWanIpAddress.AddressFamily == AddressFamily.InterNetworkV6)
|
||||
{
|
||||
address = "[" + DiscoveredWanIpAddress + "]";
|
||||
}
|
||||
else
|
||||
{
|
||||
address = DiscoveredWanIpAddress.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
return address;
|
||||
@@ -81,12 +89,6 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||
if (!ip.StartsWith("http://", StringComparison.OrdinalIgnoreCase) &&
|
||||
!ip.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Handle ipv6
|
||||
if (ip.IndexOf(':') != -1)
|
||||
{
|
||||
ip = "[" + ip + "]";
|
||||
}
|
||||
|
||||
ip = (_appHost.EnableHttps ? "https://" : "http://") + ip;
|
||||
}
|
||||
|
||||
@@ -130,7 +132,7 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||
LoadCachedData();
|
||||
}
|
||||
|
||||
internal void OnWanAddressResolved(string address)
|
||||
internal void OnWanAddressResolved(IPAddress address)
|
||||
{
|
||||
DiscoveredWanIpAddress = address;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user