Add project files.

This commit is contained in:
2025-08-18 17:11:43 +03:30
parent 807dc263be
commit e5eb10d604
3943 changed files with 223719 additions and 0 deletions
@@ -0,0 +1,25 @@
using System.Net;
using Microsoft.AspNetCore.Http;
namespace Elsa.Extensions;
/// <summary>
/// Extension methods for <see cref="HttpRequest"/>.
/// </summary>
public static class HttpRequestExtensions
{
/// <summary>
/// Returns a value indicating whether the specified request is a local request.
/// </summary>
/// <param name="request"></param>
/// <returns>True if the request is local, otherwise false.</returns>
public static bool IsLocal(this HttpRequest request)
{
var connection = request.HttpContext.Connection;
return connection.RemoteIpAddress != null
? connection.LocalIpAddress != null
? connection.RemoteIpAddress.Equals(connection.LocalIpAddress)
: IPAddress.IsLoopback(connection.RemoteIpAddress)
: connection.RemoteIpAddress == null && connection.LocalIpAddress == null;
}
}