Commit 4c00ab9

Browse files
jasnelladuh95
authored andcommitted
quic: add getters for local and remote transport parameters
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #63267 Backport-PR-URL: #64675 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 858b636 commit 4c00ab9

8 files changed

Lines changed: 465 additions & 1 deletion

File tree

β€Ždoc/api/quic.mdβ€Ž

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,17 @@ added: v23.8.0
833833

834834
True if `session.destroy()` has been called. Read only.
835835

836+
### `session.localTransportParams`
837+
838+
<!-- YAML
839+
added: REPLACEME
840+
-->
841+
842+
* Type: {quic.TransportParams|null}
843+
844+
The transport parameters advertised by the local endpoint during the handshake.
845+
Returns `null` if the session has been destroyed. Read only.
846+
836847
### `session.endpoint`
837848

838849
<!-- YAML
@@ -1126,6 +1137,19 @@ added: v23.8.0
11261137

11271138
The local and remote socket addresses associated with the session. Read only.
11281139

1140+
### `session.remoteTransportParams`
1141+
1142+
<!-- YAML
1143+
added: REPLACEME
1144+
-->
1145+
1146+
* Type: {quic.TransportParams|null|undefined}
1147+
1148+
The transport parameters advertised by the remote peer during the handshake.
1149+
Returns `null` if the session has been destroyed, `undefined` if the handshake
1150+
has not yet completed and the remote parameters are not yet available. Read
1151+
only.
1152+
11291153
### `session.sendDatagram(datagram[, encoding])`
11301154

11311155
<!-- YAML
@@ -2927,6 +2951,37 @@ won't have need to specify.
29272951
added: v23.8.0
29282952
-->
29292953

2954+
The `TransportParams` type represents the QUIC transport parameters that are
2955+
negotiated during session establishment. These parameters are used when
2956+
creating a session. The negotiated values can be observed via the
2957+
`session.localTransportParams` and `session.remoteTransportParams` properties.
2958+
2959+
#### `transportParams.initialSCID`
2960+
2961+
<!-- YAML
2962+
added: REPLACEME
2963+
-->
2964+
2965+
* Type: {string}
2966+
2967+
The initial source connection ID (SCID) specified. This field is ignored on
2968+
creation of the session and is provided for informational purposes only when
2969+
available in the `session.localTransportParams` and
2970+
`session.remoteTransportParams` properties.
2971+
2972+
#### `transportParams.originalDCID`
2973+
2974+
<!-- YAML
2975+
added: REPLACEME
2976+
-->
2977+
2978+
* Type: {string}
2979+
2980+
The original destination connection ID (DCID) specified. This field is
2981+
ignored on creation of the session and is provided for informational
2982+
purposes only when available in the `session.localTransportParams` and
2983+
`session.remoteTransportParams` properties.
2984+
29302985
#### `transportParams.preferredAddressIpv4`
29312986

29322987
<!-- YAML
@@ -3040,6 +3095,19 @@ will not send datagrams larger than this value. The actual maximum size of
30403095
a datagram that can be _sent_ is determined by the peer's
30413096
`maxDatagramFrameSize`, not this endpoint's value.
30423097

3098+
#### `transportParams.retrySCID`
3099+
3100+
<!-- YAML
3101+
added: REPLACEME
3102+
-->
3103+
3104+
* Type: {string}
3105+
3106+
The retry connection ID specified. This field is ignored on creation
3107+
of the session and is provided for informational purposes only when
3108+
available in the `session.localTransportParams` and
3109+
`session.remoteTransportParams` properties.
3110+
30433111
## Callbacks
30443112

30453113
### Callback error handling

β€Žlib/internal/quic/quic.jsβ€Ž

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,6 +2626,8 @@ class QuicSession {
26262626
certificate: undefined,
26272627
peerCertificate: undefined,
26282628
ephemeralKeyInfo: undefined,
2629+
localTransportParams: undefined,
2630+
remoteTransportParams: undefined,
26292631
};
26302632

