aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations')
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs20
-rw-r--r--MediaBrowser.Server.Implementations/Security/AuthenticationRepository.cs12
2 files changed, 30 insertions, 2 deletions
diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs
index b3fbd2d1d..5df37118d 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs
@@ -136,11 +136,27 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
{
return remoteIp ??
(remoteIp = XForwardedFor ??
- (XRealIp ??
- ((request.RemoteEndPoint != null) ? request.RemoteEndPoint.Address.ToString() : null)));
+ (NormalizeIp(XRealIp) ??
+ ((request.RemoteEndPoint != null) ? NormalizeIp(request.RemoteEndPoint.Address.ToString()) : null)));
}
}
+ private string NormalizeIp(string ip)
+ {
+ if (!string.IsNullOrWhiteSpace(ip))
+ {
+ // Handle ipv4 mapped to ipv6
+ const string srch = "::ffff:";
+ var index = ip.IndexOf(srch, StringComparison.OrdinalIgnoreCase);
+ if (index == 0)
+ {
+ ip = ip.Substring(srch.Length);
+ }
+ }
+
+ return ip;
+ }
+
public bool IsSecureConnection
{
get { return request.IsSecureConnection || XForwardedProtocol == "https"; }
diff --git a/MediaBrowser.Server.Implementations/Security/AuthenticationRepository.cs b/MediaBrowser.Server.Implementations/Security/AuthenticationRepository.cs
index df7cc47f4..b36db51b3 100644
--- a/MediaBrowser.Server.Implementations/Security/AuthenticationRepository.cs
+++ b/MediaBrowser.Server.Implementations/Security/AuthenticationRepository.cs
@@ -185,6 +185,18 @@ namespace MediaBrowser.Server.Implementations.Security
cmd.Parameters.Add(cmd, "@IsActive", DbType.Boolean).Value = query.IsActive.Value;
}
+ if (query.HasUser.HasValue)
+ {
+ if (query.HasUser.Value)
+ {
+ whereClauses.Add("UserId not null");
+ }
+ else
+ {
+ whereClauses.Add("UserId is null");
+ }
+ }
+
var whereTextWithoutPaging = whereClauses.Count == 0 ?
string.Empty :
" where " + string.Join(" AND ", whereClauses.ToArray());