Skip to content

Commit

Permalink
Merge pull request #25 from odysseus1973/master
Browse files Browse the repository at this point in the history
Adding wildcard matcher to policy
  • Loading branch information
stefanprodan committed Aug 26, 2017
2 parents ae890c9 + 68c1b1b commit b2f6d99
Show file tree
Hide file tree
Showing 17 changed files with 362 additions and 7 deletions.
3 changes: 1 addition & 2 deletions AspNetCoreRateLimit.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.8
VisualStudioVersion = 15.0.26430.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{909648ED-E1F4-4DAE-A274-AEC47BE826F3}"
EndProject
Expand Down
48 changes: 48 additions & 0 deletions Backup/AspNetCoreRateLimit.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{909648ED-E1F4-4DAE-A274-AEC47BE826F3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C3997747-D4C9-4E9F-866D-F5B6D10CD40F}"
ProjectSection(SolutionItems) = preProject
global.json = global.json
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "KestrelRateLimit", "src\AspNetCoreRateLimit\AspNetCoreRateLimit.xproj", "{E9557798-3499-4726-BCB7-5EB7CB4B33E7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{83B05009-1BC7-4E56-8D4B-0E107CA4D45B}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "KestrelRateLimit.Demo", "test\AspNetCoreRateLimit.Demo\AspNetCoreRateLimit.Demo.xproj", "{14C9FF9D-E50A-4A66-AEAB-F2C113743B95}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "KestrelRateLimit.Tests", "test\AspNetCoreRateLimit.Tests\AspNetCoreRateLimit.Tests.xproj", "{0A7C0247-AE46-4068-AE42-F955AE2A1D0E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E9557798-3499-4726-BCB7-5EB7CB4B33E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E9557798-3499-4726-BCB7-5EB7CB4B33E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E9557798-3499-4726-BCB7-5EB7CB4B33E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E9557798-3499-4726-BCB7-5EB7CB4B33E7}.Release|Any CPU.Build.0 = Release|Any CPU
{14C9FF9D-E50A-4A66-AEAB-F2C113743B95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{14C9FF9D-E50A-4A66-AEAB-F2C113743B95}.Debug|Any CPU.Build.0 = Debug|Any CPU
{14C9FF9D-E50A-4A66-AEAB-F2C113743B95}.Release|Any CPU.ActiveCfg = Release|Any CPU
{14C9FF9D-E50A-4A66-AEAB-F2C113743B95}.Release|Any CPU.Build.0 = Release|Any CPU
{0A7C0247-AE46-4068-AE42-F955AE2A1D0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0A7C0247-AE46-4068-AE42-F955AE2A1D0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A7C0247-AE46-4068-AE42-F955AE2A1D0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A7C0247-AE46-4068-AE42-F955AE2A1D0E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{E9557798-3499-4726-BCB7-5EB7CB4B33E7} = {909648ED-E1F4-4DAE-A274-AEC47BE826F3}
{14C9FF9D-E50A-4A66-AEAB-F2C113743B95} = {83B05009-1BC7-4E56-8D4B-0E107CA4D45B}
{0A7C0247-AE46-4068-AE42-F955AE2A1D0E} = {83B05009-1BC7-4E56-8D4B-0E107CA4D45B}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions Backup/global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"projects": [ "src", "test"],
"sdk": {
"version": "1.0.0-preview2-003121"
}
}
19 changes: 19 additions & 0 deletions Backup/src/AspNetCoreRateLimit/AspNetCoreRateLimit.xproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>e9557798-3499-4726-bcb7-5eb7cb4b33e7</ProjectGuid>
<RootNamespace>AspNetCoreRateLimit</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
28 changes: 28 additions & 0 deletions Backup/src/AspNetCoreRateLimit/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"version": "1.0.5",
"description": "ASP.NET Core rate limiting middleware",
"authors": [ "Stefan Prodan" ],
"packOptions": {
"tags": [ "aspnetcore", "rate-limit", "throttle" ],
"projectUrl": "https://github.com/stefanprodan/AspNetCoreRateLimit",
"licenseUrl": "http://opensource.org/licenses/MIT",
"summary": "AspNetCoreRateLimit is an ASP.NET Core rate limiting solution designed to control the rate of requests that clients can make to a Web API or MVC app based on IP address or client ID.",
"copyright": "Copyright © Stefan Prodan 2016",
"repository": {
"type": "git",
"url": "https://github.com/stefanprodan/AspNetCoreRateLimit"
}
},
"dependencies": {
"Microsoft.AspNetCore.Mvc": "1.0.1",
"NETStandard.Library": "1.6.0"
},

"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
},
"net46": {
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>14c9ff9d-e50a-4a66-aeab-f2c113743b95</ProjectGuid>
<RootNamespace>AspNetCoreRateLimit.Demo</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet.Web\Microsoft.DotNet.Web.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
60 changes: 60 additions & 0 deletions Backup/test/AspNetCoreRateLimit.Demo/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"AspNetCoreRateLimit": {
"version": "1.0.1-*",
"target": "project"
},
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1"
},

