aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Connect
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-04-16 15:26:00 -0400
committerLuke <luke.pulverenti@gmail.com>2016-04-16 15:26:00 -0400
commit18dbdb194b6db75c1acb5457e9797d8b37150c07 (patch)
treef23d3d169ba1d6befcee6b0262133e778e815323 /MediaBrowser.Server.Implementations/Connect
parent007f4e193af99036b250a8323f92b753a9b74797 (diff)
parented6d8ae87f95acecc4636004574b551e3dc5b0fe (diff)
Merge pull request #1653 from MediaBrowser/beta
Beta
Diffstat (limited to 'MediaBrowser.Server.Implementations/Connect')
-rw-r--r--MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs2
-rw-r--r--MediaBrowser.Server.Implementations/Connect/ConnectManager.cs38
2 files changed, 31 insertions, 9 deletions
diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs b/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs
index 1b951374e..ea12e332d 100644
--- a/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs
+++ b/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs
@@ -10,10 +10,8 @@ using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
-using System.Threading;
using System.Threading.Tasks;
using CommonIO;
-using MediaBrowser.Common.IO;
using MediaBrowser.Common.Threading;
namespace MediaBrowser.Server.Implementations.Connect
diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs
index ac0d2c569..f3d545492 100644
--- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs
+++ b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs
@@ -24,6 +24,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
+using MediaBrowser.Common.Extensions;
namespace MediaBrowser.Server.Implementations.Connect
{
@@ -62,6 +63,17 @@ namespace MediaBrowser.Server.Implementations.Connect
{
var address = _config.Configuration.WanDdns;
+ if (!string.IsNullOrWhiteSpace(address))
+ {
+ try
+ {
+ address = new Uri(address).Host;
+ }
+ catch
+ {
+ }
+ }
+
if (string.IsNullOrWhiteSpace(address) && DiscoveredWanIpAddress != null)
{
if (DiscoveredWanIpAddress.AddressFamily == AddressFamily.InterNetworkV6)
@@ -237,8 +249,8 @@ namespace MediaBrowser.Server.Implementations.Connect
var postData = new Dictionary<string, string>
{
- {"name", _appHost.FriendlyName},
- {"url", wanApiAddress},
+ {"name", _appHost.FriendlyName},
+ {"url", wanApiAddress},
{"systemId", _appHost.SystemId}
};
@@ -544,9 +556,22 @@ namespace MediaBrowser.Server.Implementations.Connect
}
catch (HttpException ex)
{
- if (!ex.StatusCode.HasValue ||
- ex.StatusCode.Value != HttpStatusCode.NotFound ||
- !Validator.EmailIsValid(connectUsername))
+ if (!ex.StatusCode.HasValue)
+ {
+ throw;
+ }
+
+ // If they entered a username, then whatever the error is just throw it, for example, user not found
+ if (!Validator.EmailIsValid(connectUsername))
+ {
+ if (ex.StatusCode.Value == HttpStatusCode.NotFound)
+ {
+ throw new ResourceNotFoundException();
+ }
+ throw;
+ }
+
+ if (ex.StatusCode.Value != HttpStatusCode.NotFound)
{
throw;
}
@@ -891,8 +916,7 @@ namespace MediaBrowser.Server.Implementations.Connect
private async Task RefreshGuestNames(List<ServerUserAuthorizationResponse> list, bool refreshImages)
{
var users = _userManager.Users
- .Where(i => !string.IsNullOrEmpty(i.ConnectUserId) &&
- (i.ConnectLinkType.HasValue && i.ConnectLinkType.Value == UserLinkType.Guest))
+ .Where(i => !string.IsNullOrEmpty(i.ConnectUserId) && i.ConnectLinkType.HasValue && i.ConnectLinkType.Value == UserLinkType.Guest)
.ToList();
foreach (var user in users)