remove throttler and its dependencies

This commit is contained in:
nek0 2022-09-29 02:39:15 +02:00
parent e1d082e6e6
commit b111c4d47a
3 changed files with 3 additions and 20 deletions

View file

@ -37,7 +37,6 @@ import Network.Socket (defaultPort)
import Network.Wai import Network.Wai
import Network.Wai.Logger import Network.Wai.Logger
import Network.Wai.Handler.Warp import Network.Wai.Handler.Warp
import Network.Wai.Middleware.Throttle
import Control.Monad.Reader import Control.Monad.Reader
@ -144,20 +143,7 @@ main = do
, rsMailQueue = mailQueue , rsMailQueue = mailQueue
} }
expirationSpec = TimeSpec 5 0 -- five seconds expirationSpec = TimeSpec 5 0 -- five seconds
throt = (defaultThrottleSettings expirationSpec) runSettings settings (app initState)
{ throttleSettingsRate = 10
, throttleSettingsPeriod = 1000
}
th <- initCustomThrottler throt
(\req ->
let headers = requestHeaders req
in case lookup "x-forwarded-for" headers of
Just addrs ->
let xaddr = fst (B8.break (== ',') addrs)
in Right $ Address $ toSockAddr (read (B8.unpack xaddr), defaultPort)
Nothing -> Right $ Address $ remoteHost req
)
runSettings settings (throttle th (app initState))
where where
opts = info (options <**> helper) opts = info (options <**> helper)
( fullDesc ( fullDesc

View file

@ -14,11 +14,9 @@
haskellPackages = pkgs.haskellPackages.override { haskellPackages = pkgs.haskellPackages.override {
overrides = hself: hsuper: { overrides = hself: hsuper: {
pg-transact = with pkgs.haskell.lib; pg-transact = with pkgs.haskell.lib;
doJailbreak (unmarkBroken (dontCheck doJailbreak(hsuper.pg-transact))); unmarkBroken (dontCheck (doJailbreak hsuper.pg-transact));
hspec-wai-json = with pkgs.haskell.lib; hspec-wai-json = with pkgs.haskell.lib;
doJailbreak (unmarkBroken (dontCheck doJailbreak(hsuper.hspec-wai-json))); unmarkBroken (dontCheck (doJailbreak hsuper.hspec-wai-json));
token-bucket = with pkgs.haskell.lib;
doJailbreak (unmarkBroken (dontCheck doJailbreak(hsuper.token-bucket)));
}; };
}; };

View file

@ -157,7 +157,6 @@ executable mateamt
, warp , warp
, wai , wai
, wai-logger , wai-logger
, wai-middleware-throttle
, yaml , yaml
, optparse-applicative , optparse-applicative
, case-insensitive , case-insensitive