update connection

This commit is contained in:
Luke Pulverenti
2016-03-25 12:23:48 -04:00
parent ae684cf0a5
commit e619a0dc90
2 changed files with 87 additions and 58 deletions

View File

@@ -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;