@fails-components/webtransport-transport-http3-quiche 1.2.1 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CMakeLists.txt CHANGED
@@ -88,7 +88,6 @@ platform/quiche_platform_impl/quiche_stream_buffer_allocator_impl.h
88
88
  platform/quiche_platform_impl/quiche_time_utils_impl.h
89
89
  platform/quiche_platform_impl/quiche_udp_socket_platform_impl.h
90
90
  platform/quiche_platform_impl/quiche_server_stats_impl.h
91
- platform/quiche_platform_impl/quiche_mem_slice_impl.h
92
91
  platform/quiche_platform_impl/quiche_flag_utils_impl.h
93
92
  #protofiles
94
93
  #${PROTO_SRCS}
@@ -157,7 +156,6 @@ third_party/quiche/quiche/common/platform/api/quiche_hostname_utils.cc
157
156
  third_party/quiche/quiche/common/platform/api/quiche_hostname_utils.h
158
157
  third_party/quiche/quiche/common/platform/api/quiche_iovec.h
159
158
  third_party/quiche/quiche/common/platform/api/quiche_logging.h
160
- third_party/quiche/quiche/common/platform/api/quiche_mem_slice.h
161
159
  third_party/quiche/quiche/common/platform/api/quiche_reference_counted.h
162
160
  third_party/quiche/quiche/common/platform/api/quiche_time_utils.h
163
161
  third_party/quiche/quiche/common/platform/api/quiche_url_utils.h
@@ -168,7 +166,6 @@ third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_fl
168
166
  third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_flags_impl.cc
169
167
  third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_logging_impl.cc
170
168
  third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_logging_impl.h
171
- third_party/quiche/quiche/common/platform/api/quiche_mem_slice.cc
172
169
  third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_stack_trace_impl.cc
173
170
  third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_stack_trace_impl.h
174
171
  third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_iovec_impl.h
@@ -189,6 +186,8 @@ third_party/quiche/quiche/common/quiche_ip_address.h
189
186
  third_party/quiche/quiche/common/quiche_ip_address_family.cc
190
187
  third_party/quiche/quiche/common/quiche_ip_address_family.h
191
188
  third_party/quiche/quiche/common/quiche_linked_hash_map.h
189
+ third_party/quiche/quiche/common/quiche_mem_slice.cc
190
+ third_party/quiche/quiche/common/quiche_mem_slice.h
192
191
  third_party/quiche/quiche/common/quiche_mem_slice_storage.h
193
192
  third_party/quiche/quiche/common/quiche_mem_slice_storage.cc
194
193
  third_party/quiche/quiche/common/quiche_random.cc
package/eslint.config.js CHANGED
@@ -1,21 +1,22 @@
1
-
2
- import js from "@eslint/js"
3
- import promise from "eslint-plugin-promise"
4
- import babelParser from "@babel/eslint-parser"
1
+ import js from '@eslint/js'
2
+ import promise from 'eslint-plugin-promise'
3
+ import babelParser from '@babel/eslint-parser'
4
+ import importplug from 'eslint-plugin-import'
5
+ // eslint-disable-next-line import/extensions
5
6
  import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
6
- import globals from "globals";
7
+ import globals from 'globals'
7
8
 
8
9
  export default [
9
10
  js.configs.recommended,
10
11
  eslintPluginPrettierRecommended,
11
12
  {
12
13
  plugins: {
13
- promise
14
+ promise,
15
+ import: importplug
14
16
  },
15
17
  languageOptions: {
16
18
  globals: {
17
19
  ...globals.node
18
-
19
20
  },
20
21
  parser: babelParser,
21
22
  ecmaVersion: 2020,
@@ -24,28 +25,36 @@ export default [
24
25
  legacyDecorators: true,
25
26
  jsx: true
26
27
  },
27
- requireConfigFile: false,
28
+ requireConfigFile: false
28
29
  }
29
30
  },
30
31
  ignores: [
31
- "build/*",
32
- "dist/*",
33
- "node_modules/*",
34
- ".snapshots/*",
35
- "*.min.js"
32
+ 'build/*',
33
+ 'dist/*',
34
+ 'node_modules/*',
35
+ '.snapshots/*',
36
+ '*.min.js'
36
37
  ],
37
38
  rules: {
38
- "space-before-function-paren": 0,
39
- "import/export": 0,
40
- "promise/catch-or-return": "error",
41
- "no-useless-return": 1,
42
- "camelcase": 1,
43
- },
39
+ 'space-before-function-paren': 0,
40
+ 'import/export': 0,
41
+ 'promise/catch-or-return': 'error',
42
+ 'no-useless-return': 1,
43
+ camelcase: 1,
44
+ 'import/extensions': [
45
+ 'error',
46
+ 'always',
47
+ {
48
+ js: 'always',
49
+ jsx: 'always'
50
+ }
51
+ ]
52
+ }
44
53
  },
