mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-07 20:08:59 +02:00
Handle null values for RemoteIpAddress and LocalIpAddress in websocket requests
These values are null when creating fake web requests as part of integration tests
This commit is contained in:
parent
32ccab32bf
commit
3cf2fce983
1 changed files with 7 additions and 1 deletions
|
@ -62,6 +62,9 @@ namespace Emby.Server.Implementations.SocketSharp
|
||||||
if (!IPAddress.TryParse(GetHeader(CustomHeaderNames.XRealIP), out ip))
|
if (!IPAddress.TryParse(GetHeader(CustomHeaderNames.XRealIP), out ip))
|
||||||
{
|
{
|
||||||
ip = Request.HttpContext.Connection.RemoteIpAddress;
|
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.SocketSharp
|
||||||
|
|
||||||
public IQueryCollection QueryString => Request.Query;
|
public 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;
|
public string HttpMethod => Request.Method;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue