http2 5.1.1 → 5.1.2
raw patch · 8 files changed
+19/−22 lines, 8 filesdep ~network
Dependency ranges changed: network
Files
- ChangeLog.md +5/−0
- Network/HTTP2/Client.hs +1/−0
- Network/HTTP2/Client/Run.hs +1/−1
- Network/HTTP2/H2/Receiver.hs +2/−6
- Network/HTTP2/H2/Settings.hs +6/−3
- Network/HTTP2/Server/Run.hs +1/−1
- http2.cabal +2/−2
- test/HTTP2/ServerSpec.hs +1/−9
ChangeLog.md view
@@ -1,3 +1,8 @@+## 5.1.2++* Make ping rate limit configurable+ [#108](https://github.com/kazu-yamamoto/http2/pull/108)+ ## 5.1.1 * Deal with RST_STREAM in HalfClosedLocal state
Network/HTTP2/Client.hs view
@@ -66,6 +66,7 @@ initialWindowSize, maxFrameSize, maxHeaderListSize,+ pingRateLimit, -- * Common configuration Config (..),
Network/HTTP2/Client/Run.hs view
@@ -52,7 +52,7 @@ -- @userinfo\@@ as part of the authority. -- -- >>> defaultClientConfig--- ClientConfig {scheme = "http", authority = "localhost", cacheLimit = 64, connectionWindowSize = 1048576, settings = Settings {headerTableSize = 4096, enablePush = True, maxConcurrentStreams = Just 64, initialWindowSize = 262144, maxFrameSize = 16384, maxHeaderListSize = Nothing}}+-- ClientConfig {scheme = "http", authority = "localhost", cacheLimit = 64, connectionWindowSize = 1048576, settings = Settings {headerTableSize = 4096, enablePush = True, maxConcurrentStreams = Just 64, initialWindowSize = 262144, maxFrameSize = 16384, maxHeaderListSize = Nothing, pingRateLimit = 10}} defaultClientConfig :: ClientConfig defaultClientConfig = ClientConfig
Network/HTTP2/H2/Receiver.hs view
@@ -39,9 +39,6 @@ headerFragmentLimit :: Int headerFragmentLimit = 51200 -- 50K -pingRateLimit :: Int-pingRateLimit = 4- settingsRateLimit :: Int settingsRateLimit = 4 @@ -328,11 +325,10 @@ setframe = CFrames (Just peerAlist) (frames ++ [ack]) writeIORef myFirstSettings True enqueueControl controlQ setframe-control FramePing FrameHeader{flags, streamId} bs Context{controlQ, pingRate} =+control FramePing FrameHeader{flags, streamId} bs Context{mySettings, controlQ, pingRate} = unless (testAck flags) $ do- -- Ping Flood - CVE-2019-9512 rate <- getRate pingRate- if rate > pingRateLimit+ if rate > pingRateLimit mySettings then E.throwIO $ ConnectionErrorIsSent EnhanceYourCalm streamId "too many ping" else do let frame = pingFrame bs
Network/HTTP2/H2/Settings.hs view
@@ -25,13 +25,15 @@ -- ^ SETTINGS_MAX_FRAME_SIZE , maxHeaderListSize :: Maybe Int -- ^ SETTINGS_MAX_HEADER_LIST_SIZE+ , pingRateLimit :: Int+ -- ^ Maximum number of pings allowed per second (CVE-2019-9512) } deriving (Eq, Show) -- | The default settings. -- -- >>> baseSettings--- Settings {headerTableSize = 4096, enablePush = True, maxConcurrentStreams = Nothing, initialWindowSize = 65535, maxFrameSize = 16384, maxHeaderListSize = Nothing}+-- Settings {headerTableSize = 4096, enablePush = True, maxConcurrentStreams = Nothing, initialWindowSize = 65535, maxFrameSize = 16384, maxHeaderListSize = Nothing, pingRateLimit = 10} baseSettings :: Settings baseSettings = Settings@@ -41,12 +43,13 @@ , initialWindowSize = defaultWindowSize -- 64K (65,535) , maxFrameSize = defaultPayloadLength -- 2^14 (16,384) , maxHeaderListSize = Nothing+ , pingRateLimit = 10 } -- | The default settings. -- -- >>> defaultSettings--- Settings {headerTableSize = 4096, enablePush = True, maxConcurrentStreams = Just 64, initialWindowSize = 262144, maxFrameSize = 16384, maxHeaderListSize = Nothing}+-- Settings {headerTableSize = 4096, enablePush = True, maxConcurrentStreams = Just 64, initialWindowSize = 262144, maxFrameSize = 16384, maxHeaderListSize = Nothing, pingRateLimit = 10} defaultSettings :: Settings defaultSettings = baseSettings@@ -59,7 +62,7 @@ -- | Updating settings. -- -- >>> fromSettingsList defaultSettings [(SettingsEnablePush,0),(SettingsMaxHeaderListSize,200)]--- Settings {headerTableSize = 4096, enablePush = False, maxConcurrentStreams = Just 64, initialWindowSize = 262144, maxFrameSize = 16384, maxHeaderListSize = Just 200}+-- Settings {headerTableSize = 4096, enablePush = False, maxConcurrentStreams = Just 64, initialWindowSize = 262144, maxFrameSize = 16384, maxHeaderListSize = Just 200, pingRateLimit = 10} {- FOURMOLU_DISABLE -} fromSettingsList :: Settings -> SettingsList -> Settings fromSettingsList settings kvs = foldl' update settings kvs
Network/HTTP2/Server/Run.hs view
@@ -30,7 +30,7 @@ -- | The default server config. -- -- >>> defaultServerConfig--- ServerConfig {numberOfWorkers = 8, connectionWindowSize = 1048576, settings = Settings {headerTableSize = 4096, enablePush = True, maxConcurrentStreams = Just 64, initialWindowSize = 262144, maxFrameSize = 16384, maxHeaderListSize = Nothing}}+-- ServerConfig {numberOfWorkers = 8, connectionWindowSize = 1048576, settings = Settings {headerTableSize = 4096, enablePush = True, maxConcurrentStreams = Just 64, initialWindowSize = 262144, maxFrameSize = 16384, maxHeaderListSize = Nothing, pingRateLimit = 10}} defaultServerConfig :: ServerConfig defaultServerConfig = ServerConfig
http2.cabal view
@@ -1,6 +1,6 @@ cabal-version: >=1.10 name: http2-version: 5.1.1+version: 5.1.2 license: BSD3 license-file: LICENSE maintainer: Kazu Yamamoto <kazu@iij.ad.jp>@@ -41,7 +41,7 @@ source-repository head type: git- location: git://github.com/kazu-yamamoto/http2+ location: https://github.com/kazu-yamamoto/http2 flag devel description: Development commands
test/HTTP2/ServerSpec.hs view
@@ -345,15 +345,7 @@ let einfo = EncodeInfo defaultFlags 0 Nothing opaque64 = "01234567" bs = encodeFrame einfo $ PingFrame opaque64- cioWriteBytes bs- cioWriteBytes bs- cioWriteBytes bs- cioWriteBytes bs- cioWriteBytes bs- cioWriteBytes bs- cioWriteBytes bs- cioWriteBytes bs- cioWriteBytes bs+ replicateM_ 20 $ cioWriteBytes bs rapidEmptyHeader :: C.ClientIO -> IO () rapidEmptyHeader C.ClientIO{..} = do