Commit Graph

81 Commits

Author SHA1 Message Date
James M Snell aafdc2fcad quic: replace ipv6Only option with `'udp6-only'` type
Since the `ipv6Only` option was mutually exclusive with
using `'udp6'`, making it it's own type simplifies things
a bit.

PR-URL: https://github.com/nodejs/node/pull/34283
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-15 17:16:30 -07:00
James M Snell c176d5fac2 quic: set destroyed at timestamps for duration calculation
PR-URL: https://github.com/nodejs/node/pull/34262
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-10 13:51:18 -07:00
James M Snell 48a349efd9 quic: use Number instead of BigInt for more stats
PR-URL: https://github.com/nodejs/node/pull/34262
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-10 13:51:16 -07:00
James M Snell 5e769b2eaf quic: use less specific error codes
Stop the madness. Only you can prevent excessive error code
proliferation.

PR-URL: https://github.com/nodejs/node/pull/34262
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-10 13:51:13 -07:00
James M Snell 458d243f20 quic: proper custom inspect for QuicStream
PR-URL: https://github.com/nodejs/node/pull/34247
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-09 07:15:44 -07:00
James M Snell 0860b11655 quic: proper custom inspect for QuicSession
PR-URL: https://github.com/nodejs/node/pull/34247
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-09 07:15:44 -07:00
James M Snell b047930d76 quic: proper custom inspect for QuicSocket
PR-URL: https://github.com/nodejs/node/pull/34247
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-09 07:15:44 -07:00
James M Snell 511f8c1138 quic: proper custom inspect for QuicEndpoint
PR-URL: https://github.com/nodejs/node/pull/34247
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-09 07:15:43 -07:00
James M Snell fe11f6bf7c quic: cleanup QuicSocketFlags, used shared state struct
Some of the flags were no longer being used.

Switched to use an AliasedStruct for shared state to avoid
extraneous expensive JS=>C++ calls.

Removed unused QuicSocket option

PR-URL: https://github.com/nodejs/node/pull/34247
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-09 07:15:43 -07:00
James M Snell d08e99de24 quic: use getter/setter for stateless reset toggle
PR-URL: https://github.com/nodejs/node/pull/34247
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-09 07:15:43 -07:00
James M Snell 71236097d0 quic: use Number() instead of bigint for QuicSocket stats
PR-URL: https://github.com/nodejs/node/pull/34247
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-09 07:14:17 -07:00
James M Snell 94372b124a quic: refactor/improve/document QuicSocket listening event
PR-URL: https://github.com/nodejs/node/pull/34247
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-09 07:14:14 -07:00
James M Snell afc9390ae5 quic: refactor/improve QuicSocket ready event handling
PR-URL: https://github.com/nodejs/node/pull/34247
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-09 07:14:12 -07:00
James M Snell cc89aac5f7 quic: refactor/improve error handling for busy event
Also, change setServerBusy into a setter

PR-URL: https://github.com/nodejs/node/pull/34247
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-09 07:14:07 -07:00
James M Snell edc71ef008 quic: handle errors thrown / rejections in the session event
Errors thrown within the session event handler will be handled
by destroying the session (allowing a proper connection close
to be sent to the client peer). They will not crash the parent
QuicSocket by default. Instead, a `'sessionError'` event will
be emitted, allowing the error to be logged or handled.

PR-URL: https://github.com/nodejs/node/pull/34247
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-09 07:14:05 -07:00
James M Snell bcde849be9 quic: remove unnecessary bool conversion
The argument will always be a boolean already