"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},

"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},

"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},

"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},

"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
},

"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>0a7c0247-ae46-4068-ae42-f955ae2a1d0e</ProjectGuid>
<RootNamespace>AspNetCoreRateLimit.Tests</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
39 changes: 39 additions & 0 deletions Backup/test/AspNetCoreRateLimit.Tests/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"version": "1.0.0-*",

"dependencies": {
"dotnet-test-xunit": "1.0.0-rc2-*",
"AspNetCoreRateLimit": {
"version": "1.0.1-*",
"target": "project"
},
"AspNetCoreRateLimit.Demo": {
"version": "1.0.0-*",
"target": "project"
},
"Microsoft.AspNetCore.TestHost": "1.0.0",
"xunit": "2.1.0"
},
"buildOptions": {
"copyToOutput": {
"include": [ "appsettings.json" ]
}
},
"testRunner": "xunit",
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"System.Diagnostics.Process": "4.1.0-*",
"System.Diagnostics.TraceSource": "4.0.0"
},
"imports": [
"dotnet5.6",
"portable-net451+win8"
]
}
}
}
Binary file added UpgradeLog.htm
Binary file not shown.
22 changes: 22 additions & 0 deletions sh.exe.stackdump
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Exception: STATUS_STACK_OVERFLOW at rip=7FFCA929AAB7
rax=0000000000001058 rbx=00000000000A0BE0 rcx=2DAF1A30BD8C0000
rdx=0000000000000001 rsi=00000000000A4D3C rdi=0000000000000001
r8 =000000000008980C r9 =000000000000001B r10=00000000FFFFA000
r11=00000000FFE03D70 r12=0000000000000424 r13=00000000000A4D20
r14=0000000000000000 r15=0000000000000000
rbp=00000000000A0BE0 rsp=00000000FFFFB450
program=C:\Users\a.lebedev\AppData\Local\GitHubDesktop\app-0.6.1\resources\app\git\usr\bin\sh.exe, pid 8484, thread unknown (0x2D2C)
cs=0033 ds=002B es=002B fs=0053 gs=002B ss=002B
Stack trace:
Frame Function Args
000000A0BE0 7FFCA929AAB7 (00180010018, 00000083DBC, 000000A4D3C, 7FFC00000002)
000000A0BE0 7FFCA53E637A (00000083DBC, 000000A4D3C, 7FFC00000002, 000FFFFB850)
000000A0BE0 7FFCA53E813E (000000A0C94, 00000000420, 00000000420, 000000A4F8C)
00000000420 7FFCA53E8836 (000FFFFB770, 000000001EC, 00000000000, 00180277C00)
00000000420 7FFCA59A9FF6 (00000000001, 00000000000, 000FFFFB850, 00100000001)
00000000420 7FFCA8EABF13 (00000000020, 00000000000, 000FFFFB9D0, 00000000001)
00000000420 001800AA082 (000FFFFB970, 00000000000, 7FFC00000000, 00000000000)
000FFFFB9F0 001800AAC25 (00100410FBB, 00000000001, 0060004CE30, 001004E6740)
000FFFFBBF0 0018011A60B (00100410FBB, 00000000001, 0060004CE30, 001004E6740)
000FFFFBBF0 0000271E458 (00100410FBB, 00000000001, 0060004CE30, 001004E6740)
End of stack trace
1 change: 0 additions & 1 deletion src/AspNetCoreRateLimit/AspNetCoreRateLimit.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>ASP.NET Core rate limiting middleware</Description>
<VersionPrefix>1.0.6</VersionPrefix>
Expand Down
3 changes: 2 additions & 1 deletion src/AspNetCoreRateLimit/Core/IpRateLimitProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using AspNetCoreRateLimit.Core;

namespace AspNetCoreRateLimit
{
Expand Down Expand Up @@ -74,7 +75,7 @@ public List<RateLimitRule> GetMatchingRules(ClientRequestIdentity identity)
matchingGeneralLimits.AddRange(pathLimits);

// search for rules with endpoints like "matching_verb:/matching_path" in general rules
var verbLimits = _options.GeneralRules.Where(l => $"{identity.HttpVerb}:{identity.Path}".ToLowerInvariant().Contains(l.Endpoint.ToLowerInvariant())).AsEnumerable();
var verbLimits = _options.GeneralRules.Where(l => $"{identity.HttpVerb}:{identity.Path}".ToLowerInvariant().IsMatch(l.Endpoint.ToLowerInvariant())).AsEnumerable();
matchingGeneralLimits.AddRange(verbLimits);
}
else
Expand Down

0 comments on commit b2f6d99

Please sign in to comment.