本文整理汇总了C#中IPlatform.RewriteRemoteIpAddress方法的典型用法代码示例。如果您正苦于以下问题:C# IPlatform.RewriteRemoteIpAddress方法的具体用法?C# IPlatform.RewriteRemoteIpAddress怎么用?C# IPlatform.RewriteRemoteIpAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPlatform
的用法示例。
在下文中一共展示了IPlatform.RewriteRemoteIpAddress方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TakeActionBasedOnReportAsync
/// <summary>
/// Takes any actions recommended by a report. Returns a <see cref="bool"/> indicating
/// whether or not the request may still be handled by downstream middleware. When <see cref="TakeActionBasedOnReportAsync(Report, Mike.IPlatform)"/>
/// returns <c>false</c>, the request must end after the call. If it returns <c>true</c>
/// the request must be handed to downstream middleware.
/// </summary>
/// <param name="report">The report to action on.</param>
/// <param name="platform">A platform providing Mike a way to interact with the hosting environment.</param>
/// <returns>
/// <c>true</c> if downstream middleware must still handle the request, or <c>false</c>
/// if the response has already been sent to the client and downstream middleware cannot
/// handle the request anymore.
/// </returns>
public async Task<bool> TakeActionBasedOnReportAsync(Report report, IPlatform platform)
{
if (report.RemoteAddressRewriteAdvised && !Configuration.DontAllowRewriteOfRemoteIpAddress)
{
platform.RewriteRemoteIpAddress(report.RemoteAddress);
}
IntrusionAction actionToTake = IntrusionAction.None;
if (report.IntrusionDetected)
{
if(report.IsXhr)
{
actionToTake = Configuration.ActionWhenIntrusionDetectedXhr;
}
else
{
actionToTake = Configuration.ActionWhenIntrusionDetected;
}
}
if (actionToTake == IntrusionAction.None && report.RateLimitReached)
{
if (report.IsXhr)
{
actionToTake = Configuration.ActionWhenRateLimitReachedXhr;
}
else
{
actionToTake = Configuration.ActionWhenRateLimitReached;
}
}
if (actionToTake == IntrusionAction.None)
{
return true;
}
else
{
return await TakeActionAsync(report, actionToTake, platform);
}
}