Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
msmolka committed Dec 22, 2017
1 parent 96be73d commit 305fcc0
Showing 1 changed file with 31 additions and 35 deletions.
66 changes: 31 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,25 @@ using ZNetCS.AspNetCore.IPFiltering.DependencyInjection;
```csharp
public void ConfigureServices(IServiceCollection services)
{
services.AddIPFiltering();
services.AddIPFiltering(this.Configuration.GetSection("IPFiltering"));
}
```
or

```csharp
public void ConfigureServices(IServiceCollection services)
{
services.AddIPFiltering(
opts =>
{
opts.DefaultBlockLevel = DefaultBlockLevel.All;
opts.HttpStatusCode = HttpStatusCode.NotFound;
opts.Blacklist = new List<string> { "192.168.0.100-192.168.1.200" };
opts.Whitelist = new List<string> { "192.168.0.10-192.168.10.20", "fe80::/10" };
});
}
```
```csharp
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.UseIPFiltering();
Expand All @@ -49,6 +65,20 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
}
```

## File
Middleware can be configured in `appsettings.json` file. By adding following section and use following `ConfigureServices` method:

```json
{
"IPFiltering": {
"DefaultBlockLevel": "All",
"HttpStatusCode": 404,
"Whitelist": [ "192.168.0.10-192.168.10.20", "fe80::/10" ],
"Blacklist": [ "192.168.0.100-192.168.1.200"]
}
}
```

## Configuration
This middleware can be configured using following configuration options:

Expand All @@ -65,37 +95,3 @@ package: https://github.com/jsakamoto/ipaddressrange. Ranges can be defined in f
* `192.168.0.10-192.168.10.20`
* `fe80::/10`

## File
Middleware can be configured in `appsettings.json` file. By adding following section and use following `ConfigureServices` method:

```json
{
"IPFiltering": {
"DefaultBlockLevel": "All",
"HttpStatusCode": 404,
"Whitelist": [ "192.168.0.10-192.168.10.20", "fe80::/10" ],
"Blacklist": [ "192.168.0.100-192.168.1.200"]
}
}
```

```csharp
public void ConfigureServices(IServiceCollection services)
{
services.AddIPFiltering(this.Configuration.GetSection("IPFiltering"));
}
```

```csharp
public void ConfigureServices(IServiceCollection services)
{
services.AddIPFiltering(
opts =>
{
opts.DefaultBlockLevel = DefaultBlockLevel.All;
opts.HttpStatusCode = HttpStatusCode.NotFound;
opts.Blacklist = new List<string> { "192.168.0.100-192.168.1.200" };
opts.Whitelist = new List<string> { "192.168.0.10-192.168.10.20", "fe80::/10" };
});
}
```

0 comments on commit 305fcc0

Please sign in to comment.