45
54
  {
46
- files: ["test/*.spec.js"],
55
+ files: ['test/*.spec.js'],
47
56
  rules: {
48
- "no-undef": 0
57
+ 'no-undef': 0
49
58
  }
50
- },
51
- ];
59
+ }
60
+ ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fails-components/webtransport-transport-http3-quiche",
3
- "version": "1.2.1",
3
+ "version": "1.3.1",
4
4
  "description": "A component to add webtransport support (server and client) to node.js, transport using libquiche",
5
5
  "exports": {
6
6
  ".": {
@@ -395,7 +395,11 @@ namespace quic
395
395
  }
396
396
  }*/
397
397
 
398
- void Http3ServerJS::processNewSession(Http3WTSession *session, const std::string &path, Napi::Reference<Napi::Value> *header, Napi::Reference<Napi::Value> *userData)
398
+ void Http3ServerJS::processNewSession(Http3WTSession *session,
399
+ const std::string &path,
400
+ const std::string& peer_address,
401
+ Napi::Reference<Napi::Value> *header,
402
+ Napi::Reference<Napi::Value> *userData)
399
403
  {
400
404
  Napi::HandleScope scope(Env());
401
405
 
@@ -421,12 +425,16 @@ namespace quic
421
425
  retObj.Set("userData", userData->Value());
422
426
  userData->Unref();
423
427
  }
428
+ retObj.Set("peerAddress", peer_address);
424
429
  objVal.Get("onHttpWTSessionVisitor")
425
430
  .As<Napi::Function>()
426
431
  .Call(objVal, {retObj});
427
432
  }
428
433
 
429
- void Http3ServerJS::processNewSessionRequest(WebTransportSession *session, const quiche::HttpHeaderBlock &reqhead, WebTransportRespPromisePtr promise)
434
+ void Http3ServerJS::processNewSessionRequest(WebTransportSession *session,
435
+ const quiche::HttpHeaderBlock &reqhead,
436
+ const std::string& peer_address,
437
+ WebTransportRespPromisePtr promise)
430
438
  {
431
439
  Napi::HandleScope scope(Env());
432
440
 
@@ -464,7 +472,8 @@ namespace quic
464
472
  });
465
473
  retObj.Set("session", wtsObj);
466
474
  retObj.Set("protocol", "http3:libquiche");
467
-
475
+ retObj.Set("peerAddress", peer_address);
476
+
468
477
  objVal.Get("onSessionRequest")
469
478
  .As<Napi::Function>()
470
479
  .Call(objVal, {retObj});
@@ -524,6 +533,13 @@ namespace quic
524
533
  else
525
534
  return Napi::Error::New(Env(), "No session passed for finishSessionRequest").ThrowAsJavaScriptException();
526
535
 
536
+ std::string peer_address;
537
+ if (lobj.Has("peerAddress") && !(lobj).Get("peerAddress").IsEmpty()) {
538
+ Napi::Value peerAddressValue = lobj.Get("peerAddress");
539
+ peer_address= peerAddressValue.ToString().Utf8Value();
540
+ } else
541
+ return Napi::Error::New(Env(), "No peerAddress passed for finishSessionRequest").ThrowAsJavaScriptException();
542
+
527
543
  if (lobj.Has("promise") && !(lobj).Get("promise").IsEmpty())
528
544
  {
529
545
  Napi::Value promiseVal = (lobj).Get("promise");
@@ -576,7 +592,8 @@ namespace quic
576
592
  wtsession->init(session);
577
593
  response->visitor =
578
594
  std::make_unique<Http3WTSession::Visitor>(wtsession);
579
- processNewSession(static_cast<Http3WTSession *>(wtsession), path, headerValue, userDataValue);
595
+ processNewSession(static_cast<Http3WTSession *>(wtsession), path, peer_address,
596
+ headerValue, userDataValue);
580
597
  (*prom)->resolve(std::move(response));
581
598
  }
