Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review - Tests, Key and Certificate Generation, Concurrency Control, Custom TLS Verification #26

Merged
merged 22 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2ffa5ec
feat: initial refactor work
CMCDragonkai May 19, 2023
498f7aa
feat: applying monitor locking to serialize async events
tegefaulkes Jun 20, 2023
bacfc4d
tests: expanded native TLS tests to demonstrate custom connection fai…
tegefaulkes Jun 21, 2023
9b58b85
fix: general fixes and clean up
tegefaulkes Jun 21, 2023
442814e
tests: fixing up client tests
tegefaulkes Jun 23, 2023
b45cc22
fix: removing fixtures
tegefaulkes Jun 23, 2023
a2058cc
tests: fixing up tests
tegefaulkes Jun 23, 2023
1d55f12
dep: bump `@matrixai/async-init` to `1.8.4`
tegefaulkes Jun 23, 2023
9f6ae63
feat: added in secure establishment event
tegefaulkes Jun 23, 2023
225babf
feat: added `verifyCallback` and `verifyAllowFail`
tegefaulkes Jun 23, 2023
9cc653d
tests: fixing up client tests
tegefaulkes Jun 23, 2023
110034d
tests: creating native stream tests
tegefaulkes Jun 27, 2023
b1ea509
fix: small fixes
tegefaulkes Jun 27, 2023
6009eb2
feat: `QUICConnection` and `QUICClient` handles `ctx` and timeouts
tegefaulkes Jun 28, 2023
cea873b
tests: adding custom TLS verification tests
tegefaulkes Jun 28, 2023
968ae89
feat: applying `maxIdleTimeout` constraints for keep-alive and start …
tegefaulkes Jun 29, 2023
85b0375
tests: fixing up tests to match changes
tegefaulkes Jun 29, 2023
798014b
lint: fixing up linting errors
tegefaulkes Jun 29, 2023
30daec8
tests: expanding native stream tests
tegefaulkes Jun 29, 2023
242859c
fix: refactored and cleaned up
tegefaulkes Jul 3, 2023
ed6f3a3
fix: general logic fixes and clean up
tegefaulkes Jul 3, 2023
cbedc26
fix: cleaning up `Monitor` resources
tegefaulkes Jul 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,58 @@ npm publish --access public
git push
git push --tags
```

---

I need to be locked together.

These need to be atomic operations.

The only issue is that the "atomicity" is controlled outside of `QUICConnection` atm.

Whereas it seems to make sense to do this directly?

```
recieve
[IF IS DRAINING IS TRUE SKIP SEND]
send
[CLOSE] - we may be "closed here"
set-timeout
```

This would be triggered by:
* QUICStream
* keepAliveTimer
* after onTimeout

```
send
[CLOSE] - we may be "closed here"
set-timeout
```

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.

Now of course we enable calling recv and send.

But `send` actually ends up calling multiple things here.

But if `recv` is synchronous, you can always call it infront of `send`.

This technically means `send` should be encapsulating the logic of setting the timeout.

If you want to make sure it's re-entrant, you can just "lock" on the send call.

The setTimeout is then protected.

The `recv` call is made synchronously.



Receive Send Timer, Send Timer (all of this requires locking the conn lock)

Closing too, it should require the conn lock
Receive Send [Close] Timer, Send [Close] Timer
It's all optional
It's the send that has to do Send, Close, Timer... that's what needs to check it all
Forget about events for now
31 changes: 15 additions & 16 deletions benches/stream_1KB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ async function main() {
),
]);
// Setting up initial state
const crypto = {
key: await testsUtils.generateKey(),
ops: {
sign: testsUtils.sign,
verify: testsUtils.verify,
randomBytes: testsUtils.randomBytes,
},
};

const data1KiB = Buffer.alloc(1024, 0xf0);
const host = '127.0.0.1' as Host;
const certChainPem = await fs.promises.readFile(
Expand All @@ -36,14 +27,18 @@ async function main() {

const quicServer = new QUICServer({
config: {
tlsConfig: {
privKeyPem: privKeyPem.toString(),
certChainPem: certChainPem.toString(),
},
key: privKeyPem.toString(),
cert: certChainPem.toString(),
verifyPeer: false,
keepAliveIntervalTime: 1000,
},
crypto: {
key: await testsUtils.generateKeyHMAC(),
ops: {
sign: testsUtils.signHMAC,
verify: testsUtils.verifyHMAC,
},
},
keepaliveIntervalTime: 1000,
crypto,
logger,
});
quicServer.addEventListener(
Expand Down Expand Up @@ -80,7 +75,11 @@ async function main() {
host,
port: quicServer.port,
localHost: host,
crypto,
crypto: {
ops: {
randomBytes: testsUtils.randomBytes,
},
},
logger,
});

Expand Down
17 changes: 15 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,21 @@ module.exports = {
roots: ['<rootDir>/tests'],
testMatch: ['**/?(*.)+(spec|test|unit.test).+(ts|tsx|js|jsx)'],
transform: {
'^.+\\.tsx?$': 'ts-jest',
'^.+\\.jsx?$': 'babel-jest',
"^.+\\.(t|j)sx?$": [
"@swc/jest",
{
jsc: {
parser: {
syntax: "typescript",
tsx: true,
decorators: compilerOptions.experimentalDecorators,
dynamicImport: true,
},
target: compilerOptions.target.toLowerCase(),
keepClassNames: true,
},
}
],
},
reporters: [
'default',
Expand Down
Loading