Code Monkey home page Code Monkey logo

znetcs.aspnetcore.ipfiltering's People

Contributors

msmolka avatar v1rusyra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

znetcs.aspnetcore.ipfiltering's Issues

Ip Proxy Reverse

Thanks for your contribution, I have a configuration where the web api receives a request only from a reverse proxy, but in the console it shows me the IP of the final client and I want to validate the IP of the proxy in this case, is it possible?

DI resolution error during startup.

netcoreapp2.0 where I followed the setup, but gets:

Cannot resolve scoped service 'Microsoft.Extensions.Options.IOptionsSnapshot`1[ZNetCS.AspNetCore.IPFiltering.IPFilteringOptions]' from root provider.

Uses:

IP Filter

Any objections to me submitting a pull request that adds IP filtering as a MVC filter? This would bring in a new dependencies of Microsoft.AspNetCore.Mvc.Abstractions.

My thoughts here would be an attribute that could be applied either at the class or method level. Something like [IPFilter(Policy = "MyPolicy")] This would allow for either white listing, black listing at a more granular level than at the middle ware level.

Thanks!

Ignoring paths separately for each Black-listed Ip

I have two Ips which I've black-listed:

"Blacklist": [ "127.0.0.1", "192.168.0.1" ]

I want to ignore paths separately for each of them:

i.e. for "127.0.0.1"
"IgnoredPaths": [ "POST:/*" ]

and for "192.168.0.1"
"IgnoredPaths": [ "GET:/*" ]

Is there any way to do that?

Fatal error

@msmolka I got a fatal error as follows:

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at AspNetCoreRateLimit.Bits.GetBitMask(Int32 sizeOfBuff, Int32 bitLen)
   at AspNetCoreRateLimit.IpAddressRange..ctor(String ipRangeString)
   at AspNetCoreRateLimit.IpAddressUtil.ContainsIp(List`1 ipRules, String clientIp)
   at AspNetCoreRateLimit.IpParser.ContainsIp(List`1 ipRules, String clientIp)
   at AspNetCoreRateLimit.IpRateLimitProcessor.IsWhitelisted(ClientRequestIdentity requestIdentity)
   at AspNetCoreRateLimit.RateLimitMiddleware`1.Invoke(HttpContext context)
   at ZNetCS.AspNetCore.IPFiltering.IPFilteringMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)

Just parse IP ranges once

This library appears to parse the allowed IP ranges on every call to IPAddressChecker.IsAllowed:

var whitelist = optWhitelist.Select(IPAddressRange.Parse).ToList();
var blacklist = optBlacklist.Select(IPAddressRange.Parse).ToList();

However, the config will very rarely change between requests, so it'd be more efficient to only parse these once and reuse the same objects across requests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.