26312633
static{
@@ -2676,6 +2678,45 @@ class QuicSession {
26762678
debug('session created');
26772679
}
26782680

2681+
getlocalTransportParams(){
2682+
if(this.#inner.localTransportParams!==undefined){
2683+
returnthis.#inner.localTransportParams;
2684+
}
2685+
// If the handle is already gone, we cannot retrieve the transport params.
2686+
if(this.destroyed)returnnull;
2687+
constparams=this.#handle.localTransportParams();
2688+
if(params.preferredAddressIpv4!==undefined){
2689+
params.preferredAddressIpv4=newInternalSocketAddress(params.preferredAddressIpv4);
2690+
}
2691+
if(params.preferredAddressIpv6!==undefined){
2692+
params.preferredAddressIpv6=newInternalSocketAddress(params.preferredAddressIpv6);
2693+
}
2694+
returnthis.#inner.localTransportParams=params;
2695+
}
2696+
2697+
getremoteTransportParams(){
2698+
if(this.#inner.remoteTransportParams!==undefined){
2699+
returnthis.#inner.remoteTransportParams;
2700+
}
2701+
// If the handle is already gone, we cannot retrieve the transport params.
2702+
if(this.destroyed)returnnull;
2703+
constparams=this.#handle.remoteTransportParams();
2704+
// If params is undefined, the transport parameters have not yet been received.
2705+
// Note the distinction between this and the case where the handle is gone.
2706+
// If the handle is gone, we return null because we know the transport
2707+
// parameters will be unavailable. If the transport parameters have not yet
2708+
// been received, we return undefined to indicate that they may still become
2709+
// available in the future.
2710+
if(params===undefined)returnundefined;
2711+
if(params.preferredAddressIpv4!==undefined){
2712+
params.preferredAddressIpv4=newInternalSocketAddress(params.preferredAddressIpv4);
2713+
}
2714+
if(params.preferredAddressIpv6!==undefined){
2715+
params.preferredAddressIpv6=newInternalSocketAddress(params.preferredAddressIpv6);
2716+
}
2717+
returnthis.#inner.remoteTransportParams=params;
2718+
}
2719+
26792720
/** @type {boolean} */
26802721
get #isClosedOrClosing(){
26812722
returnthis.#handle ===undefined||this.#inner.isPendingClose;

β€Žsrc/quic/bindingdata.ccβ€Ž

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
namespacenode {
2121

2222
using mem::kReserveSizeAndAlign;
23+
using v8::DictionaryTemplate;
2324
using v8::Function;
2425
using v8::FunctionTemplate;
2526
using v8::HandleScope;
@@ -377,6 +378,16 @@ QUIC_CONSTRUCTORS(V)
377378

378379
#undef V
379380

381+
voidBindingData::set_transport_params_template(
382+
Local<DictionaryTemplate> tmpl) {
383+
transport_params_template_.Reset(env()->isolate(), tmpl);
384+
}
385+
386+
Local<DictionaryTemplate> BindingData::transport_params_template() const {
387+
returnPersistentToLocal::Default(env()->isolate(),
388+
transport_params_template_);
389+
}
390+
380391
#defineV(name, _) \
381392
void BindingData::set_##name##_callback(Local<Function> fn) { \
382393
name##_callback_.Reset(env()->isolate(), fn); \

β€Žsrc/quic/bindingdata.hβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ class BindingData final
303303
QUIC_CONSTRUCTORS(V)
304304
#undef V
305305

306+
voidset_transport_params_template(v8::Local<v8::DictionaryTemplate> tmpl);
307+
v8::Local<v8::DictionaryTemplate> transport_params_template() const;
308+
306309
#defineV(name, _) \
307310
void set_##name##_callback(v8::Local<v8::Function> fn); \
308311
v8::Local<v8::Function> name##_callback() const;
@@ -321,6 +324,8 @@ class BindingData final
321324
QUIC_CONSTRUCTORS(V)
322325
#undef V
323326

327+
v8::Global<v8::DictionaryTemplate> transport_params_template_;
328+
324329
#defineV(name, _) v8::Global<v8::Function> name##_callback_;
325330
QUIC_JS_CALLBACKS(V)
326331
#undef V

β€Žsrc/quic/session.ccβ€Ž

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ uint64_t MaxDatagramPayload(uint64_t max_frame_size) {
190190
V(SilentClose, silentClose, SIDE_EFFECT) \
191191
V(UpdateKey, updateKey, SIDE_EFFECT) \
192192
V(OpenStream, openStream, SIDE_EFFECT) \
193-
V(SendDatagram, sendDatagram, SIDE_EFFECT)
193+
V(SendDatagram, sendDatagram, SIDE_EFFECT) \
194+
V(LocalTransportParams, localTransportParams, NO_SIDE_EFFECT) \
195+
V(RemoteTransportParams, remoteTransportParams, NO_SIDE_EFFECT) \
194196

195197
structSession::State final {
196198
#defineV(_, name, type) type name;
@@ -1163,6 +1165,36 @@ struct Session::Impl final : public MemoryRetainer {
11631165
BigInt::New(env->isolate(), session->SendDatagram(std::move(store))));
11641166
}
11651167

1168+
JS_METHOD(LocalTransportParams) {
1169+
auto env = Environment::GetCurrent(args);
1170+
Session* session;
1171+
ASSIGN_OR_RETURN_UNWRAP(&session, args.This());
1172+
1173+
ngtcp2_conn* conn = *session;
1174+
TransportParams params(ngtcp2_conn_get_local_transport_params(conn));
1175+
Local<Object> obj;
1176+
if (params.ToObject(env).ToLocal(&obj)) {
1177+
args.GetReturnValue().Set(obj);
1178+
}
1179+
}
1180+
1181+
JS_METHOD(RemoteTransportParams) {
1182+
auto env = Environment::GetCurrent(args);
1183+
Session* session;
1184+
ASSIGN_OR_RETURN_UNWRAP(&session, args.This());
1185+
1186+
ngtcp2_conn* conn = *session;
1187+
auto params = ngtcp2_conn_get_remote_transport_params(conn);
1188+
if (params == nullptr) {
1189+
// Remote transport parameters are not yet available.
1190+
return args.GetReturnValue().SetUndefined();
1191+
}
1192+
TransportParams tp(params);
1193+
Local<Object> obj;
1194+
if (tp.ToObject(env).ToLocal(&obj)) {
1195+
args.GetReturnValue().Set(obj);
1196+
}
1197+
}
11661198
// Internal ngtcp2 callbacks
11671199

11681200
staticinton_acknowledge_stream_data_offset(ngtcp2_conn* conn,

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Commit 4c00ab9

Browse files
jasnelladuh95
authored andcommitted
quic: add getters for local and remote transport parameters
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #63267 Backport-PR-URL: #64675 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 858b636 commit 4c00ab9

8 files changed

Lines changed: 465 additions & 1 deletion

File tree

β€Ždoc/api/quic.mdβ€Ž

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,17 @@ added: v23.8.0
833833

834834
True if `session.destroy()` has been called. Read only.
835835

836+
### `session.localTransportParams`
837+
838+
<!-- YAML
839+
added: REPLACEME
840+
-->
841+
842+
* Type: {quic.TransportParams|null}
843+
844+
The transport parameters advertised by the local endpoint during the handshake.
845+
Returns `null` if the session has been destroyed. Read only.
846+
836847
### `session.endpoint`
837848

838849
<!-- YAML
@@ -1126,6 +1137,19 @@ added: v23.8.0
11261137

11271138
The local and remote socket addresses associated with the session. Read only.
11281139

1140+
### `session.remoteTransportParams`
1141+
1142+
<!-- YAML
1143+
added: REPLACEME
1144+
-->
1145+
1146+
* Type: {quic.TransportParams|null|undefined}
1147+
1148+
The transport parameters advertised by the remote peer during the handshake.
1149+
Returns `null` if the session has been destroyed, `undefined` if the handshake
1150+
has not yet completed and the remote parameters are not yet available. Read
1151+
only.
1152+
11291153
### `session.sendDatagram(datagram[, encoding])`
11301154

11311155
<!-- YAML
@@ -2927,6 +2951,37 @@ won't have need to specify.
29272951
added: v23.8.0
29282952
-->
29292953

2954+
The `TransportParams` type represents the QUIC transport parameters that are
2955+
negotiated during session establishment. These parameters are used when
2956+
creating a session. The negotiated values can be observed via the
2957+
`session.localTransportParams` and `session.remoteTransportParams` properties.
2958+
2959+
#### `transportParams.initialSCID`
2960+
2961+
<!-- YAML
2962+
added: REPLACEME
2963+
-->
2964+
2965+
* Type: {string}
2966+
2967+
The initial source connection ID (SCID) specified. This field is ignored on
2968+
creation of the session and is provided for informational purposes only when
2969+
available in the `session.localTransportParams` and
2970+
`session.remoteTransportParams` properties.
2971+
2972+
#### `transportParams.originalDCID`
2973+
2974+
<!-- YAML
2975+
added: REPLACEME
2976+
-->
2977+
2978+
* Type: {string}
2979+
2980+
The original destination connection ID (DCID) specified. This field is
2981+
ignored on creation of the session and is provided for informational
2982+
purposes only when available in the `session.localTransportParams` and
2983+
`session.remoteTransportParams` properties.
2984+
29302985
#### `transportParams.preferredAddressIpv4`
29312986

29322987
<!-- YAML
@@ -3040,6 +3095,19 @@ will not send datagrams larger than this value. The actual maximum size of
30403095
a datagram that can be _sent_ is determined by the peer's
30413096
`maxDatagramFrameSize`, not this endpoint's value.
30423097

3098+
#### `transportParams.retrySCID`
3099+
3100+
<!-- YAML
3101+
added: REPLACEME
3102+
-->
3103+
3104+
* Type: {string}
3105+
3106+
The retry connection ID specified. This field is ignored on creation
3107+
of the session and is provided for informational purposes only when
3108+
available in the `session.localTransportParams` and
3109+
`session.remoteTransportParams` properties.
3110+
30433111
## Callbacks
30443112

30453113
### Callback error handling

β€Žlib/internal/quic/quic.jsβ€Ž

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,6 +2626,8 @@ class QuicSession {
26262626
certificate: undefined,
26272627
peerCertificate: undefined,
26282628
ephemeralKeyInfo: undefined,
2629+
localTransportParams: undefined,
2630+
remoteTransportParams: undefined,
26292631
};
26302632

26312633
static{
@@ -2676,6 +2678,45 @@ class QuicSession {
26762678
debug('session created');
26772679
}
26782680

2681+
getlocalTransportParams(){
2682+
if(this.#inner.localTransportParams!==undefined){
2683+
returnthis.#inner.localTransportParams;
2684+
}
2685+
// If the handle is already gone, we cannot retrieve the transport params.
2686+
if(this.destroyed)returnnull;
2687+
constparams=this.#handle.localTransportParams();
2688+
if(params.preferredAddressIpv4!==undefined){
2689+
params.preferredAddressIpv4=newInternalSocketAddress(params.preferredAddressIpv4);
2690+
}
2691+
if(params.preferredAddressIpv6!==undefined){
2692+
params.preferredAddressIpv6=newInternalSocketAddress(params.preferredAddressIpv6);
2693+
}
2694+
returnthis.#inner.localTransportParams=params;
2695+
}
2696+
2697+
getremoteTransportParams(){
2698+
if(this.#inner.remoteTransportParams!==undefined){
2699+
returnthis.#inner.remoteTransportParams;
2700+
}
2701+
// If the handle is already gone, we cannot retrieve the transport params.
2702+
if(this.destroyed)returnnull;
2703+
constparams=this.#handle.remoteTransportParams();
2704+
// If params is undefined, the transport parameters have not yet been received.
2705+
// Note the distinction between this and the case where the handle is gone.
2706+
// If the handle is gone, we return null because we know the transport
2707+
// parameters will be unavailable. If the transport parameters have not yet
2708+
// been received, we return undefined to indicate that they may still become
2709+
// available in the future.
2710+
if(params===undefined)returnundefined;
2711+
if(params.preferredAddressIpv4!==undefined){
2712+
params.preferredAddressIpv4=newInternalSocketAddress(params.preferredAddressIpv4);
2713+
}
2714+
if(params.preferredAddressIpv6!==undefined){
2715+
params.preferredAddressIpv6=newInternalSocketAddress(params.preferredAddressIpv6);
2716+
}
2717+
returnthis.#inner.remoteTransportParams=params;
2718+
}
2719+
26792720
/** @type {boolean} */
26802721
get #isClosedOrClosing(){
26812722
returnthis.#handle ===undefined||this.#inner.isPendingClose;

β€Žsrc/quic/bindingdata.ccβ€Ž

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
namespacenode {
2121

2222
using mem::kReserveSizeAndAlign;
23+
using v8::DictionaryTemplate;
2324
using v8::Function;
2425
using v8::FunctionTemplate;
2526
using v8::HandleScope;
@@ -377,6 +378,16 @@ QUIC_CONSTRUCTORS(V)
377378

378379
#undef V
379380

381+
voidBindingData::set_transport_params_template(
382+
Local<DictionaryTemplate> tmpl) {
383+
transport_params_template_.Reset(env()->isolate(), tmpl);
384+
}
385+
386+
Local<DictionaryTemplate> BindingData::transport_params_template() const {
387+
returnPersistentToLocal::Default(env()->isolate(),
388+
transport_params_template_);
389+
}
390+
380391
#defineV(name, _) \
381392
void BindingData::set_##name##_callback(Local<Function> fn) { \
382393
name##_callback_.Reset(env()->isolate(), fn); \

β€Žsrc/quic/bindingdata.hβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ class BindingData final
303303
QUIC_CONSTRUCTORS(V)
304304
#undef V
305305

306+
voidset_transport_params_template(v8::Local<v8::DictionaryTemplate> tmpl);
307+
v8::Local<v8::DictionaryTemplate> transport_params_template() const;
308+
306309
#defineV(name, _) \
307310
void set_##name##_callback(v8::Local<v8::Function> fn); \
308311
v8::Local<v8::Function> name##_callback() const;
@@ -321,6 +324,8 @@ class BindingData final
321324
QUIC_CONSTRUCTORS(V)
322325
#undef V
323326

327+
v8::Global<v8::DictionaryTemplate> transport_params_template_;
328+
324329
#defineV(name, _) v8::Global<v8::Function> name##_callback_;
325330
QUIC_JS_CALLBACKS(V)
326331
#undef V

β€Žsrc/quic/session.ccβ€Ž

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ uint64_t MaxDatagramPayload(uint64_t max_frame_size) {
190190
V(SilentClose, silentClose, SIDE_EFFECT) \
191191
V(UpdateKey, updateKey, SIDE_EFFECT) \
192192
V(OpenStream, openStream, SIDE_EFFECT) \
193-
V(SendDatagram, sendDatagram, SIDE_EFFECT)
193+
V(SendDatagram, sendDatagram, SIDE_EFFECT) \
194+
V(LocalTransportParams, localTransportParams, NO_SIDE_EFFECT) \
195+
V(RemoteTransportParams, remoteTransportParams, NO_SIDE_EFFECT) \
194196

195197
structSession::State final {
196198
#defineV(_, name, type) type name;
@@ -1163,6 +1165,36 @@ struct Session::Impl final : public MemoryRetainer {
11631165
BigInt::New(env->isolate(), session->SendDatagram(std::move(store))));
11641166
}
11651167

1168+
JS_METHOD(LocalTransportParams) {
1169+
auto env = Environment::GetCurrent(args);
1170+
Session* session;
1171+
ASSIGN_OR_RETURN_UNWRAP(&session, args.This());
1172+
1173+
ngtcp2_conn* conn = *session;
1174+
TransportParams params(ngtcp2_conn_get_local_transport_params(conn));
1175+
Local<Object> obj;
1176+
if (params.ToObject(env).ToLocal(&obj)) {
1177+
args.GetReturnValue().Set(obj);
1178+
}
1179+
}
1180+
1181+
JS_METHOD(RemoteTransportParams) {
1182+
auto env = Environment::GetCurrent(args);
1183+
Session* session;
1184+
ASSIGN_OR_RETURN_UNWRAP(&session, args.This());
1185+
1186+
ngtcp2_conn* conn = *session;
1187+
auto params = ngtcp2_conn_get_remote_transport_params(conn);
1188+
if (params == nullptr) {
1189+
// Remote transport parameters are not yet available.
1190+
return args.GetReturnValue().SetUndefined();
1191+
}
1192+
TransportParams tp(params);
1193+
Local<Object> obj;
1194+
if (tp.ToObject(env).ToLocal(&obj)) {
1195+
args.GetReturnValue().Set(obj);
1196+
}
1197+
}
11661198
// Internal ngtcp2 callbacks
11671199

11681200
staticinton_acknowledge_stream_data_offset(ngtcp2_conn* conn,

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 4c00ab9

Browse files
jasnelladuh95
authored andcommitted
quic: add getters for local and remote transport parameters
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #63267 Backport-PR-URL: #64675 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 858b636 commit 4c00ab9

8 files changed

Lines changed: 465 additions & 1 deletion

File tree

β€Ždoc/api/quic.mdβ€Ž

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,17 @@ added: v23.8.0
833833

834834
True if `session.destroy()` has been called. Read only.
835835

836+
### `session.localTransportParams`
837+
838+
<!-- YAML
839+
added: REPLACEME
840+
-->
841+
842+
* Type: {quic.TransportParams|null}
843+
844+
The transport parameters advertised by the local endpoint during the handshake.
845+
Returns `null` if the session has been destroyed. Read only.
846+
836847
### `session.endpoint`
837848

838849
<!-- YAML
@@ -1126,6 +1137,19 @@ added: v23.8.0
11261137

11271138
The local and remote socket addresses associated with the session. Read only.
11281139

1140+
### `session.remoteTransportParams`
1141+
1142+
<!-- YAML
1143+
added: REPLACEME
1144+
-->
1145+
1146+
* Type: {quic.TransportParams|null|undefined}
1147+
1148+
The transport parameters advertised by the remote peer during the handshake.
1149+
Returns `null` if the session has been destroyed, `undefined` if the handshake
1150+
has not yet completed and the remote parameters are not yet available. Read
1151+
only.
1152+
11291153
### `session.sendDatagram(datagram[, encoding])`
11301154

11311155
<!-- YAML
@@ -2927,6 +2951,37 @@ won't have need to specify.
29272951
added: v23.8.0
29282952
-->
29292953

2954+
The `TransportParams` type represents the QUIC transport parameters that are
2955+
negotiated during session establishment. These parameters are used when
2956+
creating a session. The negotiated values can be observed via the
2957+
`session.localTransportParams` and `session.remoteTransportParams` properties.
2958+
2959+
#### `transportParams.initialSCID`
2960+
2961+
<!-- YAML
2962+
added: REPLACEME
2963+
-->
2964+
2965+
* Type: {string}
2966+
2967+
The initial source connection ID (SCID) specified. This field is ignored on
2968+
creation of the session and is provided for informational purposes only when
2969+
available in the `session.localTransportParams` and
2970+
`session.remoteTransportParams` properties.
2971+
2972+
#### `transportParams.originalDCID`
2973+
2974+
<!-- YAML
2975+
added: REPLACEME
2976+
-->
2977+
2978+
* Type: {string}
2979+
2980+
The original destination connection ID (DCID) specified. This field is
2981+
ignored on creation of the session and is provided for informational
2982+
purposes only when available in the `session.localTransportParams` and
2983+
`session.remoteTransportParams` properties.
2984+
29302985
#### `transportParams.preferredAddressIpv4`
29312986

29322987
<!-- YAML
@@ -3040,6 +3095,19 @@ will not send datagrams larger than this value. The actual maximum size of
30403095
a datagram that can be _sent_ is determined by the peer's
30413096
`maxDatagramFrameSize`, not this endpoint's value.
30423097

3098+
#### `transportParams.retrySCID`
3099+
3100+
<!-- YAML
3101+
added: REPLACEME
3102+
-->
3103+
3104+
* Type: {string}
3105+
3106+
The retry connection ID specified. This field is ignored on creation
3107+
of the session and is provided for informational purposes only when
3108+
available in the `session.localTransportParams` and
3109+
`session.remoteTransportParams` properties.
3110+
30433111
## Callbacks
30443112

30453113
### Callback error handling

β€Žlib/internal/quic/quic.jsβ€Ž

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,6 +2626,8 @@ class QuicSession {
26262626
certificate: undefined,
26272627
peerCertificate: undefined,
26282628
ephemeralKeyInfo: undefined,
2629+
localTransportParams: undefined,
2630+
remoteTransportParams: undefined,
26292631
};
26302632

26312633
static{
@@ -2676,6 +2678,45 @@ class QuicSession {
26762678
debug('session created');
26772679
}
26782680

2681+
getlocalTransportParams(){
2682+
if(this.#inner.localTransportParams!==undefined){
2683+
returnthis.#inner.localTransportParams;
2684+
}
2685+
// If the handle is already gone, we cannot retrieve the transport params.
2686+
if(this.destroyed)returnnull;
2687+
constparams=this.#handle.localTransportParams();
2688+
if(params.preferredAddressIpv4!==undefined){
2689+
params.preferredAddressIpv4=newInternalSocketAddress(params.preferredAddressIpv4);
2690+
}
2691+
if(params.preferredAddressIpv6!==undefined){
2692+
params.preferredAddressIpv6=newInternalSocketAddress(params.preferredAddressIpv6);
2693+
}
2694+
returnthis.#inner.localTransportParams=params;
2695+
}
2696+
2697+
getremoteTransportParams(){
2698+
if(this.#inner.remoteTransportParams!==undefined){
2699+
returnthis.#inner.remoteTransportParams;
2700+
}
2701+
// If the handle is already gone, we cannot retrieve the transport params.
2702+
if(this.destroyed)returnnull;
2703+
constparams=this.#handle.remoteTransportParams();
2704+
// If params is undefined, the transport parameters have not yet been received.
2705+
// Note the distinction between this and the case where the handle is gone.
2706+
// If the handle is gone, we return null because we know the transport
2707+
// parameters will be unavailable. If the transport parameters have not yet
2708+
// been received, we return undefined to indicate that they may still become
2709+
// available in the future.
2710+
if(params===undefined)returnundefined;
2711+
if(params.preferredAddressIpv4!==undefined){
2712+
params.preferredAddressIpv4=newInternalSocketAddress(params.preferredAddressIpv4);
2713+
}
2714+
if(params.preferredAddressIpv6!==undefined){
2715+
params.preferredAddressIpv6=newInternalSocketAddress(params.preferredAddressIpv6);
2716+
}
2717+
returnthis.#inner.remoteTransportParams=params;
2718+
}
2719+
26792720
/** @type {boolean} */
26802721
get #isClosedOrClosing(){
26812722
returnthis.#handle ===undefined||this.#inner.isPendingClose;

β€Žsrc/quic/bindingdata.ccβ€Ž

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
namespacenode {
2121

2222
using mem::kReserveSizeAndAlign;
23+
using v8::DictionaryTemplate;
2324
using v8::Function;
2425
using v8::FunctionTemplate;
2526
using v8::HandleScope;
@@ -377,6 +378,16 @@ QUIC_CONSTRUCTORS(V)
377378

378379
#undef V
379380

381+
voidBindingData::set_transport_params_template(
382+
Local<DictionaryTemplate> tmpl) {
383+
transport_params_template_.Reset(env()->isolate(), tmpl);
384+
}
385+
386+
Local<DictionaryTemplate> BindingData::transport_params_template() const {
387+
returnPersistentToLocal::Default(env()->isolate(),
388+
transport_params_template_);
389+
}
390+
380391
#defineV(name, _) \
381392
void BindingData::set_##name##_callback(Local<Function> fn) { \
382393
name##_callback_.Reset(env()->isolate(), fn); \

β€Žsrc/quic/bindingdata.hβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ class BindingData final
303303
QUIC_CONSTRUCTORS(V)
304304
#undef V
305305

306+
voidset_transport_params_template(v8::Local<v8::DictionaryTemplate> tmpl);
307+
v8::Local<v8::DictionaryTemplate> transport_params_template() const;
308+
306309
#defineV(name, _) \
307310
void set_##name##_callback(v8::Local<v8::Function> fn); \
308311
v8::Local<v8::Function> name##_callback() const;
@@ -321,6 +324,8 @@ class BindingData final
321324
QUIC_CONSTRUCTORS(V)
322325
#undef V
323326

327+
v8::Global<v8::DictionaryTemplate> transport_params_template_;
328+
324329
#defineV(name, _) v8::Global<v8::Function> name##_callback_;
325330
QUIC_JS_CALLBACKS(V)
326331
#undef V

β€Žsrc/quic/session.ccβ€Ž

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ uint64_t MaxDatagramPayload(uint64_t max_frame_size) {
190190
V(SilentClose, silentClose, SIDE_EFFECT) \
191191
V(UpdateKey, updateKey, SIDE_EFFECT) \
192192
V(OpenStream, openStream, SIDE_EFFECT) \
193-
V(SendDatagram, sendDatagram, SIDE_EFFECT)
193+
V(SendDatagram, sendDatagram, SIDE_EFFECT) \
194+
V(LocalTransportParams, localTransportParams, NO_SIDE_EFFECT) \
195+
V(RemoteTransportParams, remoteTransportParams, NO_SIDE_EFFECT) \
194196

195197
structSession::State final {
196198
#defineV(_, name, type) type name;
@@ -1163,6 +1165,36 @@ struct Session::Impl final : public MemoryRetainer {
11631165
BigInt::New(env->isolate(), session->SendDatagram(std::move(store))));
11641166
}
11651167

1168+
JS_METHOD(LocalTransportParams) {
1169+
auto env = Environment::GetCurrent(args);
1170+
Session* session;
1171+
ASSIGN_OR_RETURN_UNWRAP(&session, args.This());
1172+
1173+
ngtcp2_conn* conn = *session;
1174+
TransportParams params(ngtcp2_conn_get_local_transport_params(conn));
1175+
Local<Object> obj;
1176+
if (params.ToObject(env).ToLocal(&obj)) {
1177+
args.GetReturnValue().Set(obj);
1178+
}
1179+
}
1180+
1181+
JS_METHOD(RemoteTransportParams) {
1182+
auto env = Environment::GetCurrent(args);
1183+
Session* session;
1184+
ASSIGN_OR_RETURN_UNWRAP(&session, args.This());
1185+
1186+
ngtcp2_conn* conn = *session;
1187+
auto params = ngtcp2_conn_get_remote_transport_params(conn);
1188+
if (params == nullptr) {
1189+
// Remote transport parameters are not yet available.
1190+
return args.GetReturnValue().SetUndefined();
1191+
}
1192+
TransportParams tp(params);
1193+
Local<Object> obj;
1194+
if (tp.ToObject(env).ToLocal(&obj)) {
1195+
args.GetReturnValue().Set(obj);
1196+
}
1197+
}
11661198
// Internal ngtcp2 callbacks
11671199

11681200
staticinton_acknowledge_stream_data_offset(ngtcp2_conn* conn,

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 4c00ab9

Browse files
jasnelladuh95
authored andcommitted
quic: add getters for local and remote transport parameters
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #63267 Backport-PR-URL: #64675 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 858b636 commit 4c00ab9

8 files changed

Lines changed: 465 additions & 1 deletion

File tree

β€Ždoc/api/quic.mdβ€Ž

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,17 @@ added: v23.8.0
833833

834834
True if `session.destroy()` has been called. Read only.
835835

836+
### `session.localTransportParams`
837+
838+
<!-- YAML
839+
added: REPLACEME
840+
-->
841+
842+
* Type: {quic.TransportParams|null}
843+
844+
The transport parameters advertised by the local endpoint during the handshake.
845+
Returns `null` if the session has been destroyed. Read only.
846+
836847
### `session.endpoint`
837848

838849
<!-- YAML
@@ -1126,6 +1137,19 @@ added: v23.8.0
11261137

11271138
The local and remote socket addresses associated with the session. Read only.
11281139

1140+
### `session.remoteTransportParams`
1141+
1142+
<!-- YAML
1143+
added: REPLACEME
1144+
-->
1145+
1146+
* Type: {quic.TransportParams|null|undefined}
1147+
1148+
The transport parameters advertised by the remote peer during the handshake.
1149+
Returns `null` if the session has been destroyed, `undefined` if the handshake
1150+
has not yet completed and the remote parameters are not yet available. Read
1151+
only.
1152+
11291153
### `session.sendDatagram(datagram[, encoding])`
11301154

11311155
<!-- YAML
@@ -2927,6 +2951,37 @@ won't have need to specify.
29272951
added: v23.8.0
29282952
-->
29292953

2954+
The `TransportParams` type represents the QUIC transport parameters that are
2955+
negotiated during session establishment. These parameters are used when
2956+
creating a session. The negotiated values can be observed via the
2957+
`session.localTransportParams` and `session.remoteTransportParams` properties.
2958+
2959+
#### `transportParams.initialSCID`
2960+
2961+
<!-- YAML
2962+
added: REPLACEME
2963+
-->
2964+
2965+
* Type: {string}
2966+
2967+
The initial source connection ID (SCID) specified. This field is ignored on
2968+
creation of the session and is provided for informational purposes only when
2969+
available in the `session.localTransportParams` and
2970+
`session.remoteTransportParams` properties.
2971+
2972+
#### `transportParams.originalDCID`
2973+
2974+
<!-- YAML
2975+
added: REPLACEME
2976+
-->
2977+
2978+
* Type: {string}
2979+
2980+
The original destination connection ID (DCID) specified. This field is
2981+
ignored on creation of the session and is provided for informational
2982+
purposes only when available in the `session.localTransportParams` and
2983+
`session.remoteTransportParams` properties.
2984+
29302985
#### `transportParams.preferredAddressIpv4`
29312986

29322987
<!-- YAML
@@ -3040,6 +3095,19 @@ will not send datagrams larger than this value. The actual maximum size of
30403095
a datagram that can be _sent_ is determined by the peer's
30413096
`maxDatagramFrameSize`, not this endpoint's value.
30423097

3098+
#### `transportParams.retrySCID`
3099+
3100+
<!-- YAML
3101+
added: REPLACEME
3102+
-->
3103+
3104+
* Type: {string}
3105+
3106+
The retry connection ID specified. This field is ignored on creation
3107+
of the session and is provided for informational purposes only when
3108+
available in the `session.localTransportParams` and
3109+
`session.remoteTransportParams` properties.
3110+
30433111
## Callbacks
30443112

30453113
### Callback error handling

β€Žlib/internal/quic/quic.jsβ€Ž

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,6 +2626,8 @@ class QuicSession {
26262626
certificate: undefined,
26272627
peerCertificate: undefined,
26282628
ephemeralKeyInfo: undefined,
2629+
localTransportParams: undefined,
2630+
remoteTransportParams: undefined,
26292631
};
26302632

26312633
static{
@@ -2676,6 +2678,45 @@ class QuicSession {
26762678
debug('session created');
26772679
}
26782680

2681+
getlocalTransportParams(){
2682+
if(this.#inner.localTransportParams!==undefined){
2683+
returnthis.#inner.localTransportParams;
2684+
}
2685+
// If the handle is already gone, we cannot retrieve the transport params.
2686+
if(this.destroyed)returnnull;
2687+
constparams=this.#handle.localTransportParams();
2688+
if(params.preferredAddressIpv4!==undefined){
2689+
params.preferredAddressIpv4=newInternalSocketAddress(params.preferredAddressIpv4);
2690+
}
2691+
if(params.preferredAddressIpv6!==undefined){
2692+
params.preferredAddressIpv6=newInternalSocketAddress(params.preferredAddressIpv6);
2693+
}
2694+
returnthis.#inner.localTransportParams=params;
2695+
}
2696+
2697+
getremoteTransportParams(){
2698+
if(this.#inner.remoteTransportParams!==undefined){
2699+
returnthis.#inner.remoteTransportParams;
2700+
}
2701+
// If the handle is already gone, we cannot retrieve the transport params.
2702+
if(this.destroyed)returnnull;
2703+
constparams=this.#handle.remoteTransportParams();
2704+
// If params is undefined, the transport parameters have not yet been received.
2705+
// Note the distinction between this and the case where the handle is gone.
2706+
// If the handle is gone, we return null because we know the transport
2707+
// parameters will be unavailable. If the transport parameters have not yet
2708+
// been received, we return undefined to indicate that they may still become
2709+
// available in the future.
2710+
if(params===undefined)returnundefined;
2711+
if(params.preferredAddressIpv4!==undefined){
2712+
params.preferredAddressIpv4=newInternalSocketAddress(params.preferredAddressIpv4);
2713+
}
2714+
if(params.preferredAddressIpv6!==undefined){
2715+
params.preferredAddressIpv6=newInternalSocketAddress(params.preferredAddressIpv6);
2716+
}
2717+
returnthis.#inner.remoteTransportParams=params;
2718+
}
2719+
26792720
/** @type {boolean} */
26802721
get #isClosedOrClosing(){
26812722
returnthis.#handle ===undefined||this.#inner.isPendingClose;

β€Žsrc/quic/bindingdata.ccβ€Ž

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
namespacenode {
2121

2222
using mem::kReserveSizeAndAlign;
23+
using v8::DictionaryTemplate;
2324
using v8::Function;
2425
using v8::FunctionTemplate;
2526
using v8::HandleScope;
@@ -377,6 +378,16 @@ QUIC_CONSTRUCTORS(V)
377378

378379
#undef V
379380

381+
voidBindingData::set_transport_params_template(
382+
Local<DictionaryTemplate> tmpl) {
383+
transport_params_template_.Reset(env()->isolate(), tmpl);
384+
}
385+
386+
Local<DictionaryTemplate> BindingData::transport_params_template() const {
387+
returnPersistentToLocal::Default(env()->isolate(),
388+
transport_params_template_);
389+
}
390+
380391
#defineV(name, _) \
381392
void BindingData::set_##name##_callback(Local<Function> fn) { \
382393
name##_callback_.Reset(env()->isolate(), fn); \

β€Žsrc/quic/bindingdata.hβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ class BindingData final
303303
QUIC_CONSTRUCTORS(V)
304304
#undef V
305305

306+
voidset_transport_params_template(v8::Local<v8::DictionaryTemplate> tmpl);
307+
v8::Local<v8::DictionaryTemplate> transport_params_template() const;
308+
306309
#defineV(name, _) \
307310
void set_##name##_callback(v8::Local<v8::Function> fn); \
308311
v8::Local<v8::Function> name##_callback() const;
@@ -321,6 +324,8 @@ class BindingData final
321324
QUIC_CONSTRUCTORS(V)
322325
#undef V
323326

327+
v8::Global<v8::DictionaryTemplate> transport_params_template_;
328+
324329
#defineV(name, _) v8::Global<v8::Function> name##_callback_;
325330
QUIC_JS_CALLBACKS(V)
326331
#undef V

β€Žsrc/quic/session.ccβ€Ž

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ uint64_t MaxDatagramPayload(uint64_t max_frame_size) {
190190
V(SilentClose, silentClose, SIDE_EFFECT) \
191191
V(UpdateKey, updateKey, SIDE_EFFECT) \
192192
V(OpenStream, openStream, SIDE_EFFECT) \
193-
V(SendDatagram, sendDatagram, SIDE_EFFECT)
193+
V(SendDatagram, sendDatagram, SIDE_EFFECT) \
194+
V(LocalTransportParams, localTransportParams, NO_SIDE_EFFECT) \
195+
V(RemoteTransportParams, remoteTransportParams, NO_SIDE_EFFECT) \
194196

195197
structSession::State final {
196198
#defineV(_, name, type) type name;
@@ -1163,6 +1165,36 @@ struct Session::Impl final : public MemoryRetainer {
11631165
BigInt::New(env->isolate(), session->SendDatagram(std::move(store))));
11641166
}
11651167

1168+
JS_METHOD(LocalTransportParams) {
1169+
auto env = Environment::GetCurrent(args);
1170+
Session* session;
1171+
ASSIGN_OR_RETURN_UNWRAP(&session, args.This());
1172+
1173+
ngtcp2_conn* conn = *session;
1174+
TransportParams params(ngtcp2_conn_get_local_transport_params(conn));
1175+
Local<Object> obj;
1176+
if (params.ToObject(env).ToLocal(&obj)) {
1177+
args.GetReturnValue().Set(obj);
1178+
}
1179+
}
1180+
1181+
JS_METHOD(RemoteTransportParams) {
1182+
auto env = Environment::GetCurrent(args);
1183+
Session* session;
1184+
ASSIGN_OR_RETURN_UNWRAP(&session, args.This());
1185+
1186+
ngtcp2_conn* conn = *session;
1187+
auto params = ngtcp2_conn_get_remote_transport_params(conn);
1188+
if (params == nullptr) {
1189+
// Remote transport parameters are not yet available.
1190+
return args.GetReturnValue().SetUndefined();
1191+
}
1192+
TransportParams tp(params);
1193+
Local<Object> obj;
1194+
if (tp.ToObject(env).ToLocal(&obj)) {
1195+
args.GetReturnValue().Set(obj);
1196+
}
1197+
}
11661198
// Internal ngtcp2 callbacks
11671199

11681200
staticinton_acknowledge_stream_data_offset(ngtcp2_conn* conn,

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Commit 4c00ab9

Browse files
jasnelladuh95
authored andcommitted
quic: add getters for local and remote transport parameters
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #63267 Backport-PR-URL: #64675 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 858b636 commit 4c00ab9

8 files changed

Lines changed: 465 additions & 1 deletion

File tree

β€Ždoc/api/quic.mdβ€Ž

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,17 @@ added: v23.8.0
833833

834834
True if `session.destroy()` has been called. Read only.
835835

836+
### `session.localTransportParams`
837+
838+
<!-- YAML
839+
added: REPLACEME
840+
-->
841+
842+
* Type: {quic.TransportParams|null}
843+
844+
The transport parameters advertised by the local endpoint during the handshake.
845+
Returns `null` if the session has been destroyed. Read only.
846+
836847
### `session.endpoint`
837848

838849
<!-- YAML
@@ -1126,6 +1137,19 @@ added: v23.8.0
11261137

11271138
The local and remote socket addresses associated with the session. Read only.
11281139

1140+
### `session.remoteTransportParams`
1141+
1142+
<!-- YAML
1143+
added: REPLACEME
1144+
-->
1145+
1146+
* Type: {quic.TransportParams|null|undefined}
1147+
1148+
The transport parameters advertised by the remote peer during the handshake.
1149+
Returns `null` if the session has been destroyed, `undefined` if the handshake
1150+
has not yet completed and the remote parameters are not yet available. Read
1151+
only.
1152+
11291153
### `session.sendDatagram(datagram[, encoding])`
11301154

11311155
<!-- YAML
@@ -2927,6 +2951,37 @@ won't have need to specify.
29272951
added: v23.8.0
29282952
-->
29292953

2954+
The `TransportParams` type represents the QUIC transport parameters that are
2955+
negotiated during session establishment. These parameters are used when
2956+
creating a session. The negotiated values can be observed via the
2957+
`session.localTransportParams` and `session.remoteTransportParams` properties.
2958+
2959+
#### `transportParams.initialSCID`
2960+
2961+
<!-- YAML
2962+
added: REPLACEME
2963+
-->
2964+
2965+
* Type: {string}
2966+
2967+
The initial source connection ID (SCID) specified. This field is ignored on
2968+
creation of the session and is provided for informational purposes only when
2969+
available in the `session.localTransportParams` and
2970+
`session.remoteTransportParams` properties.
2971+
2972+
#### `transportParams.originalDCID`
2973+
2974+
<!-- YAML
2975+
added: REPLACEME
2976+
-->
2977+
2978+
* Type: {string}
2979+
2980+
The original destination connection ID (DCID) specified. This field is
2981+
ignored on creation of the session and is provided for informational
2982+
purposes only when available in the `session.localTransportParams` and
2983+
`session.remoteTransportParams` properties.
2984+
29302985
#### `transportParams.preferredAddressIpv4`
29312986

29322987
<!-- YAML
@@ -3040,6 +3095,19 @@ will not send datagrams larger than this value. The actual maximum size of
30403095
a datagram that can be _sent_ is determined by the peer's
30413096
`maxDatagramFrameSize`, not this endpoint's value.
30423097

3098+
#### `transportParams.retrySCID`
3099+
3100+
<!-- YAML
3101+
added: REPLACEME
3102+
-->
3103+
3104+
* Type: {string}
3105+
3106+
The retry connection ID specified. This field is ignored on creation
3107+
of the session and is provided for informational purposes only when
3108+
available in the `session.localTransportParams` and
3109+
`session.remoteTransportParams` properties.
3110+
30433111
## Callbacks
30443112

30453113
### Callback error handling

β€Žlib/internal/quic/quic.jsβ€Ž

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,6 +2626,8 @@ class QuicSession {
26262626
certificate: undefined,
26272627
peerCertificate: undefined,
26282628
ephemeralKeyInfo: undefined,
2629+
localTransportParams: undefined,
2630+
remoteTransportParams: undefined,
26292631
};
26302632

26312633
static{
@@ -2676,6 +2678,45 @@ class QuicSession {
26762678
debug('session created');
26772679
}
26782680

2681+
getlocalTransportParams(){
2682+
if(this.#inner.localTransportParams!==undefined){
2683+
returnthis.#inner.localTransportParams;
2684+
}
2685+
// If the handle is already gone, we cannot retrieve the transport params.
2686+
if(this.destroyed)returnnull;
2687+
constparams=this.#handle.localTransportParams();
2688+
if(params.preferredAddressIpv4!==undefined){
2689+
params.preferredAddressIpv4=newInternalSocketAddress(params.preferredAddressIpv4);
2690+
}
2691+
if(params.preferredAddressIpv6!==undefined){
2692+
params.preferredAddressIpv6=newInternalSocketAddress(params.preferredAddressIpv6);
2693+
}
2694+
returnthis.#inner.localTransportParams=params;
2695+
}
2696+
2697+
getremoteTransportParams(){
2698+
if(this.#inner.remoteTransportParams!==undefined){
2699+
returnthis.#inner.remoteTransportParams;
2700+
}
2701+
// If the handle is already gone, we cannot retrieve the transport params.
2702+
if(this.destroyed)returnnull;
2703+
constparams=this.#handle.remoteTransportParams();
2704+
// If params is undefined, the transport parameters have not yet been received.
2705+
// Note the distinction between this and the case where the handle is gone.
2706+
// If the handle is gone, we return null because we know the transport
2707+
// parameters will be unavailable. If the transport parameters have not yet
2708+
// been received, we return undefined to indicate that they may still become
2709+
// available in the future.
2710+
if(params===undefined)returnundefined;
2711+
if(params.preferredAddressIpv4!==undefined){
2712+
params.preferredAddressIpv4=newInternalSocketAddress(params.preferredAddressIpv4);
2713+
}
2714+
if(params.preferredAddressIpv6!==undefined){
2715+
params.preferredAddressIpv6=newInternalSocketAddress(params.preferredAddressIpv6);
2716+
}
2717+
returnthis.#inner.remoteTransportParams=params;
2718+
}
2719+
26792720
/** @type {boolean} */
26802721
get #isClosedOrClosing(){
26812722
returnthis.#handle ===undefined||this.#inner.isPendingClose;

β€Žsrc/quic/bindingdata.ccβ€Ž

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
namespacenode {
2121

2222
using mem::kReserveSizeAndAlign;
23+
using v8::DictionaryTemplate;
2324
using v8::Function;
2425
using v8::FunctionTemplate;
2526
using v8::HandleScope;
@@ -377,6 +378,16 @@ QUIC_CONSTRUCTORS(V)
377378

378379
#undef V
379380

381+
voidBindingData::set_transport_params_template(
382+
Local<DictionaryTemplate> tmpl) {
383+
transport_params_template_.Reset(env()->isolate(), tmpl);
384+
}
385+
386+
Local<DictionaryTemplate> BindingData::transport_params_template() const {
387+
returnPersistentToLocal::Default(env()->isolate(),
388+
transport_params_template_);
389+
}
390+
380391
#defineV(name, _) \
381392
void BindingData::set_##name##_callback(Local<Function> fn) { \
382393
name##_callback_.Reset(env()->isolate(), fn); \

β€Žsrc/quic/bindingdata.hβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ class BindingData final
303303
QUIC_CONSTRUCTORS(V)
304304
#undef V
305305

306+
voidset_transport_params_template(v8::Local<v8::DictionaryTemplate> tmpl);
307+
v8::Local<v8::DictionaryTemplate> transport_params_template() const;
308+
306309
#defineV(name, _) \
307310
void set_##name##_callback(v8::Local<v8::Function> fn); \
308311
v8::Local<v8::Function> name##_callback() const;
@@ -321,6 +324,8 @@ class BindingData final
321324
QUIC_CONSTRUCTORS(V)
322325
#undef V
323326

327+
v8::Global<v8::DictionaryTemplate> transport_params_template_;
328+
324329
#defineV(name, _) v8::Global<v8::Function> name##_callback_;
325330
QUIC_JS_CALLBACKS(V)
326331
#undef V

β€Žsrc/quic/session.ccβ€Ž

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ uint64_t MaxDatagramPayload(uint64_t max_frame_size) {
190190
V(SilentClose, silentClose, SIDE_EFFECT) \
191191
V(UpdateKey, updateKey, SIDE_EFFECT) \
192192
V(OpenStream, openStream, SIDE_EFFECT) \
193-
V(SendDatagram, sendDatagram, SIDE_EFFECT)
193+
V(SendDatagram, sendDatagram, SIDE_EFFECT) \
194+
V(LocalTransportParams, localTransportParams, NO_SIDE_EFFECT) \
195+
V(RemoteTransportParams, remoteTransportParams, NO_SIDE_EFFECT) \
194196

195197
structSession::State final {
196198
#defineV(_, name, type) type name;
@@ -1163,6 +1165,36 @@ struct Session::Impl final : public MemoryRetainer {
11631165
BigInt::New(env->isolate(), session->SendDatagram(std::move(store))));
11641166
}
11651167

1168+
JS_METHOD(LocalTransportParams) {
1169+
auto env = Environment::GetCurrent(args);
1170+
Session* session;
1171+
ASSIGN_OR_RETURN_UNWRAP(&session, args.This());
1172+
1173+
ngtcp2_conn* conn = *session;
1174+
TransportParams params(ngtcp2_conn_get_local_transport_params(conn));
1175+
Local<Object> obj;
1176+
if (params.ToObject(env).ToLocal(&obj)) {
1177+
args.GetReturnValue().Set(obj);
1178+
}
1179+
}
1180+
1181+
JS_METHOD(RemoteTransportParams) {
1182+
auto env = Environment::GetCurrent(args);
1183+
Session* session;
1184+
ASSIGN_OR_RETURN_UNWRAP(&session, args.This());
1185+
1186+
ngtcp2_conn* conn = *session;
1187+
auto params = ngtcp2_conn_get_remote_transport_params(conn);
1188+
if (params == nullptr) {
1189+
// Remote transport parameters are not yet available.
1190+
return args.GetReturnValue().SetUndefined();
1191+
}
1192+
TransportParams tp(params);
1193+
Local<Object> obj;
1194+
if (tp.ToObject(env).ToLocal(&obj)) {
1195+
args.GetReturnValue().Set(obj);
1196+
}
1197+
}
11661198
// Internal ngtcp2 callbacks
11671199

11681200
staticinton_acknowledge_stream_data_offset(ngtcp2_conn* conn,

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 4c00ab9

Browse files
jasnelladuh95
authored andcommitted
quic: add getters for local and remote transport parameters
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #63267 Backport-PR-URL: #64675 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 858b636 commit 4c00ab9

8 files changed

Lines changed: 465 additions & 1 deletion

File tree

β€Ždoc/api/quic.mdβ€Ž

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,17 @@ added: v23.8.0
833833

834834
True if `session.destroy()` has been called. Read only.
835835

836+
### `session.localTransportParams`
837+
838+
<!-- YAML
839+
added: REPLACEME
840+
-->
841+
842+
* Type: {quic.TransportParams|null}
843+
844+
The transport parameters advertised by the local endpoint during the handshake.
845+
Returns `null` if the session has been destroyed. Read only.
846+
836847
### `session.endpoint`
837848

838849
<!-- YAML
@@ -1126,6 +1137,19 @@ added: v23.8.0
11261137

11271138
The local and remote socket addresses associated with the session. Read only.
11281139

1140+
### `session.remoteTransportParams`
1141+
1142+
<!-- YAML
1143+
added: REPLACEME
1144+
-->
1145+
1146+
* Type: {quic.TransportParams|null|undefined}
1147+
1148+
The transport parameters advertised by the remote peer during the handshake.
1149+
Returns `null` if the session has been destroyed, `undefined` if the handshake
1150+
has not yet completed and the remote parameters are not yet available. Read
1151+
only.
1152+
11291153
### `session.sendDatagram(datagram[, encoding])`
11301154

11311155
<!-- YAML
@@ -2927,6 +2951,37 @@ won't have need to specify.
29272951
added: v23.8.0
29282952
-->
29292953

2954+
The `TransportParams` type represents the QUIC transport parameters that are
2955+
negotiated during session establishment. These parameters are used when
2956+
creating a session. The negotiated values can be observed via the
2957+
`session.localTransportParams` and `session.remoteTransportParams` properties.
2958+
2959+
#### `transportParams.initialSCID`
2960+
2961+
<!-- YAML
2962+
added: REPLACEME
2963+
-->
2964+
2965+
* Type: {string}
2966+
2967+
The initial source connection ID (SCID) specified. This field is ignored on
2968+
creation of the session and is provided for informational purposes only when
2969+
available in the `session.localTransportParams` and
2970+
`session.remoteTransportParams` properties.
2971+
2972+
#### `transportParams.originalDCID`
2973+
2974+
<!-- YAML
2975+
added: REPLACEME
2976+
-->
2977+
2978+
* Type: {string}
2979+
2980+
The original destination connection ID (DCID) specified. This field is
2981+
ignored on creation of the session and is provided for informational
2982+
purposes only when available in the `session.localTransportParams` and
2983+
`session.remoteTransportParams` properties.
2984+
29302985
#### `transportParams.preferredAddressIpv4`
29312986

29322987
<!-- YAML
@@ -3040,6 +3095,19 @@ will not send datagrams larger than this value. The actual maximum size of
30403095
a datagram that can be _sent_ is determined by the peer's
30413096
`maxDatagramFrameSize`, not this endpoint's value.
30423097

3098+
#### `transportParams.retrySCID`
3099+
3100+
<!-- YAML
3101+
added: REPLACEME
3102+
-->
3103+
3104+
* Type: {string}
3105+
3106+
The retry connection ID specified. This field is ignored on creation
3107+
of the session and is provided for informational purposes only when
3108+
available in the `session.localTransportParams` and
3109+
`session.remoteTransportParams` properties.
3110+
30433111
## Callbacks
30443112

30453113
### Callback error handling

β€Žlib/internal/quic/quic.jsβ€Ž

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,6 +2626,8 @@ class QuicSession {
26262626
certificate: undefined,
26272627
peerCertificate: undefined,
26282628
ephemeralKeyInfo: undefined,
2629+
localTransportParams: undefined,
2630+
remoteTransportParams: undefined,
26292631
};
26302632

26312633
static{
@@ -2676,6 +2678,45 @@ class QuicSession {
26762678
debug('session created');
26772679
}
26782680

2681+
getlocalTransportParams(){
2682+
if(this.#inner.localTransportParams!==undefined){
2683+
returnthis.#inner.localTransportParams;
2684+
}
2685+
// If the handle is already gone, we cannot retrieve the transport params.
2686+
if(this.destroyed)returnnull;
2687+
constparams=this.#handle.localTransportParams();
2688+
if(params.preferredAddressIpv4!==undefined){
2689+
params.preferredAddressIpv4=newInternalSocketAddress(params.preferredAddressIpv4);
2690+
}
2691+
if(params.preferredAddressIpv6!==undefined){
2692+
params.preferredAddressIpv6=newInternalSocketAddress(params.preferredAddressIpv6);
2693+
}
2694+
returnthis.#inner.localTransportParams=params;
2695+
}
2696+
2697+
getremoteTransportParams(){
2698+
if(this.#inner.remoteTransportParams!==undefined){
2699+
returnthis.#inner.remoteTransportParams;
2700+
}
2701+
// If the handle is already gone, we cannot retrieve the transport params.
2702+
if(this.destroyed)returnnull;
2703+
constparams=this.#handle.remoteTransportParams();
2704+
// If params is undefined, the transport parameters have not yet been received.
2705+
// Note the distinction between this and the case where the handle is gone.
2706+
// If the handle is gone, we return null because we know the transport
2707+
// parameters will be unavailable. If the transport parameters have not yet
2708+
// been received, we return undefined to indicate that they may still become
2709+
// available in the future.
2710+
if(params===undefined)returnundefined;
2711+
if(params.preferredAddressIpv4!==undefined){
2712+
params.preferredAddressIpv4=newInternalSocketAddress(params.preferredAddressIpv4);
2713+
}
2714+
if(params.preferredAddressIpv6!==undefined){
2715+
params.preferredAddressIpv6=newInternalSocketAddress(params.preferredAddressIpv6);
2716+
}
2717+
returnthis.#inner.remoteTransportParams=params;
2718+
}
2719+
26792720
/** @type {boolean} */
26802721
get #isClosedOrClosing(){
26812722
returnthis.#handle ===undefined||this.#inner.isPendingClose;

β€Žsrc/quic/bindingdata.ccβ€Ž

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
namespacenode {
2121

2222
using mem::kReserveSizeAndAlign;
23+
using v8::DictionaryTemplate;
2324
using v8::Function;
2425
using v8::FunctionTemplate;
2526
using v8::HandleScope;
@@ -377,6 +378,16 @@ QUIC_CONSTRUCTORS(V)
377378

378379
#undef V
379380

381+
voidBindingData::set_transport_params_template(
382+
Local<DictionaryTemplate> tmpl) {
383+
transport_params_template_.Reset(env()->isolate(), tmpl);
384+
}
385+
386+
Local<DictionaryTemplate> BindingData::transport_params_template() const {
387+
returnPersistentToLocal::Default(env()->isolate(),
388+
transport_params_template_);
389+
}
390+
380391
#defineV(name, _) \
381392
void BindingData::set_##name##_callback(Local<Function> fn) { \
382393
name##_callback_.Reset(env()->isolate(), fn); \

β€Žsrc/quic/bindingdata.hβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ class BindingData final
303303
QUIC_CONSTRUCTORS(V)
304304
#undef V
305305

306+
voidset_transport_params_template(v8::Local<v8::DictionaryTemplate> tmpl);
307+
v8::Local<v8::DictionaryTemplate> transport_params_template() const;
308+
306309
#defineV(name, _) \
307310
void set_##name##_callback(v8::Local<v8::Function> fn); \
308311
v8::Local<v8::Function> name##_callback() const;
@@ -321,6 +324,8 @@ class BindingData final
321324
QUIC_CONSTRUCTORS(V)
322325
#undef V
323326

327+
v8::Global<v8::DictionaryTemplate> transport_params_template_;
328+
324329
#defineV(name, _) v8::Global<v8::Function> name##_callback_;
325330
QUIC_JS_CALLBACKS(V)
326331
#undef V

β€Žsrc/quic/session.ccβ€Ž

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ uint64_t MaxDatagramPayload(uint64_t max_frame_size) {
190190
V(SilentClose, silentClose, SIDE_EFFECT) \
191191
V(UpdateKey, updateKey, SIDE_EFFECT) \
192192
V(OpenStream, openStream, SIDE_EFFECT) \
193-
V(SendDatagram, sendDatagram, SIDE_EFFECT)
193+
V(SendDatagram, sendDatagram, SIDE_EFFECT) \
194+
V(LocalTransportParams, localTransportParams, NO_SIDE_EFFECT) \
195+
V(RemoteTransportParams, remoteTransportParams, NO_SIDE_EFFECT) \
194196

195197
structSession::State final {
196198
#defineV(_, name, type) type name;
@@ -1163,6 +1165,36 @@ struct Session::Impl final : public MemoryRetainer {
11631165
BigInt::New(env->isolate(), session->SendDatagram(std::move(store))));
11641166
}
11651167

1168+
JS_METHOD(LocalTransportParams) {
1169+
auto env = Environment::GetCurrent(args);
1170+
Session* session;
1171+
ASSIGN_OR_RETURN_UNWRAP(&session, args.This());
1172+
1173+
ngtcp2_conn* conn = *session;
1174+
TransportParams params(ngtcp2_conn_get_local_transport_params(conn));
1175+
Local<Object> obj;
1176+
if (params.ToObject(env).ToLocal(&obj)) {
1177+
args.GetReturnValue().Set(obj);
1178+
}
1179+
}
1180+
1181+
JS_METHOD(RemoteTransportParams) {
1182+
auto env = Environment::GetCurrent(args);
1183+
Session* session;
1184+
ASSIGN_OR_RETURN_UNWRAP(&session, args.This());
1185+
1186+
ngtcp2_conn* conn = *session;
1187+
auto params = ngtcp2_conn_get_remote_transport_params(conn);
1188+
if (params == nullptr) {
1189+
// Remote transport parameters are not yet available.
1190+
return args.GetReturnValue().SetUndefined();
1191+
}
1192+
TransportParams tp(params);
1193+
Local<Object> obj;
1194+
if (tp.ToObject(env).ToLocal(&obj)) {
1195+
args.GetReturnValue().Set(obj);
1196+
}
1197+
}
11661198
// Internal ngtcp2 callbacks
11671199

11681200
staticinton_acknowledge_stream_data_offset(ngtcp2_conn* conn,

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 4c00ab9

Browse files
jasnelladuh95
authored andcommitted
quic: add getters for local and remote transport parameters
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #63267 Backport-PR-URL: #64675 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 858b636 commit 4c00ab9

8 files changed

Lines changed: 465 additions & 1 deletion

File tree

β€Ždoc/api/quic.mdβ€Ž

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,17 @@ added: v23.8.0
833833

834834
True if `session.destroy()` has been called. Read only.
835835

836+
### `session.localTransportParams`
837+
838+
<!-- YAML
839+
added: REPLACEME
840+
-->
841+
842+
* Type: {quic.TransportParams|null}
843+
844+
The transport parameters advertised by the local endpoint during the handshake.
845+
Returns `null` if the session has been destroyed. Read only.
846+
836847
### `session.endpoint`
837848

838849
<!-- YAML
@@ -1126,6 +1137,19 @@ added: v23.8.0
11261137

11271138
The local and remote socket addresses associated with the session. Read only.
11281139

1140+
### `session.remoteTransportParams`
1141+
1142+
<!-- YAML
1143+
added: REPLACEME
1144+
-->
1145+
1146+
* Type: {quic.TransportParams|null|undefined}
1147+
1148+
The transport parameters advertised by the remote peer during the handshake.
1149+
Returns `null` if the session has been destroyed, `undefined` if the handshake
1150+
has not yet completed and the remote parameters are not yet available. Read
1151+
only.
1152+
11291153
### `session.sendDatagram(datagram[, encoding])`
11301154

11311155
<!-- YAML
@@ -2927,6 +2951,37 @@ won't have need to specify.
29272951
added: v23.8.0
29282952
-->
29292953

2954+
The `TransportParams` type represents the QUIC transport parameters that are
2955+
negotiated during session establishment. These parameters are used when
2956+
creating a session. The negotiated values can be observed via the
2957+
`session.localTransportParams` and `session.remoteTransportParams` properties.
2958+
2959+
#### `transportParams.initialSCID`
2960+
2961+
<!-- YAML
2962+
added: REPLACEME
2963+
-->
2964+
2965+
* Type: {string}
2966+
2967+
The initial source connection ID (SCID) specified. This field is ignored on
2968+
creation of the session and is provided for informational purposes only when
2969+
available in the `session.localTransportParams` and
2970+
`session.remoteTransportParams` properties.
2971+
2972+
#### `transportParams.originalDCID`
2973+
2974+
<!-- YAML
2975+
added: REPLACEME
2976+
-->
2977+
2978+
* Type: {string}
2979+
2980+
The original destination connection ID (DCID) specified. This field is
2981+
ignored on creation of the session and is provided for informational
2982+
purposes only when available in the `session.localTransportParams` and
2983+
`session.remoteTransportParams` properties.
2984+
29302985
#### `transportParams.preferredAddressIpv4`
29312986

29322987
<!-- YAML
@@ -3040,6 +3095,19 @@ will not send datagrams larger than this value. The actual maximum size of
30403095
a datagram that can be _sent_ is determined by the peer's
30413096
`maxDatagramFrameSize`, not this endpoint's value.
30423097

3098+
#### `transportParams.retrySCID`
3099+
3100+
<!-- YAML
3101+
added: REPLACEME
3102+
-->
3103+
3104+
* Type: {string}
3105+
3106+
The retry connection ID specified. This field is ignored on creation
3107+
of the session and is provided for informational purposes only when
3108+
available in the `session.localTransportParams` and
3109+
`session.remoteTransportParams` properties.
3110+
30433111
## Callbacks
30443112

30453113
### Callback error handling

β€Žlib/internal/quic/quic.jsβ€Ž

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,6 +2626,8 @@ class QuicSession {
26262626
certificate: undefined,
26272627
peerCertificate: undefined,
26282628
ephemeralKeyInfo: undefined,
2629+
localTransportParams: undefined,
2630+
remoteTransportParams: undefined,
26292631
};
26302632

26312633
static{
@@ -2676,6 +2678,45 @@ class QuicSession {
26762678
debug('session created');
26772679
}
26782680

2681+
getlocalTransportParams(){
2682+
if(this.#inner.localTransportParams!==undefined){
2683+
returnthis.#inner.localTransportParams;
2684+
}
2685+
// If the handle is already gone, we cannot retrieve the transport params.
2686+
if(this.destroyed)returnnull;
2687+
constparams=this.#handle.localTransportParams();
2688+
if(params.preferredAddressIpv4!==undefined){
2689+
params.preferredAddressIpv4=newInternalSocketAddress(params.preferredAddressIpv4);
2690+
}
2691+
if(params.preferredAddressIpv6!==undefined){
2692+
params.preferredAddressIpv6=newInternalSocketAddress(params.preferredAddressIpv6);
2693+
}
2694+
returnthis.#inner.localTransportParams=params;
2695+
}
2696+
2697+
getremoteTransportParams(){
2698+
if(this.#inner.remoteTransportParams!==undefined){
2699+
returnthis.#inner.remoteTransportParams;
2700+
}
2701+
// If the handle is already gone, we cannot retrieve the transport params.
2702+
if(this.destroyed)returnnull;
2703+
constparams=this.#handle.remoteTransportParams();
2704+
// If params is undefined, the transport parameters have not yet been received.
2705+
// Note the distinction between this and the case where the handle is gone.
2706+
// If the handle is gone, we return null because we know the transport
2707+
// parameters will be unavailable. If the transport parameters have not yet
2708+
// been received, we return undefined to indicate that they may still become
2709+
// available in the future.
2710+
if(params===undefined)returnundefined;
2711+
if(params.preferredAddressIpv4!==undefined){
2712+
params.preferredAddressIpv4=newInternalSocketAddress(params.preferredAddressIpv4);
2713+
}
2714+
if(params.preferredAddressIpv6!==undefined){
2715+
params.preferredAddressIpv6=newInternalSocketAddress(params.preferredAddressIpv6);
2716+
}
2717+
returnthis.#inner.remoteTransportParams=params;
2718+
}
2719+
26792720
/** @type {boolean} */
26802721
get #isClosedOrClosing(){
26812722
returnthis.#handle ===undefined||this.#inner.isPendingClose;

β€Žsrc/quic/bindingdata.ccβ€Ž

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
namespacenode {
2121

2222
using mem::kReserveSizeAndAlign;
23+
using v8::DictionaryTemplate;
2324
using v8::Function;
2425
using v8::FunctionTemplate;
2526
using v8::HandleScope;
@@ -377,6 +378,16 @@ QUIC_CONSTRUCTORS(V)
377378

378379
#undef V
379380

381+
voidBindingData::set_transport_params_template(
382+
Local<DictionaryTemplate> tmpl) {
383+
transport_params_template_.Reset(env()->isolate(), tmpl);
384+
}
385+
386+
Local<DictionaryTemplate> BindingData::transport_params_template() const {
387+
returnPersistentToLocal::Default(env()->isolate(),
388+
transport_params_template_);
389+
}
390+
380391
#defineV(name, _) \
381392
void BindingData::set_##name##_callback(Local<Function> fn) { \
382393
name##_callback_.Reset(env()->isolate(), fn); \

β€Žsrc/quic/bindingdata.hβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ class BindingData final
303303
QUIC_CONSTRUCTORS(V)
304304
#undef V
305305

306+
voidset_transport_params_template(v8::Local<v8::DictionaryTemplate> tmpl);
307+
v8::Local<v8::DictionaryTemplate> transport_params_template() const;
308+
306309
#defineV(name, _) \
307310
void set_##name##_callback(v8::Local<v8::Function> fn); \
308311
v8::Local<v8::Function> name##_callback() const;
@@ -321,6 +324,8 @@ class BindingData final
321324
QUIC_CONSTRUCTORS(V)
322325
#undef V
323326

327+
v8::Global<v8::DictionaryTemplate> transport_params_template_;
328+
324329
#defineV(name, _) v8::Global<v8::Function> name##_callback_;
325330
QUIC_JS_CALLBACKS(V)
326331
#undef V

β€Žsrc/quic/session.ccβ€Ž

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ uint64_t MaxDatagramPayload(uint64_t max_frame_size) {
190190
V(SilentClose, silentClose, SIDE_EFFECT) \
191191
V(UpdateKey, updateKey, SIDE_EFFECT) \
192192
V(OpenStream, openStream, SIDE_EFFECT) \
193-
V(SendDatagram, sendDatagram, SIDE_EFFECT)
193+
V(SendDatagram, sendDatagram, SIDE_EFFECT) \
194+
V(LocalTransportParams, localTransportParams, NO_SIDE_EFFECT) \
195+
V(RemoteTransportParams, remoteTransportParams, NO_SIDE_EFFECT) \
194196

195197
structSession::State final {
196198
#defineV(_, name, type) type name;
@@ -1163,6 +1165,36 @@ struct Session::Impl final : public MemoryRetainer {
11631165
BigInt::New(env->isolate(), session->SendDatagram(std::move(store))));
11641166
}
11651167

1168+
JS_METHOD(LocalTransportParams) {
1169+
auto env = Environment::GetCurrent(args);
1170+
Session* session;
1171+
ASSIGN_OR_RETURN_UNWRAP(&session, args.This());
1172+
1173+
ngtcp2_conn* conn = *session;
1174+
TransportParams params(ngtcp2_conn_get_local_transport_params(conn));
1175+
Local<Object> obj;
1176+
if (params.ToObject(env).ToLocal(&obj)) {
1177+
args.GetReturnValue().Set(obj);
1178+
}
1179+
}
1180+
1181+
JS_METHOD(RemoteTransportParams) {
1182+
auto env = Environment::GetCurrent(args);
1183+
Session* session;
1184+
ASSIGN_OR_RETURN_UNWRAP(&session, args.This());
1185+
1186+
ngtcp2_conn* conn = *session;
1187+
auto params = ngtcp2_conn_get_remote_transport_params(conn);
1188+
if (params == nullptr) {
1189+
// Remote transport parameters are not yet available.
1190+
return args.GetReturnValue().SetUndefined();
1191+
}
1192+
TransportParams tp(params);
1193+
Local<Object> obj;
1194+
if (tp.ToObject(env).ToLocal(&obj)) {
1195+
args.GetReturnValue().Set(obj);
1196+
}
1197+
}
11661198
// Internal ngtcp2 callbacks
11671199

11681200
staticinton_acknowledge_stream_data_offset(ngtcp2_conn* conn,

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Commit 4c00ab9

Browse files
jasnelladuh95
authored andcommitted
quic: add getters for local and remote transport parameters
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #63267 Backport-PR-URL: #64675 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 858b636 commit 4c00ab9

8 files changed

Lines changed: 465 additions & 1 deletion

File tree

β€Ždoc/api/quic.mdβ€Ž

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,17 @@ added: v23.8.0
833833

834834
True if `session.destroy()` has been called. Read only.
835835

836+
### `session.localTransportParams`
837+
838+
<!-- YAML
839+
added: REPLACEME
840+
-->
841+
842+
* Type: {quic.TransportParams|null}
843+
844+
The transport parameters advertised by the local endpoint during the handshake.
845+
Returns `null` if the session has been destroyed. Read only.
846+
836847
### `session.endpoint`
837848

838849
<!-- YAML
@@ -1126,6 +1137,19 @@ added: v23.8.0
11261137

11271138
The local and remote socket addresses associated with the session. Read only.
11281139

1140+
### `session.remoteTransportParams`
1141+
1142+
<!-- YAML
1143+
added: REPLACEME
1144+
-->
1145+
1146+
* Type: {quic.TransportParams|null|undefined}
1147+
1148+
The transport parameters advertised by the remote peer during the handshake.
1149+
Returns `null` if the session has been destroyed, `undefined` if the handshake
1150+
has not yet completed and the remote parameters are not yet available. Read
1151+
only.
1152+
11291153
### `session.sendDatagram(datagram[, encoding])`
11301154

11311155
<!-- YAML
@@ -2927,6 +2951,37 @@ won't have need to specify.
29272951
added: v23.8.0
29282952
-->
29292953

2954+
The `TransportParams` type represents the QUIC transport parameters that are
2955+
negotiated during session establishment. These parameters are used when
2956+
creating a session. The negotiated values can be observed via the
2957+
`session.localTransportParams` and `session.remoteTransportParams` properties.
2958+
2959+
#### `transportParams.initialSCID`
2960+
2961+
<!-- YAML
2962+
added: REPLACEME
2963+
-->
2964+
2965+
* Type: {string}
2966+
2967+
The initial source connection ID (SCID) specified. This field is ignored on
2968+
creation of the session and is provided for informational purposes only when
2969+
available in the `session.localTransportParams` and
2970+
`session.remoteTransportParams` properties.
2971+
2972+
#### `transportParams.originalDCID`
2973+
2974+
<!-- YAML
2975+
added: REPLACEME
2976+
-->
2977+
2978+
* Type: {string}
2979+
2980+
The original destination connection ID (DCID) specified. This field is
2981+
ignored on creation of the session and is provided for informational
2982+
purposes only when available in the `session.localTransportParams` and
2983+
`session.remoteTransportParams` properties.
2984+
29302985
#### `transportParams.preferredAddressIpv4`
29312986

29322987
<!-- YAML
@@ -3040,6 +3095,19 @@ will not send datagrams larger than this value. The actual maximum size of
30403095
a datagram that can be _sent_ is determined by the peer's
30413096
`maxDatagramFrameSize`, not this endpoint's value.
30423097

3098+
#### `transportParams.retrySCID`
3099+
3100+
<!-- YAML
3101+
added: REPLACEME
3102+
-->
3103+
3104+
* Type: {string}
3105+
3106+
The retry connection ID specified. This field is ignored on creation
3107+
of the session and is provided for informational purposes only when
3108+
available in the `session.localTransportParams` and
3109+
`session.remoteTransportParams` properties.
3110+
30433111
## Callbacks
30443112

30453113
### Callback error handling

β€Žlib/internal/quic/quic.jsβ€Ž

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,6 +2626,8 @@ class QuicSession {
26262626
certificate: undefined,
26272627
peerCertificate: undefined,
26282628
ephemeralKeyInfo: undefined,
2629+
localTransportParams: undefined,
2630+
remoteTransportParams: undefined,
26292631
};
26302632

26312633
static{
@@ -2676,6 +2678,45 @@ class QuicSession {
26762678
debug('session created');
26772679
}
26782680

2681+
getlocalTransportParams(){
2682+
if(this.#inner.localTransportParams!==undefined){
2683+
returnthis.#inner.localTransportParams;
2684+
}
2685+
// If the handle is already gone, we cannot retrieve the transport params.
2686+
if(this.destroyed)returnnull;
2687+
constparams=this.#handle.localTransportParams();
2688+
if(params.preferredAddressIpv4!==undefined){
2689+
params.preferredAddressIpv4=newInternalSocketAddress(params.preferredAddressIpv4);
2690+
}
2691+
if(params.preferredAddressIpv6!==undefined){
2692+
params.preferredAddressIpv6=newInternalSocketAddress(params.preferredAddressIpv6);
2693+
}
2694+
returnthis.#inner.localTransportParams=params;
2695+
}
2696+
2697+
getremoteTransportParams(){
2698+
if(this.#inner.remoteTransportParams!==undefined){
2699+
returnthis.#inner.remoteTransportParams;
2700+
}
2701+
// If the handle is already gone, we cannot retrieve the transport params.
2702+
if(this.destroyed)returnnull;
2703+
constparams=this.#handle.remoteTransportParams();
2704+
// If params is undefined, the transport parameters have not yet been received.
2705+
// Note the distinction between this and the case where the handle is gone.
2706+
// If the handle is gone, we return null because we know the transport
2707+
// parameters will be unavailable. If the transport parameters have not yet
2708+
// been received, we return undefined to indicate that they may still become
2709+
// available in the future.
2710+
if(params===undefined)returnundefined;
2711+
if(params.preferredAddressIpv4!==undefined){
2712+
params.preferredAddressIpv4=newInternalSocketAddress(params.preferredAddressIpv4);
2713+
}
2714+
if(params.preferredAddressIpv6!==undefined){
2715+
params.preferredAddressIpv6=newInternalSocketAddress(params.preferredAddressIpv6);
2716+
}
2717+
returnthis.#inner.remoteTransportParams=params;
2718+
}
2719+
26792720
/** @type {boolean} */
26802721
get #isClosedOrClosing(){
26812722
returnthis.#handle ===undefined||this.#inner.isPendingClose;

β€Žsrc/quic/bindingdata.ccβ€Ž

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
namespacenode {
2121

2222
using mem::kReserveSizeAndAlign;
23+
using v8::DictionaryTemplate;
2324
using v8::Function;
2425
using v8::FunctionTemplate;
2526
using v8::HandleScope;
@@ -377,6 +378,16 @@ QUIC_CONSTRUCTORS(V)
377378

378379
#undef V
379380

381+
voidBindingData::set_transport_params_template(
382+
Local<DictionaryTemplate> tmpl) {
383+
transport_params_template_.Reset(env()->isolate(), tmpl);
384+
}
385+
386+
Local<DictionaryTemplate> BindingData::transport_params_template() const {
387+
returnPersistentToLocal::Default(env()->isolate(),
388+
transport_params_template_);
389+
}
390+
380391
#defineV(name, _) \
381392
void BindingData::set_##name##_callback(Local<Function> fn) { \
382393
name##_callback_.Reset(env()->isolate(), fn); \

β€Žsrc/quic/bindingdata.hβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ class BindingData final
303303
QUIC_CONSTRUCTORS(V)
304304
#undef V
305305

306+
voidset_transport_params_template(v8::Local<v8::DictionaryTemplate> tmpl);
307+
v8::Local<v8::DictionaryTemplate> transport_params_template() const;
308+
306309
#defineV(name, _) \
307310
void set_##name##_callback(v8::Local<v8::Function> fn); \
308311
v8::Local<v8::Function> name##_callback() const;
@@ -321,6 +324,8 @@ class BindingData final
321324
QUIC_CONSTRUCTORS(V)
322325
#undef V
323326

327+
v8::Global<v8::DictionaryTemplate> transport_params_template_;
328+
324329
#defineV(name, _) v8::Global<v8::Function> name##_callback_;
325330
QUIC_JS_CALLBACKS(V)
326331
#undef V

β€Žsrc/quic/session.ccβ€Ž

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ uint64_t MaxDatagramPayload(uint64_t max_frame_size) {
190190
V(SilentClose, silentClose, SIDE_EFFECT) \
191191
V(UpdateKey, updateKey, SIDE_EFFECT) \
192192
V(OpenStream, openStream, SIDE_EFFECT) \
193-
V(SendDatagram, sendDatagram, SIDE_EFFECT)
193+
V(SendDatagram, sendDatagram, SIDE_EFFECT) \
194+
V(LocalTransportParams, localTransportParams, NO_SIDE_EFFECT) \
195+
V(RemoteTransportParams, remoteTransportParams, NO_SIDE_EFFECT) \
194196

195197
structSession::State final {
196198
#defineV(_, name, type) type name;
@@ -1163,6 +1165,36 @@ struct Session::Impl final : public MemoryRetainer {
11631165
BigInt::New(env->isolate(), session->SendDatagram(std::move(store))));
11641166
}
11651167

1168+
JS_METHOD(LocalTransportParams) {
1169+
auto env = Environment::GetCurrent(args);
1170+
Session* session;
1171+
ASSIGN_OR_RETURN_UNWRAP(&session, args.This());
1172+
1173+
ngtcp2_conn* conn = *session;
1174+
TransportParams params(ngtcp2_conn_get_local_transport_params(conn));
1175+
Local<Object> obj;
1176+
if (params.ToObject(env).ToLocal(&obj)) {
1177+
args.GetReturnValue().Set(obj);
1178+
}
1179+
}
1180+
1181+
JS_METHOD(RemoteTransportParams) {
1182+
auto env = Environment::GetCurrent(args);
1183+
Session* session;
1184+
ASSIGN_OR_RETURN_UNWRAP(&session, args.This());
1185+
1186+
ngtcp2_conn* conn = *session;
1187+
auto params = ngtcp2_conn_get_remote_transport_params(conn);
1188+
if (params == nullptr) {
1189+
// Remote transport parameters are not yet available.
1190+
return args.GetReturnValue().SetUndefined();
1191+
}
1192+
TransportParams tp(params);
1193+
Local<Object> obj;
1194+
if (tp.ToObject(env).ToLocal(&obj)) {
1195+
args.GetReturnValue().Set(obj);
1196+
}
1197+
}
11661198
// Internal ngtcp2 callbacks
11671199

11681200
staticinton_acknowledge_stream_data_offset(ngtcp2_conn* conn,

0 commit comments

Comments
Β (0)