| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5ecfd94 commit 7d37bce
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1941,6 +1941,9 @@ error will be thrown. | |||
| 1941 | 1941 | <!-- YAML | |
| 1942 | 1942 | added: v8.4.0 | |
| 1943 | 1943 | changes: | |
| 1944 | + - version: REPLACEME | ||
| 1945 | + pr-url: https://github.com/nodejs/node/pull/30534 | ||
| 1946 | + description: Added `maxSessionRejectedStreams` option with a default of 100. | ||
| 1944 | 1947 | - version: REPLACEME | |
| 1945 | 1948 | pr-url: https://github.com/nodejs/node/pull/30534 | |
| 1946 | 1949 | description: Added `maxSessionInvalidFrames` option with a default of 1000. | |
@@ -2007,6 +2010,12 @@ changes: | |||
| 2007 | 2010 | * `maxSessionInvalidFrames` {integer} Sets the maximum number of invalid | |
| 2008 | 2011 | frames that will be tolerated before the session is closed. | |
| 2009 | 2012 | **Default:** `1000`. | |
| 2013 | + * `maxSessionRejectedStreams` {integer} Sets the maximum number of rejected | ||
| 2014 | + upon creation streams that will be tolerated before the session is closed. | ||
| 2015 | + Each rejection is associated with an `NGHTTP2_ENHANCE_YOUR_CALM` | ||
| 2016 | + error that should tell the peer to not open any more streams, continuing | ||
| 2017 | + to open streams is therefore regarded as a sign of a misbehaving peer. | ||
| 2018 | + **Default:** `100`. | ||
| 2010 | 2019 | * `settings` {HTTP/2 Settings Object} The initial settings to send to the | |
| 2011 | 2020 | remote peer upon connection. | |
| 2012 | 2021 | * `Http1IncomingMessage` {http.IncomingMessage} Specifies the | |
@@ -2059,6 +2068,9 @@ server.listen(80); | |||
| 2059 | 2068 | <!-- YAML | |
| 2060 | 2069 | added: v8.4.0 | |
| 2061 | 2070 | changes: | |
| 2071 | + - version: REPLACEME | ||
| 2072 | + pr-url: https://github.com/nodejs/node/pull/30534 | ||
| 2073 | + description: Added `maxSessionRejectedStreams` option with a default of 100. | ||
| 2062 | 2074 | - version: REPLACEME | |
| 2063 | 2075 | pr-url: https://github.com/nodejs/node/pull/30534 | |
| 2064 | 2076 | description: Added `maxSessionInvalidFrames` option with a default of 1000. | |
@@ -2125,6 +2137,12 @@ changes: | |||
| 2125 | 2137 | * `maxSessionInvalidFrames` {integer} Sets the maximum number of invalid | |
| 2126 | 2138 | frames that will be tolerated before the session is closed. | |
| 2127 | 2139 | **Default:** `1000`. | |
| 2140 | + * `maxSessionRejectedStreams` {integer} Sets the maximum number of rejected | ||
| 2141 | + upon creation streams that will be tolerated before the session is closed. | ||
| 2142 | + Each rejection is associated with an `NGHTTP2_ENHANCE_YOUR_CALM` | ||
| 2143 | + error that should tell the peer to not open any more streams, continuing | ||
| 2144 | + to open streams is therefore regarded as a sign of a misbehaving peer. | ||
| 2145 | + **Default:** `100`. | ||
| 2128 | 2146 | * `settings` {HTTP/2 Settings Object} The initial settings to send to the | |
| 2129 | 2147 | remote peer upon connection. | |
| 2130 | 2148 | * ...: Any [`tls.createServer()`][] options can be provided. For | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -204,6 +204,7 @@ const { | |||
| 204 | 204 | kSessionPriorityListenerCount, | |
| 205 | 205 | kSessionFrameErrorListenerCount, | |
| 206 | 206 | kSessionMaxInvalidFrames, | |
| 207 | + kSessionMaxRejectedStreams, | ||
| 207 | 208 | kSessionUint8FieldCount, | |
| 208 | 209 | kSessionHasRemoteSettingsListeners, | |
| 209 | 210 | kSessionRemoteSettingsIsUpToDate, | |
@@ -948,6 +949,12 @@ function setupHandle(socket, type, options) { | |||
| 948 | 949 | uint32[0] = options.maxSessionInvalidFrames; | |
| 949 | 950 | } | |
| 950 | 951 | ||
| 952 | + if (isUint32(options.maxSessionRejectedStreams)) { | ||
| 953 | + const uint32 = new Uint32Array( | ||
| 954 | + this[kNativeFields].buffer, kSessionMaxRejectedStreams, 1); | ||
| 955 | + uint32[0] = options.maxSessionRejectedStreams; | ||
| 956 | + } | ||
| 957 | + | ||
| 951 | 958 | const settings = typeof options.settings === 'object' ? | |
| 952 | 959 | options.settings : {}; | |
| 953 | 960 | ||
@@ -2782,6 +2789,13 @@ function initializeOptions(options) { | |||
| 2782 | 2789 | if (options.maxSessionInvalidFrames !== undefined) | |
| 2783 | 2790 | validateUint32(options.maxSessionInvalidFrames, 'maxSessionInvalidFrames'); | |
| 2784 | 2791 | ||
| 2792 | + if (options.maxSessionRejectedStreams !== undefined) { | ||
| 2793 | + validateUint32( | ||
| 2794 | + options.maxSessionRejectedStreams, | ||
| 2795 | + 'maxSessionRejectedStreams' | ||
| 2796 | + ); | ||
| 2797 | + } | ||
| 2798 | + | ||
| 2785 | 2799 | // Used only with allowHTTP1 | |
| 2786 | 2800 | options.Http1IncomingMessage = options.Http1IncomingMessage || | |
| 2787 | 2801 | http.IncomingMessage; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -920,7 +920,8 @@ int Http2Session::OnBeginHeadersCallback(nghttp2_session* handle, | |||
| 920 | 920 | if (UNLIKELY(!session->CanAddStream() || | |
| 921 | 921 | Http2Stream::New(session, id, frame->headers.cat) == | |
| 922 | 922 | nullptr)) { | |
| 923 | - if (session->rejected_stream_count_++ > 100) | ||
| 923 | + if (session->rejected_stream_count_++ > | ||
| 924 | + session->js_fields_.max_rejected_streams) | ||
| 924 | 925 | return NGHTTP2_ERR_CALLBACK_FAILURE; | |
| 925 | 926 | // Too many concurrent streams being opened | |
| 926 | 927 | nghttp2_submit_rst_stream(**session, NGHTTP2_FLAG_NONE, id, | |
@@ -3062,6 +3063,7 @@ void Initialize(Local<Object> target, | |||
| 3062 | 3063 | NODE_DEFINE_CONSTANT(target, kSessionPriorityListenerCount); | |
| 3063 | 3064 | NODE_DEFINE_CONSTANT(target, kSessionFrameErrorListenerCount); | |
| 3064 | 3065 | NODE_DEFINE_CONSTANT(target, kSessionMaxInvalidFrames); | |
| 3066 | + NODE_DEFINE_CONSTANT(target, kSessionMaxRejectedStreams); | ||
| 3065 | 3067 | NODE_DEFINE_CONSTANT(target, kSessionUint8FieldCount); | |
| 3066 | 3068 | ||
| 3067 | 3069 | NODE_DEFINE_CONSTANT(target, kSessionHasRemoteSettingsListeners); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -678,6 +678,7 @@ typedef struct { | |||
| 678 | 678 | uint8_t priority_listener_count; | |
| 679 | 679 | uint8_t frame_error_listener_count; | |
| 680 | 680 | uint32_t max_invalid_frames = 1000; | |
| 681 | + uint32_t max_rejected_streams = 100; | ||
| 681 | 682 | } SessionJSFields; | |
| 682 | 683 | ||
| 683 | 684 | // Indices for js_fields_, which serves as a way to communicate data with JS | |
@@ -691,6 +692,7 @@ enum SessionUint8Fields { | |||
| 691 | 692 | kSessionFrameErrorListenerCount = | |
| 692 | 693 | offsetof(SessionJSFields, frame_error_listener_count), | |
| 693 | 694 | kSessionMaxInvalidFrames = offsetof(SessionJSFields, max_invalid_frames), | |
| 695 | + kSessionMaxRejectedStreams = offsetof(SessionJSFields, max_rejected_streams), | ||
| 694 | 696 | kSessionUint8FieldCount = sizeof(SessionJSFields) | |
| 695 | 697 | }; | |
| 696 | 698 | ||
@@ -1024,7 +1026,7 @@ class Http2Session : public AsyncWrap, public StreamListener { | |||
| 1024 | 1026 | // limit will result in the session being destroyed, as an indication of a | |
| 1025 | 1027 | // misbehaving peer. This counter is reset once new streams are being | |
| 1026 | 1028 | // accepted again. | |
| 1027 | - int32_t rejected_stream_count_ = 0; | ||
| 1029 | + uint32_t rejected_stream_count_ = 0; | ||
| 1028 | 1030 | // Also use the invalid frame count as a measure for rejecting input frames. | |
| 1029 | 1031 | uint32_t invalid_frame_count_ = 0; | |
| 1030 | 1032 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,6 +52,22 @@ Object.entries({ | |||
| 52 | 52 | }, | |
| 53 | 53 | }, | |
| 54 | 54 | ], | |
| 55 | + maxSessionRejectedStreams: [ | ||
| 56 | + { | ||
| 57 | + val: -1, | ||
| 58 | + err: { | ||
| 59 | + name: 'RangeError', | ||
| 60 | + code: 'ERR_OUT_OF_RANGE', | ||
| 61 | + }, | ||
| 62 | + }, | ||
| 63 | + { | ||
| 64 | + val: Number.NEGATIVE_INFINITY, | ||
| 65 | + err: { | ||
| 66 | + name: 'RangeError', | ||
| 67 | + code: 'ERR_OUT_OF_RANGE', | ||
| 68 | + }, | ||
| 69 | + }, | ||
| 70 | + ], | ||
| 55 | 71 | }).forEach(([opt, tests]) => { | |
| 56 | 72 | tests.forEach(({ val, err }) => { | |
| 57 | 73 | assert.throws( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,6 +52,22 @@ Object.entries({ | |||
| 52 | 52 | }, | |
| 53 | 53 | }, | |
| 54 | 54 | ], | |
| 55 | + maxSessionRejectedStreams: [ | ||
| 56 | + { | ||
| 57 | + val: -1, | ||
| 58 | + err: { | ||
| 59 | + name: 'RangeError', | ||
| 60 | + code: 'ERR_OUT_OF_RANGE', | ||
| 61 | + }, | ||
| 62 | + }, | ||
| 63 | + { | ||
| 64 | + val: Number.NEGATIVE_INFINITY, | ||
| 65 | + err: { | ||
| 66 | + name: 'RangeError', | ||
| 67 | + code: 'ERR_OUT_OF_RANGE', | ||
| 68 | + }, | ||
| 69 | + }, | ||
| 70 | + ] | ||
| 55 | 71 | }).forEach(([opt, tests]) => { | |
| 56 | 72 | tests.forEach(({ val, err }) => { | |
| 57 | 73 | assert.throws( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments