mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-07-07 07:00:33 -04:00
Removed NioTSO client and server
- NioTSO client isn't needed because we're using RayLib - Added FreeSO's API server to handle most backend operations
This commit is contained in:
parent
f12ba1502b
commit
22191ce648
591 changed files with 53264 additions and 3362 deletions
35
server/FSO.Server.Api.Core/Utils/ApiUtils.cs
Executable file
35
server/FSO.Server.Api.Core/Utils/ApiUtils.cs
Executable file
|
@ -0,0 +1,35 @@
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using System.Linq;
|
||||
|
||||
namespace FSO.Server.Api.Core.Utils
|
||||
{
|
||||
public class ApiUtils
|
||||
{
|
||||
private const string HttpContext = "MS_HttpContext";
|
||||
private const string RemoteEndpointMessage =
|
||||
"System.ServiceModel.Channels.RemoteEndpointMessageProperty";
|
||||
private const string OwinContext = "MS_OwinContext";
|
||||
|
||||
public static string GetIP(HttpRequest request)
|
||||
{
|
||||
var api = FSO.Server.Api.Core.Api.INSTANCE;
|
||||
if (!api.Config.UseProxy)
|
||||
{
|
||||
return request.HttpContext.Connection.RemoteIpAddress.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
var ip = "127.0.0.1";
|
||||
var xff = request.Headers["X-Forwarded-For"];
|
||||
if (xff.Count != 0)
|
||||
{
|
||||
ip = xff.First();
|
||||
ip = ip.Substring(ip.IndexOf(",") + 1);
|
||||
var last = ip.LastIndexOf(":");
|
||||
if (last != -1 && last < ip.Length - 5) ip = ip.Substring(0, last);
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue