diff --git a/src/clown_limiter.nim b/src/clown_limiter.nim index 1cecf42..78de59e 100644 --- a/src/clown_limiter.nim +++ b/src/clown_limiter.nim @@ -45,9 +45,19 @@ spawn server() sync()]## -import jester, clown_limiter/tracker +import jester from re import re, contains, Regex +when not defined(useSqliteTracker): + ## when not specified to use in memory sqlite to store tracking data + + import clown_limiter/tracker + +else: + ## when specified to use in memory sqlite to store tracking data + + import clown_limiter/sqlitetracker + export tracker, re var clown_limiter_data_do_not_touch* : seq[tuple[pattern : Regex, rate, freq : int]] = @[ @@ -80,13 +90,13 @@ router clown_limiter: rate = info.rate freq = info.freq break - + if check_rate: let ip = request.ip() rateinfo = ip.rateStatus(rate, freq) - + case rateinfo.status of Exceeded: @@ -100,4 +110,3 @@ router clown_limiter: of Expired: ip.resetReqRate() -