当前位置: 首页>>代码示例>>C#>>正文


C# IPlatform.RewriteRemoteIpAddress方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:RetroRabbit,项目名称:Mike,代码行数:54,代码来源:MikeIds.cs


注:本文中的IPlatform.RewriteRemoteIpAddress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。