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

ci: merge staging to master #119

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "quic"
version = "1.2.11"
version = "1.2.12"
authors = ["Roger Qiu <[email protected]>"]
license-file = "LICENSE"
edition = "2021"
Expand Down
79 changes: 29 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ npm install --save @matrixai/quic

## Usage

See the example executables in `/src/bin`.
See the example usage in [tests](tests).

## Development

Expand All @@ -39,6 +39,27 @@ npm run lint
npm run lintfix
```

### Docs Generation

```sh
npm run docs
```

See the docs at: https://matrixai.github.io/js-quic/

### Publishing

```sh
# npm login
npm version patch # major/minor/patch
npm run build
npm publish --access public
git push
git push --tags
```

## How it works

### Quiche

To understand how to develop this, it is important to understand how quiche works.
Expand Down Expand Up @@ -113,23 +134,23 @@ When using the encapsulated way, the `QUICSocket` is separated between client an

When using the injected way, the `QUICSocket` is shared between client and server.

![](/images/quic_structure_encapsulated.svg)
![image](/images/quic_structure_encapsulated.svg)

If you are building a peer to peer network, you must use the injected way. This is the only way to ensure that hole-punching works because both the client and server for any given peer must share the same UDP socket and thus share the `QUICSocket`. When done in this way, the `QUICSocket` lifecycle is managed outside of both the `QUICClient` and `QUICServer`.

![](/images/quic_structure_injected.svg)
![image](/images/quic_structure_injected.svg)

This also means both `QUICClient` and `QUICServer` must share the same connection map. In order to allow the `QUICSocket` to dispatch data into the correct connection, the connection map is constructed in the `QUICSocket`, however setting and unsetting connections is managed by `QUICClient` and `QUICServer`.

## Dataflow
### Dataflow

The data flow of the QUIC system is a bidirectional graph.

Data received from the outside world is received on the UDP socket. It is parsed and then dispatched to each `QUICConnection`. Each connection further parses the data and then dispatches to the `QUICStream`. Each `QUICStream` presents the data on the `ReadableStream` interface, which can be read by a caller.

Data sent to the outside world is written to a `WritableStream` interface of a `QUICStream`. This data is buffered up in the underlying Quiche stream. A send procedure is triggered on the associated `QUICConnection` which takes all the buffered data to be sent for that connection, and sends it to the `QUICSocket`, which then sends it to the underlying UDP socket.

![](/images/quic_dataflow.svg)
![image](/images/quic_dataflow.svg)

Buffering occurs at the connection level and at the stream level. Each connection has a global buffer for all streams, and each stream has its own buffer. Note that connection buffering and stream buffering all occur within the Quiche library. The web streams `ReadableStream` and `WritableStream` do not do any buffering at all.

Expand All @@ -139,7 +160,7 @@ The connection negotiation process involves several exchanges of QUIC packets be

The primary reason to do this is for both sides to determine their respective connection IDs.

![](/images/quic_connection_negotiation.svg)
![image](/images/quic_connection_negotiation.svg)

### Push & Pull

Expand All @@ -156,49 +177,7 @@ Keeping track of how the system works is therefore quite complex and must follow
* Pull methods - these are either synchronous or asynchronous methods that may throw exceptions.
* Push handlers - these are event handlers that can initiate pull methods, if these pull handlers throw exceptions, these exceptions must be caught, and expected runtime exceptions are to be converted to error events, all other exceptions will be considered to be software bugs and will be bubbled up to the program boundary as unhandled exceptions or unhandled promise rejections. Generally the only exceptions that are expected runtime exceptions are those that arise from perform IO with the operating system.

## Benchmarks

```sh
npm run bench
```

View benchmarks here: https://github.com/MatrixAI/js-quic/blob/master/benches/results with https://raw.githack.com/

### Docs Generation

```sh
npm run docs
```

See the docs at: https://matrixai.github.io/js-quic/

### Publishing
## License

Publishing is handled automatically by the staging pipeline.
js-quic is licensed under Apache-2.0, you may read the terms of the license [here](LICENSE).

Prerelease:

```sh
# npm login
npm version prepatch --preid alpha # premajor/preminor/prepatch
git push --follow-tags
```

Release:

```sh
# npm login
npm version patch # major/minor/patch
git push --follow-tags
```

Manually:

```sh
# npm login
npm version patch # major/minor/patch
npm run build
npm publish --access public
git push
git push --tags
```
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@matrixai/quic",
"version": "1.2.11",
"version": "1.2.12",
"author": "Matrix AI",
"contributors": [
{
Expand Down Expand Up @@ -48,11 +48,11 @@
"ip-num": "^1.5.0"
},
"optionalDependencies": {
"@matrixai/quic-darwin-arm64": "1.2.11",
"@matrixai/quic-darwin-universal": "1.2.11",
"@matrixai/quic-darwin-x64": "1.2.11",
"@matrixai/quic-linux-x64": "1.2.11",
"@matrixai/quic-win32-x64": "1.2.11"
"@matrixai/quic-darwin-arm64": "1.2.12",
"@matrixai/quic-darwin-universal": "1.2.12",
"@matrixai/quic-darwin-x64": "1.2.12",
"@matrixai/quic-linux-x64": "1.2.12",
"@matrixai/quic-win32-x64": "1.2.12"
},
"devDependencies": {
"@fast-check/jest": "^1.1.0",
Expand Down