Skip to content

Commit 06bb0d9

Browse files
authored
Merge pull request #26 from MatrixAI/feature-key-gen
Review - Tests, Key and Certificate Generation, Concurrency Control, Custom TLS Verification
2 parents 5693ef8 + cbedc26 commit 06bb0d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+15090
-4006
lines changed

README.md

+55
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,58 @@ npm publish --access public
154154
git push
155155
git push --tags
156156
```
157+
158+
---
159+
160+
I need to be locked together.
161+
162+
These need to be atomic operations.
163+
164+
The only issue is that the "atomicity" is controlled outside of `QUICConnection` atm.
165+
166+
Whereas it seems to make sense to do this directly?
167+
168+
```
169+
recieve
170+
[IF IS DRAINING IS TRUE SKIP SEND]
171+
send
172+
[CLOSE] - we may be "closed here"
173+
set-timeout
174+
```
175+
176+
This would be triggered by:
177+
* QUICStream
178+
* keepAliveTimer
179+
* after onTimeout
180+
181+
```
182+
send
183+
[CLOSE] - we may be "closed here"
184+
set-timeout
185+
```
186+
187+
Remember you may also "receive" and end up closing too. But you will always check if you need to send first before checking the close. At worst it will tell you it's done.
188+
189+
Now of course we enable calling recv and send.
190+
191+
But `send` actually ends up calling multiple things here.
192+
193+
But if `recv` is synchronous, you can always call it infront of `send`.
194+
195+
This technically means `send` should be encapsulating the logic of setting the timeout.
196+
197+
If you want to make sure it's re-entrant, you can just "lock" on the send call.
198+
199+
The setTimeout is then protected.
200+
201+
The `recv` call is made synchronously.
202+
203+
204+
205+
Receive Send Timer, Send Timer (all of this requires locking the conn lock)
206+
207+
Closing too, it should require the conn lock
208+
Receive Send [Close] Timer, Send [Close] Timer
209+
It's all optional
210+
It's the send that has to do Send, Close, Timer... that's what needs to check it all
211+
Forget about events for now

benches/stream_1KB.ts

+15-16
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@ async function main() {
1616
),
1717
]);
1818
// Setting up initial state
19-
const crypto = {
20-
key: await testsUtils.generateKey(),
21-
ops: {
22-
sign: testsUtils.sign,
23-
verify: testsUtils.verify,
24-
randomBytes: testsUtils.randomBytes,
25-
},
26-
};
27-
2819
const data1KiB = Buffer.alloc(1024, 0xf0);
2920
const host = '127.0.0.1' as Host;
3021
const certChainPem = await fs.promises.readFile(
@@ -36,14 +27,18 @@ async function main() {
3627

3728
const quicServer = new QUICServer({
3829
config: {
39-
tlsConfig: {
40-
privKeyPem: privKeyPem.toString(),
41-
certChainPem: certChainPem.toString(),
42-
},
30+
key: privKeyPem.toString(),
31+
cert: certChainPem.toString(),
4332
verifyPeer: false,
33+
keepAliveIntervalTime: 1000,
34+
},
35+
crypto: {
36+
key: await testsUtils.generateKeyHMAC(),
37+
ops: {
38+
sign: testsUtils.signHMAC,
39+
verify: testsUtils.verifyHMAC,
40+
},
4441
},
45-
keepaliveIntervalTime: 1000,
46-
crypto,
4742
logger,
4843
});
4944
quicServer.addEventListener(
@@ -80,7 +75,11 @@ async function main() {
8075
host,
8176
port: quicServer.port,
8277
localHost: host,
83-
crypto,
78+
crypto: {
79+
ops: {
80+
randomBytes: testsUtils.randomBytes,
81+
},
82+
},
8483
logger,
8584
});
8685

jest.config.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,21 @@ module.exports = {
3333
roots: ['<rootDir>/tests'],
3434
testMatch: ['**/?(*.)+(spec|test|unit.test).+(ts|tsx|js|jsx)'],
3535
transform: {
36-
'^.+\\.tsx?$': 'ts-jest',
37-
'^.+\\.jsx?$': 'babel-jest',
36+
"^.+\\.(t|j)sx?$": [
37+
"@swc/jest",
38+
{
39+
jsc: {
40+
parser: {
41+
syntax: "typescript",
42+
tsx: true,
43+
decorators: compilerOptions.experimentalDecorators,
44+
dynamicImport: true,
45+
},
46+
target: compilerOptions.target.toLowerCase(),
47+
keepClassNames: true,
48+
},
49+
}
50+
],
3851
},
3952
reporters: [
4053
'default',

0 commit comments

Comments
 (0)