PR-URL: https://github.com/nodejs/node/pull/34247
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-09 07:14:02 -07:00
James M Snell 3837d9cf1f quic: fixup lint issues
PR-URL: https://github.com/nodejs/node/pull/34160
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-05 14:17:36 -07:00
James M Snell 7b062ca015 quic: refactor qlog handling
Because of the timing of qlog events emitted by ngtcp2, it
becomes difficult to handle those as events on the QuicSession
object because the final qlog entry is not emitted until the
ngtcp2_conn is freed, which can occur when the object is being
garbage collected (meaning, we a: can't call out to javascript
and b: don't have an object we can use to emit the event).

This refactors it into a QLogStream object that allows the
qlog data to be piped out using a separate Readable stream.

PR-URL: https://github.com/nodejs/node/pull/34160
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-05 14:17:33 -07:00
James M Snell e4d369e96e quic: remove onSessionDestroy callback
The QuicSession can be destroyed during garbage collection and
the onSessionDestroy callback was happening in the destructor.

PR-URL: https://github.com/nodejs/node/pull/34160
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-05 14:17:29 -07:00
James M Snell 3acdd6aac7 quic: refactor QuicSession shared state to use AliasedStruct
PR-URL: https://github.com/nodejs/node/pull/34160
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-05 14:17:26 -07:00
James M Snell f9c2245fb5 quic: refactor QuicSession close/destroy flow
PR-URL: https://github.com/nodejs/node/pull/34160
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-05 14:17:24 -07:00
James M Snell b5bf5bb20f quic: refactor native object flags for better readability
Use is_* and set_* pattern for native object flags to improve
readability in the code.

PR-URL: https://github.com/nodejs/node/pull/34160
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-05 14:17:18 -07:00
James M Snell 31d6d9d0f7 quic: reduce duplication of code
PR-URL: https://github.com/nodejs/node/pull/34137
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
2020-06-30 17:50:59 -07:00
James M Snell b5fe31ef19 quic: avoid using private JS fields for now
They introduce a significant performance bottleneck at the moment.

PR-URL: https://github.com/nodejs/node/pull/34137
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
2020-06-30 17:50:57 -07:00
James M Snell b1fab88ff0 quic: remove unused callback function
PR-URL: https://github.com/nodejs/node/pull/34137
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
2020-06-30 17:50:52 -07:00
James M Snell 3bae2d5073 quic: consolidate onSessionClose and onSessionSilentClose
Use a single callback function for both

PR-URL: https://github.com/nodejs/node/pull/34137
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
2020-06-30 17:50:50 -07:00
James M Snell 73a51bb9dc quic: cleanups in JS API
PR-URL: https://github.com/nodejs/node/pull/34137
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
2020-06-30 17:50:42 -07:00
James M Snell 86e67aaa69
quic: updates to implement for h3-29
PR-URL: https://github.com/nodejs/node/pull/34033
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2020-06-24 12:33:11 -07:00
James M Snell c7d859e756
quic: refactor and improve ipv6Only
Ignore `ipv6Only: true` when binding to `'udp4'` (this differs from
dgram which will still attempt to apply the flag and will fail during
bind). Improve the test so that it should work consistently.

Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/33935
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-06-22 10:58:20 -07:00
Robert Nagy 16116f5f5f
quic: remove noop code
this.unidirectional depends on #id which is never set
in the constructor, hence this condition will never run
and can be removed.

PR-URL: https://github.com/nodejs/node/pull/33914
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2020-06-18 14:44:29 -07:00
James M Snell 55360443ce
quic: initial QUIC implementation
Co-authored-by: Anna Henningsen <anna@addaleax.net>
Co-authored-by: Daniel Bevenius <daniel.bevenius@gmail.com>
Co-authored-by: gengjiawen <technicalcute@gmail.com>
Co-authored-by: James M Snell <jasnell@gmail.com>
Co-authored-by: Lucas Pardue <lucaspardue.24.7@gmail.com>
Co-authored-by: Ouyang Yadong <oyydoibh@gmail.com>
Co-authored-by: Juan Jos<C3><A9> Arboleda <soyjuanarbol@gmail.com>
Co-authored-by: Trivikram Kamat <trivikr.dev@gmail.com>
Co-authored-by: Denys Otrishko <shishugi@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/32379
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-06-16 09:23:34 -07:00