| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -833,6 +833,17 @@ added: v23.8.0 | |||
| 833 | 833 | ||
| 834 | 834 | True if `session.destroy()` has been called. Read only. | |
| 835 | 835 | ||
| 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 | + | ||
| 836 | 847 | ### `session.endpoint` | |
| 837 | 848 | ||
| 838 | 849 | <!-- YAML | |
@@ -1126,6 +1137,19 @@ added: v23.8.0 | |||
| 1126 | 1137 | ||
| 1127 | 1138 | The local and remote socket addresses associated with the session. Read only. | |
| 1128 | 1139 | ||
| 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 | + | ||
| 1129 | 1153 | ### `session.sendDatagram(datagram[, encoding])` | |
| 1130 | 1154 | ||
| 1131 | 1155 | <!-- YAML | |
@@ -2927,6 +2951,37 @@ won't have need to specify. | |||
| 2927 | 2951 | added: v23.8.0 | |
| 2928 | 2952 | --> | |
| 2929 | 2953 | ||
| 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 | + | ||
| 2930 | 2985 | #### `transportParams.preferredAddressIpv4` | |
| 2931 | 2986 | ||
| 2932 | 2987 | <!-- YAML | |
@@ -3040,6 +3095,19 @@ will not send datagrams larger than this value. The actual maximum size of | |||
| 3040 | 3095 | a datagram that can be _sent_ is determined by the peer's | |
| 3041 | 3096 | `maxDatagramFrameSize`, not this endpoint's value. | |
| 3042 | 3097 | ||
| 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 | + | ||
| 3043 | 3111 | ## Callbacks | |
| 3044 | 3112 | ||
| 3045 | 3113 | ### Callback error handling | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2626,6 +2626,8 @@ class QuicSession { | |||
| 2626 | 2626 | certificate: undefined, | |
| 2627 | 2627 | peerCertificate: undefined, | |
| 2628 | 2628 | ephemeralKeyInfo: undefined, | |
| 2629 | + localTransportParams: undefined, | ||
| 2630 | + remoteTransportParams: undefined, | ||
| 2629 | 2631 | }; | |
| 2630 | 2632 | ||
| 2631 | 2633 | static { | |
@@ -2676,6 +2678,45 @@ class QuicSession { | |||
| 2676 | 2678 | debug('session created'); | |
| 2677 | 2679 | } | |
| 2678 | 2680 | ||
| 2681 | + get localTransportParams() { | ||
| 2682 | + if (this.#inner.localTransportParams !== undefined) { | ||
| 2683 | + return this.#inner.localTransportParams; | ||
| 2684 | + } | ||
| 2685 | + // If the handle is already gone, we cannot retrieve the transport params. | ||
| 2686 | + if (this.destroyed) return null; | ||
| 2687 | + const params = this.#handle.localTransportParams(); | ||
| 2688 | + if (params.preferredAddressIpv4 !== undefined) { | ||
| 2689 | + params.preferredAddressIpv4 = new InternalSocketAddress(params.preferredAddressIpv4); | ||
| 2690 | + } | ||
| 2691 | + if (params.preferredAddressIpv6 !== undefined) { | ||
| 2692 | + params.preferredAddressIpv6 = new InternalSocketAddress(params.preferredAddressIpv6); | ||
| 2693 | + } | ||
| 2694 | + return this.#inner.localTransportParams = params; | ||
| 2695 | + } | ||
| 2696 | + | ||
| 2697 | + get remoteTransportParams() { | ||
| 2698 | + if (this.#inner.remoteTransportParams !== undefined) { | ||
| 2699 | + return this.#inner.remoteTransportParams; | ||
| 2700 | + } | ||
| 2701 | + // If the handle is already gone, we cannot retrieve the transport params. | ||
| 2702 | + if (this.destroyed) return null; | ||
| 2703 | + const params = 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) return undefined; | ||
| 2711 | + if (params.preferredAddressIpv4 !== undefined) { | ||
| 2712 | + params.preferredAddressIpv4 = new InternalSocketAddress(params.preferredAddressIpv4); | ||
| 2713 | + } | ||
| 2714 | + if (params.preferredAddressIpv6 !== undefined) { | ||
| 2715 | + params.preferredAddressIpv6 = new InternalSocketAddress(params.preferredAddressIpv6); | ||
| 2716 | + } | ||
| 2717 | + return this.#inner.remoteTransportParams = params; | ||
| 2718 | + } | ||
| 2719 | + | ||
| 2679 | 2720 | /** @type {boolean} */ | |
| 2680 | 2721 | get #isClosedOrClosing() { | |
| 2681 | 2722 | return this.#handle === undefined || this.#inner.isPendingClose; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,6 +20,7 @@ | |||
| 20 | 20 | namespace node { | |
| 21 | 21 | ||
| 22 | 22 | using mem::kReserveSizeAndAlign; | |
| 23 | + using v8::DictionaryTemplate; | ||
| 23 | 24 | using v8::Function; | |
| 24 | 25 | using v8::FunctionTemplate; | |
| 25 | 26 | using v8::HandleScope; | |
@@ -377,6 +378,16 @@ QUIC_CONSTRUCTORS(V) | |||
| 377 | 378 | ||
| 378 | 379 | #undef V | |
| 379 | 380 | ||
| 381 | + void BindingData::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 | + return PersistentToLocal::Default(env()->isolate(), | ||
| 388 | + transport_params_template_); | ||
| 389 | + } | ||
| 390 | + | ||
| 380 | 391 | #define V(name, _) \ | |
| 381 | 392 | void BindingData::set_##name##_callback(Local<Function> fn) { \ | |
| 382 | 393 | name##_callback_.Reset(env()->isolate(), fn); \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -303,6 +303,9 @@ class BindingData final | |||
| 303 | 303 | QUIC_CONSTRUCTORS(V) | |
| 304 | 304 | #undef V | |
| 305 | 305 | ||
| 306 | + void set_transport_params_template(v8::Local<v8::DictionaryTemplate> tmpl); | ||
| 307 | + v8::Local<v8::DictionaryTemplate> transport_params_template() const; | ||
| 308 | + | ||
| 306 | 309 | #define V(name, _) \ | |
| 307 | 310 | void set_##name##_callback(v8::Local<v8::Function> fn); \ | |
| 308 | 311 | v8::Local<v8::Function> name##_callback() const; | |
@@ -321,6 +324,8 @@ class BindingData final | |||
| 321 | 324 | QUIC_CONSTRUCTORS(V) | |
| 322 | 325 | #undef V | |
| 323 | 326 | ||
| 327 | + v8::Global<v8::DictionaryTemplate> transport_params_template_; | ||
| 328 | + | ||
| 324 | 329 | #define V(name, _) v8::Global<v8::Function> name##_callback_; | |
| 325 | 330 | QUIC_JS_CALLBACKS(V) | |
| 326 | 331 | #undef V | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -190,7 +190,9 @@ uint64_t MaxDatagramPayload(uint64_t max_frame_size) { | |||
| 190 | 190 | V(SilentClose, silentClose, SIDE_EFFECT) \ | |
| 191 | 191 | V(UpdateKey, updateKey, SIDE_EFFECT) \ | |
| 192 | 192 | 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) \ | ||
| 194 | 196 | ||
| 195 | 197 | struct Session::State final { | |
| 196 | 198 | #define V(_, name, type) type name; | |
@@ -1163,6 +1165,36 @@ struct Session::Impl final : public MemoryRetainer { | |||
| 1163 | 1165 | BigInt::New(env->isolate(), session->SendDatagram(std::move(store)))); | |
| 1164 | 1166 | } | |
| 1165 | 1167 | ||
| 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 | + } | ||
| 1166 | 1198 | // Internal ngtcp2 callbacks | |
| 1167 | 1199 | ||
| 1168 | 1200 | static int on_acknowledge_stream_data_offset(ngtcp2_conn* conn, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments