using log4net; 
 | 
using Microsoft.AspNetCore.Builder; 
 | 
using System; 
 | 
using System.Collections.Generic; 
 | 
using System.Linq; 
 | 
using System.Text; 
 | 
using System.Threading.Tasks; 
 | 
using WIDESEA_Core.Helper; 
 | 
  
 | 
namespace WIDESEA_Core.Middlewares 
 | 
{ 
 | 
    /// <summary> 
 | 
    /// ip 限流 
 | 
    /// </summary> 
 | 
    public static class IpLimitMiddleware 
 | 
    { 
 | 
        private static readonly ILog Log = LogManager.GetLogger(typeof(IpLimitMiddleware)); 
 | 
        /// <summary> 
 | 
        /// ip限流 
 | 
        /// </summary> 
 | 
        /// <param name="app"></param> 
 | 
        /// <exception cref="ArgumentNullException"></exception> 
 | 
        public static void UseIpLimitMiddle(this IApplicationBuilder app) 
 | 
        { 
 | 
            if (app == null) throw new ArgumentNullException(nameof(app)); 
 | 
  
 | 
            //try 
 | 
            //{ 
 | 
            //    if (AppSettings.app("Middleware", "IpRateLimit", "Enabled").ObjToBool()) 
 | 
            //    { 
 | 
            //        app.UseIpRateLimiting(); 
 | 
            //    } 
 | 
            //} 
 | 
            //catch (Exception e) 
 | 
            //{ 
 | 
            //    Log.Error($"Error occured limiting ip rate.\n{e.Message}"); 
 | 
            //    throw; 
 | 
            //} 
 | 
        } 
 | 
    } 
 | 
} 
 |