SimpleW.Service.Firewall 26.0.1

dotnet add package SimpleW.Service.Firewall --version 26.0.1
                    
NuGet\Install-Package SimpleW.Service.Firewall -Version 26.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SimpleW.Service.Firewall" Version="26.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SimpleW.Service.Firewall" Version="26.0.1" />
                    
Directory.Packages.props
<PackageReference Include="SimpleW.Service.Firewall" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SimpleW.Service.Firewall --version 26.0.1
                    
#r "nuget: SimpleW.Service.Firewall, 26.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SimpleW.Service.Firewall@26.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SimpleW.Service.Firewall&version=26.0.1
                    
Install as a Cake Addin
#tool nuget:?package=SimpleW.Service.Firewall&version=26.0.1
                    
Install as a Cake Tool

SimpleW.Service.Firewall

website

NuGet Package NuGet Downloads License

Features

This package provides an application-level firewall for SimpleW:

  • global allow and deny rules by IP/CIDR
  • global allow and deny rules by country with MaxMind GeoIP2
  • handler-level firewall rules using SimpleW handler metadata attributes
  • fixed-window and sliding-window rate limiting
  • IP/CIDR whitelist for trusted clients that bypass rate limiting
  • bounded per-IP state with TTL cleanup
  • optional telemetry counters and gauges

Getting Started

using System.Net;
using SimpleW;
using SimpleW.Service.Firewall;

var server = new SimpleWServer(IPAddress.Any, 2015);

server.UseFirewallModule(fw => {
    fw.AllowRules.Add(IpRule.Cidr("10.0.0.0/8"));
    fw.AllowRules.Add(IpRule.Single("127.0.0.1"));

    fw.GlobalRateLimit = new RateLimitOptions {
        Limit = 200,
        Window = TimeSpan.FromSeconds(10)
    };
    fw.RateLimitWhitelistRules.Add(IpRule.Cidr("10.0.0.0/8"));
});

server.MapController<AdminController>("/api");

await server.RunAsync();

[Route("/admin")]
public sealed class AdminController : Controller
{
    [FirewallAllowIp("192.168.1.0/24")]
    [FirewallRateLimit(20, 10, FirewallRateLimitWindowUnit.Seconds)]
    [Route("GET", "/dashboard")]
    public object Dashboard()
    {
        return new { ok = true };
    }
}

Global rules apply to handlers that do not declare firewall metadata. As soon as a handler has at least one firewall attribute, its handler policy replaces global allow/deny/country rules. Handler rate limits override the global rate limit; if no handler rate limit is declared, the global rate limit still applies. IP/CIDR entries in RateLimitWhitelistRules bypass both global and handler rate limits, but they do not bypass allow or deny rules.

Handler Attributes

[FirewallAllowIp("192.168.1.0/24", "127.0.0.1")]
[FirewallDenyIp("203.0.113.10")]
[FirewallAllowCountry("FR", "BE", "CH")]
[FirewallDenyCountry("RU", "CN")]
[FirewallAllowUnknownCountry]
[FirewallDenyUnknownCountry]
[FirewallRateLimit(5, 30, FirewallRateLimitWindowUnit.Seconds, slidingWindow: true)]

Attributes work on controller classes, controller methods, and non-inline delegate methods. Class metadata is evaluated before method metadata; method rate-limit metadata wins when both class and method declare one.

Notes

  • PathRule / PathRules has been removed in favor of handler metadata.
  • Static files, fallback routes, and anonymous inline lambdas cannot carry attributes directly. Use global rules for those, or route through decorated handlers.
  • The firewall uses session.ClientIpAddress, so reverse proxy setups should configure server.ConfigureClientIPResolver(...).

Documentation

To check out docs, visit simplew.net.

Changelog

Detailed changes for each release are documented in the CHANGELOG.

License

This library is under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
26.0.1 92 6/20/2026
26.0.0 207 4/26/2026
Loading failed