@fails-components/webtransport-transport-http3-quiche 1.6.2 → 1.6.4
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 +2 -0
- package/package.json +2 -2
- package/src/http3client.cc +5 -4
- package/src/http3clientsession.cc +6 -0
- package/src/http3clientsession.h +10 -3
- package/src/http3server.cc +2 -1
- package/src/http3serverbackend.cc +1 -1
- package/src/http3serverbackend.h +2 -2
- package/src/http3serversession.cc +6 -10
- package/src/http3serversession.h +9 -4
- package/src/http3serverstream.cc +9 -2
- package/src/http3wtsessionvisitor.cc +3 -0
- package/src/http3wtsessionvisitor.h +36 -17
package/CMakeLists.txt
CHANGED
|
@@ -378,6 +378,8 @@ third_party/quiche/quiche/quic/core/congestion_control/bbr2_sender.cc
|
|
|
378
378
|
third_party/quiche/quiche/quic/core/congestion_control/bbr2_sender.h
|
|
379
379
|
third_party/quiche/quiche/quic/core/congestion_control/bbr2_startup.cc
|
|
380
380
|
third_party/quiche/quiche/quic/core/congestion_control/bbr2_startup.h
|
|
381
|
+
third_party/quiche/quiche/quic/core/congestion_control/bbr3_sender.cc
|
|
382
|
+
third_party/quiche/quiche/quic/core/congestion_control/bbr3_sender.h
|
|
381
383
|
third_party/quiche/quiche/quic/core/congestion_control/bbr_sender.cc
|
|
382
384
|
third_party/quiche/quiche/quic/core/congestion_control/bbr_sender.h
|
|
383
385
|
third_party/quiche/quiche/quic/core/congestion_control/cubic_bytes.cc
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fails-components/webtransport-transport-http3-quiche",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.4",
|
|
4
4
|
"description": "A component to add webtransport support (server and client) to node.js, transport using libquiche",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"prebuild-install": "^7.1.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@babel/core": "^7.
|
|
47
|
+
"@babel/core": "^7.29.6",
|
|
48
48
|
"@babel/eslint-parser": "^7.17.0",
|
|
49
49
|
"@babel/plugin-syntax-import-attributes": "^7.23.3",
|
|
50
50
|
"@types/node": "^24.0.1",
|
package/src/http3client.cc
CHANGED
|
@@ -84,7 +84,7 @@ namespace quic
|
|
|
84
84
|
const std::string& cert_sct, const std::string& signature,
|
|
85
85
|
const ProofVerifyContext* context, std::string* error_details,
|
|
86
86
|
std::unique_ptr<ProofVerifyDetails>* details,
|
|
87
|
-
std::unique_ptr<ProofVerifierCallback> callback) {
|
|
87
|
+
std::unique_ptr<ProofVerifierCallback> callback) override {
|
|
88
88
|
auto env = envg_->getEnv();
|
|
89
89
|
Napi::HandleScope scope(env);
|
|
90
90
|
|
|
@@ -114,10 +114,10 @@ namespace quic
|
|
|
114
114
|
|
|
115
115
|
QuicAsyncStatus VerifyCertChain(
|
|
116
116
|
const std::string& hostname, const uint16_t port,
|
|
117
|
-
const std::vector<
|
|
117
|
+
const std::vector<absl::string_view>& certs, const std::string& ocsp_response,
|
|
118
118
|
const std::string& cert_sct, const ProofVerifyContext* context,
|
|
119
119
|
std::string* error_details, std::unique_ptr<ProofVerifyDetails>* details,
|
|
120
|
-
uint8_t* out_alert, std::unique_ptr<ProofVerifierCallback> callback) {
|
|
120
|
+
uint8_t* out_alert, std::unique_ptr<ProofVerifierCallback> callback) override {
|
|
121
121
|
auto env = envg_->getEnv();
|
|
122
122
|
Napi::HandleScope scope(env);
|
|
123
123
|
|
|
@@ -609,7 +609,8 @@ namespace quic
|
|
|
609
609
|
wtsessionobj->init(
|
|
610
610
|
static_cast<WebTransportSession *>(wtsession));
|
|
611
611
|
getJS()->processNewClientSession(wtsessionobj);
|
|
612
|
-
auto visitor = std::make_unique<Http3WTSession::Visitor>(wtsessionobj
|
|
612
|
+
auto visitor = std::make_unique<Http3WTSession::Visitor>(wtsessionobj,
|
|
613
|
+
static_cast<Http3ClientSession *>(session_.get()));
|
|
613
614
|
static_cast<Http3ClientSession *>(session_.get())->AddVisitor(id, visitor.get());
|
|
614
615
|
wtsession->SetVisitor(std::move(visitor));
|
|
615
616
|
}
|
|
@@ -38,6 +38,12 @@ namespace quic
|
|
|
38
38
|
drop_response_body_(drop_response_body),
|
|
39
39
|
enable_web_transport_(enable_web_transport) {}
|
|
40
40
|
|
|
41
|
+
Http3ClientSession::~Http3ClientSession() {
|
|
42
|
+
for (auto itty = svisitors_.begin(); itty != svisitors_.end(); itty++) {
|
|
43
|
+
(*itty).second->RemoveVisitorRemoveVisitor();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
41
47
|
std::unique_ptr<QuicSpdyClientStream>
|
|
42
48
|
Http3ClientSession::CreateClientStream()
|
|
43
49
|
{
|
package/src/http3clientsession.h
CHANGED
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
|
|
17
17
|
#include "quiche/quic/core/http/quic_spdy_client_session.h"
|
|
18
18
|
#include "src/http3clientstream.h"
|
|
19
|
+
#include "src/http3wtsessionvisitor.h"
|
|
19
20
|
|
|
20
21
|
namespace quic
|
|
21
22
|
{
|
|
22
23
|
|
|
23
|
-
class Http3ClientSession : public QuicSpdyClientSession
|
|
24
|
+
class Http3ClientSession : public QuicSpdyClientSession, public Http3WTSession::VisitorRemoveVisitor
|
|
24
25
|
{
|
|
25
26
|
public:
|
|
26
27
|
Http3ClientSession(const QuicConfig &config,
|
|
@@ -35,6 +36,7 @@ namespace quic
|
|
|
35
36
|
const QuicServerId &server_id,
|
|
36
37
|
QuicCryptoClientConfig *crypto_config,
|
|
37
38
|
bool drop_response_body, bool enable_web_transport);
|
|
39
|
+
~Http3ClientSession();
|
|
38
40
|
|
|
39
41
|
std::unique_ptr<QuicSpdyClientStream> CreateClientStream() override;
|
|
40
42
|
WebTransportHttp3VersionSet LocallySupportedWebTransportVersions()
|
|
@@ -42,10 +44,15 @@ namespace quic
|
|
|
42
44
|
HttpDatagramSupport LocalHttpDatagramSupport() override;
|
|
43
45
|
|
|
44
46
|
void OnCanCreateNewOutgoingStream(bool unidirectional) override;
|
|
45
|
-
void AddVisitor(const WebTransportSessionId id,
|
|
47
|
+
void AddVisitor(const WebTransportSessionId id, Http3WTSession::Visitor *visitor) {
|
|
46
48
|
svisitors_.try_emplace(id, visitor);
|
|
47
49
|
}
|
|
48
50
|
|
|
51
|
+
void RemoveVisitor(Http3WTSession::Visitor* visitor) override {
|
|
52
|
+
absl::erase_if(svisitors_,
|
|
53
|
+
[&](const auto& pair) { return pair.second == visitor; });
|
|
54
|
+
}
|
|
55
|
+
|
|
49
56
|
void set_on_interim_headers(
|
|
50
57
|
std::function<void(const quiche::HttpHeaderBlock &)> on_interim_headers)
|
|
51
58
|
{
|
|
@@ -56,7 +63,7 @@ namespace quic
|
|
|
56
63
|
std::function<void(const quiche::HttpHeaderBlock &)> on_interim_headers_;
|
|
57
64
|
const bool drop_response_body_;
|
|
58
65
|
const bool enable_web_transport_;
|
|
59
|
-
absl::flat_hash_map<QuicStreamId,
|
|
66
|
+
absl::flat_hash_map<QuicStreamId, Http3WTSession::Visitor *> svisitors_;
|
|
60
67
|
};
|
|
61
68
|
|
|
62
69
|
} // namespace quic
|
package/src/http3server.cc
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
#include "src/http3server.h"
|
|
12
12
|
#include "src/http3dispatcher.h"
|
|
13
13
|
#include "src/http3wtsessionvisitor.h"
|
|
14
|
+
#include "src/http3serversession.h"
|
|
14
15
|
#include "quiche/quic/core/quic_default_packet_writer.h"
|
|
15
16
|
#include "quiche/quic/core/quic_default_connection_helper.h"
|
|
16
17
|
#include "quiche/quic/core/quic_default_clock.h"
|
|
@@ -607,7 +608,7 @@ namespace quic
|
|
|
607
608
|
Http3WTSession *wtsession = new Http3WTSession();
|
|
608
609
|
wtsession->init(session);
|
|
609
610
|
response->visitor =
|
|
610
|
-
std::make_unique<Http3WTSession::Visitor>(wtsession);
|
|
611
|
+
std::make_unique<Http3WTSession::Visitor>(wtsession, nullptr);
|
|
611
612
|
processNewSession(static_cast<Http3WTSession *>(wtsession), path, peer_address,
|
|
612
613
|
headerValue, userDataValue);
|
|
613
614
|
(*prom)->resolve(std::move(response));
|
|
@@ -85,7 +85,7 @@ namespace quic
|
|
|
85
85
|
wtsession->init(session);
|
|
86
86
|
response->response_headers[":status"] = "200";
|
|
87
87
|
response->visitor =
|
|
88
|
-
std::make_unique<Http3WTSession::Visitor>(wtsession);
|
|
88
|
+
std::make_unique<Http3WTSession::Visitor>(wtsession, nullptr);
|
|
89
89
|
server_->getJS()->processNewSession(static_cast<Http3WTSession *>(wtsession), path, peer_address.ToString(), nullptr, nullptr);
|
|
90
90
|
promise->resolve(std::move(response));
|
|
91
91
|
return promise;
|
package/src/http3serverbackend.h
CHANGED
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
#include "quiche/quic/core/web_transport_interface.h"
|
|
18
18
|
#include "quiche/common/http/http_header_block.h"
|
|
19
19
|
#include "quiche/quic/platform/api/quic_socket_address.h"
|
|
20
|
+
#include "src/http3wtsessionvisitor.h"
|
|
20
21
|
|
|
21
22
|
namespace quic
|
|
22
23
|
{
|
|
23
24
|
|
|
24
25
|
class Http3Server;
|
|
25
|
-
class Http3EventLoop;
|
|
26
26
|
|
|
27
27
|
template <typename T>
|
|
28
28
|
class JSlikePromise
|
|
@@ -64,7 +64,7 @@ namespace quic
|
|
|
64
64
|
struct WebTransportResponse
|
|
65
65
|
{
|
|
66
66
|
quiche::HttpHeaderBlock response_headers;
|
|
67
|
-
std::unique_ptr<
|
|
67
|
+
std::unique_ptr<Http3WTSession::Visitor> visitor;
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
using WebTransportRespPromise = JSlikePromise<WebTransportResponse>;
|
|
@@ -42,7 +42,12 @@ namespace quic
|
|
|
42
42
|
QUICHE_DCHECK(http3_server_backend_);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
Http3ServerSession::~Http3ServerSession() {
|
|
45
|
+
Http3ServerSession::~Http3ServerSession() {
|
|
46
|
+
DeleteConnection();
|
|
47
|
+
for (auto itty = svisitors_.begin(); itty != svisitors_.end(); itty++) {
|
|
48
|
+
(*itty).second->RemoveVisitorRemoveVisitor();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
46
51
|
|
|
47
52
|
std::unique_ptr<QuicCryptoServerStreamBase>
|
|
48
53
|
Http3ServerSession::CreateQuicCryptoServerStream(
|
|
@@ -79,15 +84,6 @@ namespace quic
|
|
|
79
84
|
return stream;
|
|
80
85
|
}
|
|
81
86
|
|
|
82
|
-
QuicSpdyStream *Http3ServerSession::CreateIncomingStream(
|
|
83
|
-
PendingStream *pending)
|
|
84
|
-
{
|
|
85
|
-
QuicSpdyStream *stream =
|
|
86
|
-
new Http3ServerStream(pending, this, http3_server_backend_);
|
|
87
|
-
ActivateStream(absl::WrapUnique(stream));
|
|
88
|
-
return stream;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
87
|
QuicSpdyStream *Http3ServerSession::CreateOutgoingBidirectionalStream()
|
|
92
88
|
{
|
|
93
89
|
if (!WillNegotiateWebTransport())
|
package/src/http3serversession.h
CHANGED
|
@@ -29,11 +29,12 @@
|
|
|
29
29
|
// #include "quic/tools/quic_backend_response.h"
|
|
30
30
|
#include "src/http3serverbackend.h"
|
|
31
31
|
#include "src/http3serverstream.h" // todo
|
|
32
|
+
#include "src/http3wtsessionvisitor.h"
|
|
32
33
|
|
|
33
34
|
namespace quic
|
|
34
35
|
{
|
|
35
36
|
|
|
36
|
-
class Http3ServerSession : public QuicServerSessionBase
|
|
37
|
+
class Http3ServerSession : public QuicServerSessionBase, public Http3WTSession::VisitorRemoveVisitor
|
|
37
38
|
{
|
|
38
39
|
public:
|
|
39
40
|
// Takes ownership of |connection|.
|
|
@@ -54,14 +55,18 @@ namespace quic
|
|
|
54
55
|
void OnStreamFrame(const QuicStreamFrame &frame) override;
|
|
55
56
|
|
|
56
57
|
void OnCanCreateNewOutgoingStream(bool unidirectional) override;
|
|
57
|
-
void AddVisitor(const WebTransportSessionId id,
|
|
58
|
+
void AddVisitor(const WebTransportSessionId id, Http3WTSession::Visitor *visitor) {
|
|
58
59
|
svisitors_.try_emplace(id, visitor);
|
|
59
60
|
}
|
|
60
61
|
|
|
62
|
+
void RemoveVisitor(Http3WTSession::Visitor* visitor) override {
|
|
63
|
+
absl::erase_if(svisitors_,
|
|
64
|
+
[&](const auto& pair) { return pair.second == visitor; });
|
|
65
|
+
}
|
|
66
|
+
|
|
61
67
|
protected:
|
|
62
68
|
// QuicSession methods:
|
|
63
69
|
QuicSpdyStream *CreateIncomingStream(QuicStreamId id) override;
|
|
64
|
-
QuicSpdyStream *CreateIncomingStream(PendingStream *pending) override;
|
|
65
70
|
QuicSpdyStream *CreateOutgoingBidirectionalStream() override;
|
|
66
71
|
|
|
67
72
|
// QuicServerSessionBaseMethod:
|
|
@@ -92,7 +97,7 @@ namespace quic
|
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
Http3ServerBackend *http3_server_backend_; // Not owned.
|
|
95
|
-
absl::flat_hash_map<QuicStreamId,
|
|
100
|
+
absl::flat_hash_map<QuicStreamId, Http3WTSession::Visitor *> svisitors_;
|
|
96
101
|
};
|
|
97
102
|
|
|
98
103
|
} // namespace quic
|
package/src/http3serverstream.cc
CHANGED
|
@@ -48,7 +48,7 @@ namespace quic
|
|
|
48
48
|
Http3ServerStream::Http3ServerStream(
|
|
49
49
|
PendingStream *pending, QuicSpdySession *session,
|
|
50
50
|
Http3ServerBackend *http3_server_backend)
|
|
51
|
-
: QuicSpdyServerStreamBase(pending, session),
|
|
51
|
+
: QuicSpdyServerStreamBase(*pending, session),
|
|
52
52
|
content_length_(-1),
|
|
53
53
|
generate_bytes_length_(0),
|
|
54
54
|
http3_server_backend_(http3_server_backend)
|
|
@@ -151,6 +151,7 @@ namespace quic
|
|
|
151
151
|
|
|
152
152
|
void Http3ServerStream::SendResponse()
|
|
153
153
|
{
|
|
154
|
+
if (fin_buffered()) return; // we already exited
|
|
154
155
|
if (request_headers_.empty())
|
|
155
156
|
{
|
|
156
157
|
QUIC_DVLOG(1) << "Request headers empty.";
|
|
@@ -210,7 +211,8 @@ namespace quic
|
|
|
210
211
|
{
|
|
211
212
|
WriteHeaders(std::move(resp->response_headers), false, nullptr);
|
|
212
213
|
if (resp->visitor != nullptr)
|
|
213
|
-
{
|
|
214
|
+
{
|
|
215
|
+
resp->visitor->AddVisitorRemoveVisitor(static_cast<Http3ServerSession *>(session()));
|
|
214
216
|
static_cast<Http3ServerSession *>(session())->AddVisitor(id(), resp->visitor.get());
|
|
215
217
|
web_transport()->SetVisitor(std::move(resp->visitor));
|
|
216
218
|
}
|
|
@@ -357,6 +359,7 @@ namespace quic
|
|
|
357
359
|
void Http3ServerStream::SendNotFoundResponse()
|
|
358
360
|
{
|
|
359
361
|
QUIC_DVLOG(1) << "Stream " << id() << " sending not found response.";
|
|
362
|
+
if (fin_buffered()) return; // we already exited
|
|
360
363
|
HttpHeaderBlock headers;
|
|
361
364
|
headers[":status"] = "404";
|
|
362
365
|
headers["content-length"] = absl::StrCat(strlen(kNotFoundResponseBody));
|
|
@@ -375,6 +378,7 @@ namespace quic
|
|
|
375
378
|
{
|
|
376
379
|
StopReading();
|
|
377
380
|
}
|
|
381
|
+
if (fin_buffered()) return; // we already exited
|
|
378
382
|
HttpHeaderBlock headers;
|
|
379
383
|
if (resp_code <= 0)
|
|
380
384
|
{
|
|
@@ -392,6 +396,7 @@ namespace quic
|
|
|
392
396
|
HttpHeaderBlock response_headers,
|
|
393
397
|
absl::string_view body)
|
|
394
398
|
{
|
|
399
|
+
if (fin_buffered()) return; // we already exited
|
|
395
400
|
QUIC_DLOG(INFO) << "Stream " << id() << " writing headers (fin = false) : "
|
|
396
401
|
<< response_headers.DebugString();
|
|
397
402
|
WriteHeaders(std::move(response_headers), /*fin=*/false, nullptr);
|
|
@@ -410,6 +415,7 @@ namespace quic
|
|
|
410
415
|
HttpHeaderBlock response_headers,
|
|
411
416
|
absl::string_view body)
|
|
412
417
|
{
|
|
418
|
+
if (fin_buffered()) return; // we already exited
|
|
413
419
|
SendHeadersAndBodyAndTrailers(std::move(response_headers), body,
|
|
414
420
|
HttpHeaderBlock());
|
|
415
421
|
}
|
|
@@ -419,6 +425,7 @@ namespace quic
|
|
|
419
425
|
absl::string_view body,
|
|
420
426
|
HttpHeaderBlock response_trailers)
|
|
421
427
|
{
|
|
428
|
+
if (fin_buffered()) return; // we already exited
|
|
422
429
|
// Send the headers, with a FIN if there's nothing else to send.
|
|
423
430
|
bool send_fin = (body.empty() && response_trailers.empty());
|
|
424
431
|
QUIC_DLOG(INFO) << "Stream " << id() << " writing headers (fin = " << send_fin
|
|
@@ -50,12 +50,33 @@ namespace quic
|
|
|
50
50
|
// need to be called immediately after new
|
|
51
51
|
void init(WebTransportSession *session);
|
|
52
52
|
|
|
53
|
-
class Visitor
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
class Visitor;
|
|
54
|
+
|
|
55
|
+
class VisitorRemoveVisitor {
|
|
56
|
+
public:
|
|
57
|
+
virtual void RemoveVisitor(Http3WTSession::Visitor* visitor) = 0;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
class Visitor : public WebTransportVisitor {
|
|
61
|
+
public:
|
|
62
|
+
Visitor(Http3WTSession* session, VisitorRemoveVisitor* vrvis)
|
|
63
|
+
: session_(session), vrvis_(vrvis) {
|
|
64
|
+
/* printf(
|
|
65
|
+
"Session created Visitor %d %x %x\n", getpid(), this, session_);*/
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
~Visitor();
|
|
69
|
+
|
|
70
|
+
void AddVisitorRemoveVisitor(VisitorRemoveVisitor *vrvis) {
|
|
71
|
+
if (vrvis_) {
|
|
72
|
+
vrvis_->RemoveVisitor(this);
|
|
73
|
+
}
|
|
74
|
+
vrvis_ = vrvis;
|
|
75
|
+
}
|
|
57
76
|
|
|
58
|
-
|
|
77
|
+
void RemoveVisitorRemoveVisitor() {
|
|
78
|
+
vrvis_ = nullptr;
|
|
79
|
+
}
|
|
59
80
|
|
|
60
81
|
void OnSessionReady() override;
|
|
61
82
|
|
|
@@ -68,19 +89,18 @@ namespace quic
|
|
|
68
89
|
|
|
69
90
|
void OnDatagramReceived(absl::string_view datagram) override;
|
|
70
91
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
92
|
+
void OnCanCreateNewOutgoingBidirectionalStream() override {
|
|
93
|
+
// unclear how we can stich this together?
|
|
94
|
+
session_->TrySendingBidirectionalStreams();
|
|
95
|
+
}
|
|
76
96
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
97
|
+
void OnCanCreateNewOutgoingUnidirectionalStream() override {
|
|
98
|
+
session_->TrySendingUnidirectionalStreams();
|
|
99
|
+
}
|
|
81
100
|
|
|
82
|
-
|
|
83
|
-
|
|
101
|
+
protected:
|
|
102
|
+
Http3WTSession* session_;
|
|
103
|
+
VisitorRemoveVisitor* vrvis_;
|
|
84
104
|
};
|
|
85
105
|
|
|
86
106
|
bool
|
|
@@ -146,7 +166,6 @@ namespace quic
|
|
|
146
166
|
}
|
|
147
167
|
|
|
148
168
|
webtransport::DatagramStatus writeDatagramInt(char *buffer, size_t len, Napi::ObjectReference *bufferhandle);
|
|
149
|
-
|
|
150
169
|
WebTransportSession *session_;
|
|
151
170
|
bool echo_stream_opened_ = false;
|
|
152
171
|
|