582
599
  }
package/src/http3server.h CHANGED
@@ -84,8 +84,8 @@ namespace quic
84
84
  exports.Set("Http3WebTransportServer", tplsrv);
85
85
  }
86
86
 
87
- void processNewSession(Http3WTSession *session, const std::string &path, Napi::Reference<Napi::Value> *header, Napi::Reference<Napi::Value> *userData);
88
- void processNewSessionRequest(WebTransportSession *session, const quiche::HttpHeaderBlock &reqheadcopy, WebTransportRespPromisePtr promise);
87
+ void processNewSession(Http3WTSession *session, const std::string &path, const std::string &peer_address, Napi::Reference<Napi::Value> *header, Napi::Reference<Napi::Value> *userData);
88
+ void processNewSessionRequest(WebTransportSession *session, const quiche::HttpHeaderBlock &reqheadcopy, const std::string &peer_address, WebTransportRespPromisePtr promise);
89
89
 
90
90
  protected:
91
91
  std::unique_ptr<Http3Server> server_;
@@ -46,7 +46,8 @@ namespace quic
46
46
  Http3ServerBackend::WebTransportRespPromisePtr
47
47
  Http3ServerBackend::ProcessWebTransportRequest(
48
48
  const quiche::HttpHeaderBlock &request_headers,
49
- WebTransportSession *session)
49
+ WebTransportSession *session,
50
+ const QuicSocketAddress peer_address)
50
51
  {
51
52
  WebTransportRespPromisePtr promise = std::make_shared<WebTransportRespPromise>();
52
53
  if (!SupportsWebTransport())
@@ -73,7 +74,7 @@ namespace quic
73
74
  // not necessary anymore
74
75
 
75
76
  // second step inform the js side
76
- server_->getJS()->processNewSessionRequest(session, request_headers, promise);
77
+ server_->getJS()->processNewSessionRequest(session, request_headers, peer_address.ToString(), promise);
77
78
  return promise;
78
79
  }
79
80
 
@@ -85,7 +86,7 @@ namespace quic
85
86
  response->response_headers[":status"] = "200";
86
87
  response->visitor =
87
88
  std::make_unique<Http3WTSession::Visitor>(wtsession);
88
- server_->getJS()->processNewSession(static_cast<Http3WTSession *>(wtsession), path, nullptr, nullptr);
89
+ server_->getJS()->processNewSession(static_cast<Http3WTSession *>(wtsession), path, peer_address.ToString(), nullptr, nullptr);
89
90
  promise->resolve(std::move(response));
90
91
  return promise;
91
92
  }
@@ -16,6 +16,7 @@
16
16
  #include "quiche/quic/core/quic_types.h"
17
17
  #include "quiche/quic/core/web_transport_interface.h"
18
18
  #include "quiche/common/http/http_header_block.h"
19
+ #include "quiche/quic/platform/api/quic_socket_address.h"
19
20
 
20
21
  namespace quic
21
22
  {
@@ -78,7 +79,8 @@ namespace quic
78
79
 
79
80
  WebTransportRespPromisePtr ProcessWebTransportRequest(
80
81
  const quiche::HttpHeaderBlock & /*request_headers*/,
81
- WebTransportSession * /*session*/);
82
+ WebTransportSession * /*session*/,
83
+ const QuicSocketAddress/* peer_address */);
82
84
  bool SupportsWebTransport() { return true; }
83
85
  bool UsesDatagramContexts() { return true; }
84
86
  bool SupportsExtendedConnect() { return true; }
@@ -197,10 +197,11 @@ namespace quic
197
197
 
198
198
  if (web_transport() != nullptr)
199
199
  {
200
+ quic::QuicSocketAddress peer_address = spdy_session()->connection()->peer_address();
200
201
  // to do synchronize lifetime of object, so maybe store promises
201
202
  Http3ServerBackend::WebTransportRespPromisePtr response =
202
203
  http3_server_backend_->ProcessWebTransportRequest(
203
- request_headers_, web_transport());
204
+ request_headers_, web_transport(), peer_address);
204
205
  pending_proms_.insert(response);
205
206
  response->finally([this, response](Http3ServerBackend::WebTransportResponse *resp)
206
207
  {
@@ -1,2 +0,0 @@
1
- // use the default
2
- #include "quiche/common/platform/default/quiche_platform_impl/quiche_mem_slice_impl.h"