Skip to content

Commit 997f395

Browse files
committed
WIP
1 parent fb062ad commit 997f395

File tree

4 files changed

+74
-132
lines changed

4 files changed

+74
-132
lines changed

src/bin/server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async function main(_argv = process.argv): Promise<number> {
5555
privKeyFromPemFile: './tests/fixtures/certs/okp1.key',
5656
certChainFromPemFile: './tests/fixtures/certs/okp1.crt',
5757
},
58-
}
58+
},
5959
});
6060

6161
await server.start({

src/config.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,19 @@ const textEncoder = new TextEncoder();
134134

135135
function buildQuicheConfig(config: QUICConfig): QuicheConfig {
136136
if (config.key != null && config.cert == null) {
137-
throw new errors.ErrorQUICConfig('The cert option must be set when key is set');
137+
throw new errors.ErrorQUICConfig(
138+
'The cert option must be set when key is set',
139+
);
138140
} else if (config.key == null && config.cert != null) {
139-
throw new errors.ErrorQUICConfig('The key option must be set when cert is set');
141+
throw new errors.ErrorQUICConfig(
142+
'The key option must be set when cert is set',
143+
);
140144
} else if (config.key != null && config.cert != null) {
141145
if (Array.isArray(config.key) && Array.isArray(config.cert)) {
142146
if (config.key.length !== config.cert.length) {
143-
throw new errors.ErrorQUICConfig('The number of keys must match the number of certs');
147+
throw new errors.ErrorQUICConfig(
148+
'The number of keys must match the number of certs',
149+
);
144150
}
145151
}
146152
}
@@ -166,7 +172,7 @@ function buildQuicheConfig(config: QUICConfig): QuicheConfig {
166172
// This is an array of private keys in PEM format
167173
let keyPEMBuffers: Array<Uint8Array> | undefined;
168174
if (config.key != null) {
169-
let keyPEMs: Array<string> = [];
175+
const keyPEMs: Array<string> = [];
170176
if (typeof config.key === 'string') {
171177
keyPEMs.push(config.key.trim() + '\n');
172178
} else if (config.key instanceof Uint8Array) {
@@ -185,7 +191,7 @@ function buildQuicheConfig(config: QUICConfig): QuicheConfig {
185191
// This is an array of certificate chains in PEM format
186192
let certChainPEMBuffers: Array<Uint8Array> | undefined;
187193
if (config.cert != null) {
188-
let certChainPEMs: Array<string> = [];
194+
const certChainPEMs: Array<string> = [];
189195
if (typeof config.cert === 'string') {
190196
certChainPEMs.push(config.cert.trim() + '\n');
191197
} else if (config.cert instanceof Uint8Array) {

tests/QUICServer.test.ts

+7-15
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ describe(QUICServer.name, () => {
100100
tlsConfig: {
101101
privKeyPem: keyPairRSAPEM.privateKey,
102102
certChainPem: certRSAPEM,
103-
}
103+
},
104104
},
105105
logger: logger.getChild('QUICServer'),
106106
});
@@ -117,7 +117,7 @@ describe(QUICServer.name, () => {
117117
tlsConfig: {
118118
privKeyPem: keyPairECDSAPEM.privateKey,
119119
certChainPem: certECDSAPEM,
120-
}
120+
},
121121
},
122122
logger: logger.getChild('QUICServer'),
123123
});
@@ -134,7 +134,7 @@ describe(QUICServer.name, () => {
134134
tlsConfig: {
135135
privKeyPem: keyPairEd25519PEM.privateKey,
136136
certChainPem: certEd25519PEM,
137-
}
137+
},
138138
},
139139
logger: logger.getChild('QUICServer'),
140140
});
@@ -152,26 +152,24 @@ describe(QUICServer.name, () => {
152152
tlsConfig: {
153153
privKeyPem: keyPairEd25519PEM.privateKey,
154154
certChainPem: certEd25519PEM,
155-
}
155+
},
156156
},
157157
logger: logger.getChild('QUICServer'),
158158
});
159159
await quicServer.start();
160160

161-
162-
163161
const scidBuffer = new ArrayBuffer(quiche.MAX_CONN_ID_LEN);
164162
await crypto.ops.randomBytes(scidBuffer);
165163
const scid = new QUICConnectionId(scidBuffer);
166164

167165
const socket = new QUICSocket({
168166
crypto,
169167
resolveHostname: utils.resolveHostname,
170-
logger: logger.getChild(QUICSocket.name)
168+
logger: logger.getChild(QUICSocket.name),
171169
});
172170
await socket.start();
173171

174-
// const config = buildQuicheConfig({
172+
// Const config = buildQuicheConfig({
175173
// ...clientDefault
176174
// });
177175
// Here we want to VERIFY the peer
@@ -180,10 +178,9 @@ describe(QUICServer.name, () => {
180178

181179
const quicConfig: QUICConfig = {
182180
...clientDefault,
183-
verifyPeer: true
181+
verifyPeer: true,
184182
};
185183

186-
187184
const connection = await QUICConnection.connectQUICConnection({
188185
scid,
189186
socket,
@@ -194,19 +191,14 @@ describe(QUICServer.name, () => {
194191
},
195192

196193
config: quicConfig,
197-
198194
});
199195

200-
201196
await socket.stop();
202197
await quicServer.stop();
203198

204199
// We can run with several rsa keypairs and certificates
205-
206200
});
207201
describe('updating configuration', () => {
208-
209202
// We want to test changing the configuration over time
210-
211203
});
212204
});

0 commit comments

Comments
 (0)