Skip to content

Commit 464bef2

Browse files
committed
quic: add quic
Signed-off-by: James M Snell <jasnell@gmail.com>
1 parent 6abf25e commit 464bef2

27 files changed

Lines changed: 14932 additions & 1 deletion

doc/api/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
* [Process](process.md)
4848
* [Punycode](punycode.md)
4949
* [Query strings](querystring.md)
50+
* [QUIC](quic.md)
5051
* [Readline](readline.md)
5152
* [REPL](repl.md)
5253
* [Report](report.md)

doc/api/quic.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# QUIC
2+
3+
## Overview
4+
5+
## API
6+
7+
### Class: `net.quic.EndpointConfig`
8+
9+
#### `new net.quic.EndpointConfig(options)`
10+
11+
* `options` {Object}
12+
* `address` {Object|net.SocketAddress} Identifies the local IPv4 or IPv6
13+
address to bind to.
14+
* `address` {string} The network address as either an IPv4 or IPv6 string.
15+
**Default**: `'127.0.0.1'` if `family` is `'ipv4'`; `'::'` if `family` is
16+
`'ipv6'`.
17+
* `family` {string} One of either `'ipv4'` or 'ipv6'`.
18+
**Default**: `'ipv4'`.
19+
* `flowlabel` {number} An IPv6 flow-label used only if `family` is `'ipv6'`.
20+
* `port` {number} An IP port.
21+
* `retryTokenExpiration` {number|bigint}
22+
* `tokenExpiration` {number|bigint}
23+
* `maxWindowOverride` {number|bigint}
24+
* `maxStreamWindowOverride` {number|bigint}
25+
* `maxConnectionsPerHost` {number|bigint}
26+
* `maxConnectionsTotal` {number|bigint}
27+
* `maxStatelessResets` {number|bigint}
28+
* `addressLRUSize` {number|bigint}
29+
* `retryLimit` {number|bigint}
30+
* `maxPayloadSize` {number|bigint}
31+
* `unacknowledgedPacketThreshold` {number|bigint}
32+
* `qlog` {boolean}
33+
* `validateAddress` {boolean}
34+
* `disableStatelessReset` {boolean}
35+
* `rxPacketLoss` {number}
36+
* `txPacketLoss` {number}
37+
* `ccAlgorithm` {string} One of either `'cubic'` or `'reno'`.
38+
* `udp` {Object}
39+
* `ipv6Only` {boolean}
40+
* `receiveBufferSize` {number}
41+
* `sendBufferSize` {number}
42+
* `ttl` {number}
43+
* `resetTokenSecret` {ArrayBuffer|TypedArray|DataView|Buffer}
44+
45+
### Class: `net.quic.SessionConfig`
46+
47+
#### `new net.quic.SessionConfig(side, options)`
48+
49+
* `side` {String} One of `'client'` or `'server'`
50+
* `options` {Object}
51+
* `alpn` {string}
52+
* `dcid` {string|ArrayBuffer|TypedArray|DataView|Buffer}
53+
* `hostname` {string}
54+
* `preferredAddressStrategy` {string} One of `'use'` or `'ignore'`
55+
* `secure` {Object}
56+
* `ca` {string|string[]|Buffer|Buffer[]}
57+
* `cert` {string|string[]|Buffer|Buffer[]}
58+
* `sigalgs` {string}
59+
* `ciphers` {string}
60+
* `clientCertEngine` {string}
61+
* `crl` {string|string[]|Buffer|Buffer[]}
62+
* `dhparam` {string|Buffer}
63+
* `ecdhCurve` {string}
64+
* `key` {string|string[]|Buffer|Buffer[]|Object[]}
65+
* `privateKey` {Object}
66+
* `engine` {string}
67+
* `identifier` {string}
68+
* `passphrase` {string}
69+
* `pfx` {string|string[]|Buffer|Buffer[]|Object[]}
70+
* `secureOptions`
71+
* `sessionIdContext` {string}
72+
* `ticketKeys` {Buffer}
73+
* `sessionTimeout` {number}
74+
* `enableTLSTrace` {boolean}
75+
* `handshakeTimeout` {number}
76+
* `minDHSize` {number}
77+
* `pskCallback` {Function}
78+
* `socket` {tls.TLSSocket}
79+
* `identity` {string}
80+
* Returns: {Buffer|TypedArray|DataView}
81+
* `rejectUnauthorized` {boolean}
82+
* `requestOCSP` {boolean}
83+
* `requestPeerCertificate` {boolean}
84+
* `verifyHostnameIdentity` {boolean}
85+
* `transportParams` {Object}
86+
* `initialMaxStreamDataBidiLocal` {number|bigint}
87+
* `initialMaxStreamDataBidiRemote` {number|bigint}
88+
* `initialMaxStreamDataUni` {number|bigint}
89+
* `initialMaxData` {number|bigint}
90+
* `initialMaxStreamsBidi` {number|bigint}
91+
* `initialMaxStreamsUni` {number|bigint}
92+
* `maxIdleTimeout` {number|bigint}
93+
* `activeConnectionIdLimit` {number|bigint}
94+
* `ackDelayExponent` {number|bigint}
95+
* `maxAckDelay` {number|bigint}
96+
* `maxDatagramFrameSize` {number|bigint}
97+
* `disableActiveMigration` {boolean}
98+
* `preferredAddress` {Object}
99+
* `ipv4` {Object|net.SocketAddress}
100+
* `address` {string}
101+
* `port` {number}
102+
* `ipv6` {Object|net.SocketAddress}
103+
* `address` {string}
104+
* `port` {number}

lib/internal/quic/binding.js

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
'use strict';
2+
3+
const {
4+
initializeCallbacks,
5+
} = internalBinding('quic');
6+
7+
const {
8+
symbols: {
9+
owner_symbol,
10+
},
11+
} = require('internal/async_hooks');
12+
13+
// If the initializeCallbacks is undefined, the Node.js binary
14+
// was built without QUIC support, in which case we
15+
// don't want to export anything here.
16+
if (initializeCallbacks === undefined)
17+
return;
18+
19+
// For the list of required callbacks, see the QUIC_JS_CALLBACKS
20+
// macro in src/quic/quic.h
21+
22+
function onEndpointClose(context, status) {}
23+
24+
function onEndpointDone() {
25+
this[owner_symbol].destroy();
26+
}
27+
28+
function onEndpointError() {}
29+
30+
function onSessionNew() {}
31+
32+
function onSessionCert() {}
33+
34+
function onSessionClientHello() {}
35+
36+
function onSessionClose() {}
37+
38+
function onSessionDatagram() {}
39+
40+
function onSessionHandshake() {}
41+
42+
function onSessionKeylog() {}
43+
44+
function onSessionPathValidation() {}
45+
46+
function onSessionUsePreferredAddress() {}
47+
48+
function onSessionQlog() {}
49+
50+
function onSessionOcspRequest() {}
51+
52+
function onSessionOcspResponse() {}
53+
54+
function onSessionTicket() {}
55+
56+
function onSessionVersionNegotiation() {}
57+
58+
function onStreamClose() {}
59+
60+
function onStreamError() {}
61+
62+
function onStreamReady() {}
63+
64+
function onStreamReset() {}
65+
66+
function onStreamHeaders() {}
67+
68+
function onStreamBlocked() {}
69+
70+
module.exports = {
71+
initializeBinding() {
72+
initializeCallbacks({
73+
onEndpointClose,
74+
onEndpointDone,
75+
onEndpointError,
76+
onSessionNew,
77+
onSessionCert,
78+
onSessionClientHello,
79+
onSessionClose,
80+
onSessionDatagram,
81+
onSessionHandshake,
82+
onSessionKeylog,
83+
onSessionPathValidation,
84+
onSessionUsePreferredAddress,
85+
onSessionQlog,
86+
onSessionOcspRequest,
87+
onSessionOcspResponse,
88+
onSessionTicket,
89+
onSessionVersionNegotiation,
90+
onStreamClose,
91+
onStreamError,
92+
onStreamReady,
93+
onStreamReset,
94+
onStreamHeaders,
95+
onStreamBlocked,
96+
});
97+
}
98+
};

0 commit comments

Comments
 (0)