mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
normalize remote ip
This commit is contained in:
parent
b959b7d447
commit
1055c1c77e
@ -136,11 +136,27 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
|
|||||||
{
|
{
|
||||||
return remoteIp ??
|
return remoteIp ??
|
||||||
(remoteIp = XForwardedFor ??
|
(remoteIp = XForwardedFor ??
|
||||||
(XRealIp ??
|
(NormalizeIp(XRealIp) ??
|
||||||
((request.RemoteEndPoint != null) ? request.RemoteEndPoint.Address.ToString() : null)));
|
((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
|
public bool IsSecureConnection
|
||||||
{
|
{
|
||||||
get { return request.IsSecureConnection || XForwardedProtocol == "https"; }
|
get { return request.IsSecureConnection || XForwardedProtocol == "https"; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user