Skip to content

Commit be58e55

Browse files
committed
quic: rename classes for consistency and other cleanups
1 parent 122e5eb commit be58e55

File tree

4 files changed

+55
-55
lines changed

4 files changed

+55
-55
lines changed

lib/internal/quic/quic.js

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -231,22 +231,22 @@ const {
231231
/**
232232
* Called when the Endpoint receives a new server-side Session.
233233
* @callback OnSessionCallback
234-
* @param {Session} session
235-
* @param {Endpoint} endpoint
234+
* @param {QuicSession} session
235+
* @param {QuicEndpoint} endpoint
236236
* @returns {void}
237237
*/
238238

239239
/**
240240
* @callback OnStreamCallback
241241
* @param {QuicStream} stream
242-
* @param {Session} session
242+
* @param {QuicSession} session
243243
* @returns {void}
244244
*/
245245

246246
/**
247247
* @callback OnDatagramCallback
248248
* @param {Uint8Array} datagram
249-
* @param {Session} session
249+
* @param {QuicSession} session
250250
* @param {boolean} early
251251
* @returns {void}
252252
*/
@@ -255,7 +255,7 @@ const {
255255
* @callback OnDatagramStatusCallback
256256
* @param {bigint} id
257257
* @param {'lost'|'acknowledged'} status
258-
* @param {Session} session
258+
* @param {QuicSession} session
259259
* @returns {void}
260260
*/
261261

@@ -267,14 +267,14 @@ const {
267267
* @param {SocketAddress} oldLocalAddress
268268
* @param {SocketAddress} oldRemoteAddress
269269
* @param {boolean} preferredAddress
270-
* @param {Session} session
270+
* @param {QuicSession} session
271271
* @returns {void}
272272
*/
273273

274274
/**
275275
* @callback OnSessionTicketCallback
276276
* @param {object} ticket
277-
* @param {Session} session
277+
* @param {QuicSession} session
278278
* @returns {void}
279279
*/
280280

@@ -283,7 +283,7 @@ const {
283283
* @param {number} version
284284
* @param {number[]} requestedVersions
285285
* @param {number[]} supportedVersions
286-
* @param {Session} session
286+
* @param {QuicSession} session
287287
* @returns {void}
288288
*/
289289

@@ -296,7 +296,7 @@ const {
296296
* @param {string} validationErrorReason
297297
* @param {number} validationErrorCode
298298
* @param {boolean} earlyDataAccepted
299-
* @param {Session} session
299+
* @param {QuicSession} session
300300
* @returns {void}
301301
*/
302302

@@ -443,9 +443,9 @@ function processTlsOptions(tls) {
443443
ciphers = DEFAULT_CIPHERS,
444444
groups = DEFAULT_GROUPS,
445445
keylog = false,
446-
verifyClient = true,
446+
verifyClient = false,
447447
tlsTrace = false,
448-
verifyPrivateKey = true,
448+
verifyPrivateKey = false,
449449
keys,
450450
certs,
451451
ca,
@@ -538,7 +538,7 @@ function processTlsOptions(tls) {
538538
class QuicStream {
539539
/** @type {object} */
540540
#handle;
541-
/** @type {Session} */
541+
/** @type {QuicSession} */
542542
#session;
543543
/** @type {QuicStreamStats} */
544544
#stats;
@@ -560,7 +560,7 @@ class QuicStream {
560560
/**
561561
* @param {StreamCallbackConfiguration} config
562562
* @param {object} handle
563-
* @param {Session} session
563+
* @param {QuicSession} session
564564
*/
565565
constructor(config, handle, session, direction) {
566566
validateObject(config, 'config');
@@ -607,7 +607,7 @@ class QuicStream {
607607
/** @type {QuicStreamState} */
608608
get state() { return this.#state; }
609609

610-
/** @type {Session} */
610+
/** @type {QuicSession} */
611611
get session() { return this.#session; }
612612

613613
/** @type {bigint} */
@@ -657,8 +657,8 @@ class QuicStream {
657657
}
658658
}
659659

660-
class Session {
661-
/** @type {Endpoint} */
660+
class QuicSession {
661+
/** @type {QuicEndpoint} */
662662
#endpoint = undefined;
663663
/** @type {boolean} */
664664
#isPendingClose = false;
@@ -695,7 +695,7 @@ class Session {
695695
* @param {SessionCallbackConfiguration} config
696696
* @param {StreamCallbackConfiguration} streamConfig
697697
* @param {object} [handle]
698-
* @param {Endpoint} [endpoint]
698+
* @param {QuicEndpoint} [endpoint]
699699
*/
700700
constructor(config, streamConfig, handle, endpoint) {
701701
validateObject(config, 'config');
@@ -753,7 +753,7 @@ class Session {
753753
/** @type {QuicSessionState} */
754754
get state() { return this.#state; }
755755

756-
/** @type {Endpoint} */
756+
/** @type {QuicEndpoint} */
757757
get endpoint() { return this.#endpoint; }
758758

759759
/** @type {Path} */
@@ -976,7 +976,7 @@ class Session {
976976
depth: options.depth == null ? null : options.depth - 1,
977977
};
978978

979-
return `Session ${inspect({
979+
return `QuicSession ${inspect({
980980
closed: this.closed,
981981
closing: this.#isPendingClose,
982982
destroyed: this.destroyed,
@@ -1039,7 +1039,7 @@ function validateEndpointConfig(config) {
10391039
return config;
10401040
}
10411041

1042-
class Endpoint {
1042+
class QuicEndpoint {
10431043
/** @type {SocketAddress|undefined} */
10441044
#address = undefined;
10451045
/** @type {boolean} */
@@ -1054,7 +1054,7 @@ class Endpoint {
10541054
#pendingClose;
10551055
/** @type {any} */
10561056
#pendingError = undefined;
1057-
/** @type {Session[]} */
1057+
/** @type {QuicSession[]} */
10581058
#sessions = [];
10591059
/** @type {QuicEndpointState} */
10601060
#state;
@@ -1235,7 +1235,7 @@ class Endpoint {
12351235
* Initiates a session with a remote endpoint.
12361236
* @param {SocketAddress} address
12371237
* @param {SessionOptions} [options]
1238-
* @returns {Session}
1238+
* @returns {QuicSession}
12391239
*/
12401240
connect(address, options = kEmptyObject) {
12411241
if (this.#isClosedOrClosing) {
@@ -1278,7 +1278,7 @@ class Endpoint {
12781278
if (handle === undefined) {
12791279
throw new ERR_QUIC_CONNECTION_FAILED();
12801280
}
1281-
const session = new Session(this.#sessionConfig, this.#streamConfig, handle, this);
1281+
const session = new QuicSession(this.#sessionConfig, this.#streamConfig, handle, this);
12821282
ArrayPrototypePush(this.#sessions, session);
12831283
return session;
12841284
}
@@ -1393,7 +1393,7 @@ class Endpoint {
13931393
}
13941394

13951395
[kNewSession](handle) {
1396-
const session = new Session(this.#sessionConfig, this.#streamConfig, handle, this);
1396+
const session = new QuicSession(this.#sessionConfig, this.#streamConfig, handle, this);
13971397
ArrayPrototypePush(this.#sessions, session);
13981398
this.#onsession(session, this);
13991399
}
@@ -1409,7 +1409,7 @@ class Endpoint {
14091409
depth: options.depth == null ? null : options.depth - 1,
14101410
};
14111411

1412-
return `Endpoint ${inspect({
1412+
return `QuicEndpoint ${inspect({
14131413
address: this.address,
14141414
busy: this.busy,
14151415
closed: this.closed,
@@ -1423,7 +1423,7 @@ class Endpoint {
14231423
}
14241424
};
14251425

1426-
ObjectDefineProperties(Endpoint, {
1426+
ObjectDefineProperties(QuicEndpoint, {
14271427
CC_ALGO_RENO: {
14281428
__proto__: null,
14291429
value: CC_ALGO_RENO,
@@ -1467,7 +1467,7 @@ ObjectDefineProperties(Endpoint, {
14671467
enumerable: true,
14681468
},
14691469
});
1470-
ObjectDefineProperties(Session, {
1470+
ObjectDefineProperties(QuicSession, {
14711471
DEFAULT_CIPHERS: {
14721472
__proto__: null,
14731473
value: DEFAULT_CIPHERS,
@@ -1485,8 +1485,8 @@ ObjectDefineProperties(Session, {
14851485
});
14861486

14871487
module.exports = {
1488-
Endpoint,
1489-
Session,
1488+
QuicEndpoint,
1489+
QuicSession,
14901490
QuicStream,
14911491
QuicSessionState,
14921492
QuicSessionStats,

test/parallel/test-quic-internal-endpoint-listen-defaults.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ describe('quic internal endpoint listen defaults', { skip: !hasQuic }, async ()
2020
} = require('net');
2121

2222
const {
23-
Endpoint,
23+
QuicEndpoint,
2424
} = require('internal/quic/quic');
2525

2626
it('are reasonable and work as expected', async () => {
27-
const endpoint = new Endpoint({
27+
const endpoint = new QuicEndpoint({
2828
onsession() {},
2929
session: {},
3030
stream: {},

test/parallel/test-quic-internal-endpoint-options.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('quic internal endpoint options', { skip: !hasQuic }, async () => {
1515
} = require('node:assert');
1616

1717
const {
18-
Endpoint,
18+
QuicEndpoint,
1919
} = require('internal/quic/quic');
2020

2121
const {
@@ -30,17 +30,17 @@ describe('quic internal endpoint options', { skip: !hasQuic }, async () => {
3030

3131
it('invalid options', async () => {
3232
['a', null, false, NaN].forEach((i) => {
33-
throws(() => new Endpoint(callbackConfig, i), {
33+
throws(() => new QuicEndpoint(callbackConfig, i), {
3434
code: 'ERR_INVALID_ARG_TYPE',
3535
});
3636
});
3737
});
3838

3939
it('valid options', async () => {
4040
// Just Works... using all defaults
41-
new Endpoint(callbackConfig, {});
42-
new Endpoint(callbackConfig);
43-
new Endpoint(callbackConfig, undefined);
41+
new QuicEndpoint(callbackConfig, {});
42+
new QuicEndpoint(callbackConfig);
43+
new QuicEndpoint(callbackConfig, undefined);
4444
});
4545

4646
it('various cases', async () => {
@@ -126,12 +126,12 @@ describe('quic internal endpoint options', { skip: !hasQuic }, async () => {
126126
{
127127
key: 'cc',
128128
valid: [
129-
Endpoint.CC_ALGO_RENO,
130-
Endpoint.CC_ALGO_CUBIC,
131-
Endpoint.CC_ALGO_BBR,
132-
Endpoint.CC_ALGO_RENO_STR,
133-
Endpoint.CC_ALGO_CUBIC_STR,
134-
Endpoint.CC_ALGO_BBR_STR,
129+
QuicEndpoint.CC_ALGO_RENO,
130+
QuicEndpoint.CC_ALGO_CUBIC,
131+
QuicEndpoint.CC_ALGO_BBR,
132+
QuicEndpoint.CC_ALGO_RENO_STR,
133+
QuicEndpoint.CC_ALGO_CUBIC_STR,
134+
QuicEndpoint.CC_ALGO_BBR_STR,
135135
],
136136
invalid: [-1, 4, 1n, 'a', null, false, true, {}, [], () => {}],
137137
},
@@ -190,39 +190,39 @@ describe('quic internal endpoint options', { skip: !hasQuic }, async () => {
190190
for (const value of valid) {
191191
const options = {};
192192
options[key] = value;
193-
new Endpoint(callbackConfig, options);
193+
new QuicEndpoint(callbackConfig, options);
194194
}
195195

196196
for (const value of invalid) {
197197
const options = {};
198198
options[key] = value;
199-
throws(() => new Endpoint(callbackConfig, options), {
199+
throws(() => new QuicEndpoint(callbackConfig, options), {
200200
code: 'ERR_INVALID_ARG_VALUE',
201201
});
202202
}
203203
}
204204
});
205205

206206
it('endpoint can be ref/unrefed without error', async () => {
207-
const endpoint = new Endpoint(callbackConfig, {});
207+
const endpoint = new QuicEndpoint(callbackConfig, {});
208208
endpoint.unref();
209209
endpoint.ref();
210210
endpoint.close();
211211
await endpoint.closed;
212212
});
213213

214214
it('endpoint can be inspected', async () => {
215-
const endpoint = new Endpoint(callbackConfig, {});
215+
const endpoint = new QuicEndpoint(callbackConfig, {});
216216
strictEqual(typeof inspect(endpoint), 'string');
217217
endpoint.close();
218218
await endpoint.closed;
219219
});
220220

221221
it('endpoint with object address', () => {
222-
new Endpoint(callbackConfig, {
222+
new QuicEndpoint(callbackConfig, {
223223
address: { host: '127.0.0.1:0' },
224224
});
225-
throws(() => new Endpoint(callbackConfig, { address: '127.0.0.1:0' }), {
225+
throws(() => new QuicEndpoint(callbackConfig, { address: '127.0.0.1:0' }), {
226226
code: 'ERR_INVALID_ARG_TYPE',
227227
});
228228
});

0 commit comments

Comments
 (0)