The Free Software Media System - Server Backend & API
Handle null values for RemoteIpAddress and LocalIpAddress in websocket requests
Mark Monteiro3cf2fce983fa
diff --git a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.csindex 1781df8b51..f27f7eeb86 100644--- a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs+++ b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs@@ -62,6 +62,9 @@ namespace Emby.Server.Implementations.SocketSharpif (!IPAddress.TryParse(GetHeader(CustomHeaderNames.XRealIP), out ip)){ip = Request.HttpContext.Connection.RemoteIpAddress;++ // Default to the loopback address if no RemoteIpAddress is specified (i.e. during integration tests)+ ip ??= IPAddress.Loopback;}}@@ -89,7 +92,10 @@ namespace Emby.Server.Implementations.SocketSharppublic IQueryCollection QueryString => Request.Query;- public bool IsLocal => Request.HttpContext.Connection.LocalIpAddress.Equals(Request.HttpContext.Connection.RemoteIpAddress);+ public bool IsLocal =>+ (Request.HttpContext.Connection.LocalIpAddress == null+ && Request.HttpContext.Connection.RemoteIpAddress == null)+ || Request.HttpContext.Connection.LocalIpAddress.Equals(Request.HttpContext.Connection.RemoteIpAddress);public string HttpMethod => Request.Method;