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

feat:hyper-1.0 #115

Merged
merged 43 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b639e79
wip: implemented hyper-1.0 for http/1.1 and http/2. todo: http/3 and …
junkurihara Nov 18, 2023
7bc6e30
chore: deps
junkurihara Nov 21, 2023
f98c778
wip: refactor whole module in lib
junkurihara Nov 21, 2023
de91c7a
wip: refactoring all the structure and improve error messages
junkurihara Nov 22, 2023
3c6e4e5
wip: implemented backend
junkurihara Nov 24, 2023
5576389
wip: implemented crypto reloader, as separated object from proxy itself
junkurihara Nov 24, 2023
1dc88ce
wip: tested with synthetic echo response from h3
junkurihara Nov 24, 2023
4b6f63e
wip: implemented incoming-like body for asynchronous operation in http/3
junkurihara Nov 24, 2023
b8cec68
wip: add stub for message handler
junkurihara Nov 24, 2023
e8d67bf
wip: add tests for incoming-like body
junkurihara Nov 24, 2023
a9ce26a
wip: implementing message handler
junkurihara Nov 27, 2023
c4cf40b
wip: implementing message handler, finished to implement request mani…
junkurihara Nov 27, 2023
f9453fe
wip: fix private type
junkurihara Nov 27, 2023
ab4ac3b
fix private type again
junkurihara Nov 27, 2023
f0b0dbc
wip: manipulate response header
junkurihara Nov 28, 2023
8f77ce9
wip: implement switching protocols (http upgrade)
junkurihara Nov 28, 2023
f020ece
chore: change mod name
junkurihara Nov 28, 2023
a9f5e0e
feat: client (wip), still unstable for http2 due to alpn issues
junkurihara Nov 28, 2023
0741990
wip: fix sync
junkurihara Nov 28, 2023
48a84a7
implement native-tls client
junkurihara Nov 29, 2023
a6f9fc7
remove unneccessary deps
junkurihara Nov 29, 2023
deb4c28
wip: set_reuse_addr for client
junkurihara Nov 30, 2023
2a48c64
deps
junkurihara Dec 4, 2023
f58ce97
chore: empty feature rustls
junkurihara Dec 4, 2023
4aa149a
deps except for rustls family
junkurihara Dec 8, 2023
f714282
chore: prioritize http3-quinn over http3-s2n when both features are e…
junkurihara Dec 8, 2023
6030beb
chore: prioritize rustls-backend while it is not supported (non-default)
junkurihara Dec 8, 2023
f5197d0
wip: refactoring the cache logic
junkurihara Dec 8, 2023
cdcb1b1
wip: chore: fix bug for unused
junkurihara Dec 8, 2023
d473b44
add comment
junkurihara Dec 9, 2023
ed33c5d
wip: implement on-memory cache as is
junkurihara Dec 9, 2023
cc48394
wip: feat: update h3 response reader to use async stream
junkurihara Dec 11, 2023
d526ce6
wip: refactor: reconsider timeouts of connections
junkurihara Dec 11, 2023
b8f3034
wip: fix keep alive timeouts
junkurihara Dec 11, 2023
7cb25a7
add tokio timer
junkurihara Dec 11, 2023
008b62a
wip: feat: define response body enum
junkurihara Dec 12, 2023
1c18f38
wip: feat: change request body from either to explicit enum
junkurihara Dec 12, 2023
8dd6af6
wip: feat: refactored cache implementation for put
junkurihara Dec 12, 2023
bd29c9d
wip: feat: implemented cache
junkurihara Dec 12, 2023
66efa93
Merge pull request #127 from junkurihara/feat/cache-hyper-1.0
junkurihara Dec 12, 2023
92638cc
wip: update changelog and todo
junkurihara Dec 12, 2023
f41a221
preparing nightly-build
junkurihara Dec 15, 2023
db65872
update docs. preparing 0.7.0-alpha.0.
junkurihara Dec 15, 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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ bench/
.private/
.github/
example-certs/
legacy-lib/
66 changes: 33 additions & 33 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,35 +44,35 @@ jobs:
platform: linux/arm64
tags-suffix: "-s2n"

- target: "gnu"
build-feature: "-native-roots"
platform: linux/amd64
tags-suffix: "-native-roots"

- target: "gnu"
build-feature: "-native-roots"
platform: linux/arm64
tags-suffix: "-native-roots"

- target: "musl"
build-feature: "-native-roots"
platform: linux/amd64
tags-suffix: "-slim-native-roots"

- target: "musl"
build-feature: "-native-roots"
platform: linux/arm64
tags-suffix: "-slim-native-roots"

- target: "gnu"
build-feature: "-s2n-native-roots"
platform: linux/amd64
tags-suffix: "-s2n-native-roots"

- target: "gnu"
build-feature: "-s2n-native-roots"
platform: linux/arm64
tags-suffix: "-s2n-native-roots"
# - target: "gnu"
# build-feature: "-native-roots"
# platform: linux/amd64
# tags-suffix: "-native-roots"

# - target: "gnu"
# build-feature: "-native-roots"
# platform: linux/arm64
# tags-suffix: "-native-roots"

# - target: "musl"
# build-feature: "-native-roots"
# platform: linux/amd64
# tags-suffix: "-slim-native-roots"

# - target: "musl"
# build-feature: "-native-roots"
# platform: linux/arm64
# tags-suffix: "-slim-native-roots"

# - target: "gnu"
# build-feature: "-s2n-native-roots"
# platform: linux/amd64
# tags-suffix: "-s2n-native-roots"

# - target: "gnu"
# build-feature: "-s2n-native-roots"
# platform: linux/arm64
# tags-suffix: "-s2n-native-roots"

steps:
- run: "echo 'The relese triggering workflows passed'"
Expand All @@ -81,8 +81,8 @@ jobs:
id: "set-env"
run: |
if [ ${{ matrix.platform }} == 'linux/amd64' ]; then PLATFORM_MAP="x86_64"; else PLATFORM_MAP="aarch64"; fi
if [ ${{ github.ref_name }} == 'develop' ]; then BUILD_NAME="-nightly"; else BUILD_NAME=""; fi
if [ ${{ github.ref_name }} == 'develop' ]; then BUILD_IMG="nightly"; else BUILD_IMG="latest"; fi
if [ ${{ github.ref_name == 'develop' && github.event.client_payload.pull_request.head == 'develop' && github.event.client_payload.pull_request.base == 'main' }} || ${{ github.ref_name == 'main' }}]; then BUILD_NAME=""; else BUILD_NAME="-nightly"; fi
if [ ${{ github.ref_name }} == 'main' ]; then BUILD_IMG="latest"; else BUILD_IMG="nightly"; fi
echo "build_img=${BUILD_IMG}" >> $GITHUB_OUTPUT
echo "target_name=rpxy${BUILD_NAME}-${PLATFORM_MAP}-unknown-linux-${{ matrix.target }}${{ matrix.build-feature }}" >> $GITHUB_OUTPUT

Expand All @@ -93,7 +93,7 @@ jobs:
docker cp ${CONTAINER_ID}:/rpxy/bin/rpxy /tmp/${{ steps.set-env.outputs.target_name }}

- name: "upload artifacts"
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ steps.set-env.outputs.target_name }}
path: "/tmp/${{ steps.set-env.outputs.target_name }}"
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:

- name: download artifacts
if: ${{ steps.regex-match.outputs.match != ''}}
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
path: /tmp/rpxy

Expand Down
74 changes: 37 additions & 37 deletions .github/workflows/release_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- target: "s2n"
dockerfile: ./docker/Dockerfile
build-args: |
"CARGO_FEATURES=--no-default-features --features=http3-s2n,cache"
"CARGO_FEATURES=--no-default-features --features=http3-s2n,cache,native-tls-backend"
"ADDITIONAL_DEPS=pkg-config libssl-dev cmake libclang1 gcc g++"
platforms: linux/amd64,linux/arm64
tags-suffix: "-s2n"
Expand All @@ -53,42 +53,42 @@ jobs:
jqtype/rpxy:s2n
ghcr.io/junkurihara/rust-rpxy:s2n

- target: "native-roots"
dockerfile: ./docker/Dockerfile
platforms: linux/amd64,linux/arm64
build-args: |
"CARGO_FEATURES=--no-default-features --features=http3-quinn,cache,native-roots"
tags-suffix: "-native-roots"
# Aliases must be used only for release builds
aliases: |
jqtype/rpxy:native-roots
ghcr.io/junkurihara/rust-rpxy:native-roots

- target: "slim-native-roots"
dockerfile: ./docker/Dockerfile-slim
build-args: |
"CARGO_FEATURES=--no-default-features --features=http3-quinn,cache,native-roots"
build-contexts: |
messense/rust-musl-cross:amd64-musl=docker-image://messense/rust-musl-cross:x86_64-musl
messense/rust-musl-cross:arm64-musl=docker-image://messense/rust-musl-cross:aarch64-musl
platforms: linux/amd64,linux/arm64
tags-suffix: "-slim-native-roots"
# Aliases must be used only for release builds
aliases: |
jqtype/rpxy:slim-native-roots
ghcr.io/junkurihara/rust-rpxy:slim-native-roots

- target: "s2n-native-roots"
dockerfile: ./docker/Dockerfile
build-args: |
"CARGO_FEATURES=--no-default-features --features=http3-s2n,cache,native-roots"
"ADDITIONAL_DEPS=pkg-config libssl-dev cmake libclang1 gcc g++"
platforms: linux/amd64,linux/arm64
tags-suffix: "-s2n-native-roots"
# Aliases must be used only for release builds
aliases: |
jqtype/rpxy:s2n-native-roots
ghcr.io/junkurihara/rust-rpxy:s2n-native-roots
# - target: "native-roots"
# dockerfile: ./docker/Dockerfile
# platforms: linux/amd64,linux/arm64
# build-args: |
# "CARGO_FEATURES=--no-default-features --features=http3-quinn,cache,native-roots"
# tags-suffix: "-native-roots"
# # Aliases must be used only for release builds
# aliases: |
# jqtype/rpxy:native-roots
# ghcr.io/junkurihara/rust-rpxy:native-roots

# - target: "slim-native-roots"
# dockerfile: ./docker/Dockerfile-slim
# build-args: |
# "CARGO_FEATURES=--no-default-features --features=http3-quinn,cache,native-roots"
# build-contexts: |
# messense/rust-musl-cross:amd64-musl=docker-image://messense/rust-musl-cross:x86_64-musl
# messense/rust-musl-cross:arm64-musl=docker-image://messense/rust-musl-cross:aarch64-musl
# platforms: linux/amd64,linux/arm64
# tags-suffix: "-slim-native-roots"
# # Aliases must be used only for release builds
# aliases: |
# jqtype/rpxy:slim-native-roots
# ghcr.io/junkurihara/rust-rpxy:slim-native-roots

# - target: "s2n-native-roots"
# dockerfile: ./docker/Dockerfile
# build-args: |
# "CARGO_FEATURES=--no-default-features --features=http3-s2n,cache,native-roots"
# "ADDITIONAL_DEPS=pkg-config libssl-dev cmake libclang1 gcc g++"
# platforms: linux/amd64,linux/arm64
# tags-suffix: "-s2n-native-roots"
# # Aliases must be used only for release builds
# aliases: |
# jqtype/rpxy:s2n-native-roots
# ghcr.io/junkurihara/rust-rpxy:s2n-native-roots

steps:
- name: Checkout
Expand Down
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
[submodule "submodules/h3"]
path = submodules/h3
url = [email protected]:junkurihara/h3.git
[submodule "submodules/quinn"]
path = submodules/quinn
url = [email protected]:junkurihara/quinn.git
[submodule "submodules/s2n-quic"]
path = submodules/s2n-quic
url = [email protected]:junkurihara/s2n-quic.git
[submodule "submodules/rusty-http-cache-semantics"]
path = submodules/rusty-http-cache-semantics
url = [email protected]:junkurihara/rusty-http-cache-semantics.git
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## 0.7.0 (unreleased)

- Breaking: `hyper`-1.0 for both server and client modules.
- Breaking: Remove `override_host` option in upstream options. Add a reverse option, i.e., `disable_override_host`. That is, `rpxy` always override the host header by the upstream hostname by default.
- Breaking: Introduced `native-tls-backend` feature to use the native TLS engine to access backend applications.
- Redesigned: Cache structure is totally redesigned with more memory-efficient way to read from cache file, and more secure way to strongly bind memory-objects with files with hash values.
- Redesigned: HTTP body handling flow is also redesigned with more memory-and-time efficient techniques without putting the whole objects on memory by using `futures::stream::Stream` and `futures::channel::mpsc`
- Refactor: lots of minor improvements

## 0.6.2

### Improvement
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ If you want to host multiple and distinct domain names in a single IP address/po
```toml
default_application = "app1"

[app.app1]
[apps.app1]
server_name = "app1.example.com"
#...

[app.app2]
[apps.app2]
server_name = "app2.example.org"
#...
```
Expand Down
2 changes: 2 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# TODO List

- Support of `rustls-0.22` along with `hyper-1.0`. Maybe `hyper-rustls` is the most difficult part.
- [Done in 0.6.0] But we need more sophistication on `Forwarder` struct. ~~Fix strategy for `h2c` requests on forwarded requests upstream. This needs to update forwarder definition. Also, maybe forwarder would have a cache corresponding to the following task.~~
- [Initial implementation in v0.6.0] ~~**Cache option for the response with `Cache-Control: public` header directive ([#55](https://github.com/junkurihara/rust-rpxy/issues/55))**~~ Using `lru` crate might be inefficient in terms of the speed.
- Consider more sophisticated architecture for cache
- Persistent cache (if possible).
- More secure cache file object naming
- etc etc
- Improvement of path matcher
- More flexible option for rewriting path
Expand Down
6 changes: 3 additions & 3 deletions config-example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ upstream = [
]
load_balance = "round_robin" # or "random" or "sticky" (sticky session) or "none" (fix to the first one, default)
upstream_options = [
"override_host",
"force_http2_upstream", # mutually exclusive with "force_http11_upstream"
"disable_override_host", # do not overwrite HOST value with upstream hostname (like 192.168.xx.x seen from rpxy)
"force_http2_upstream", # mutually exclusive with "force_http11_upstream"
]

# Non-default destination in "localhost" app, which is routed by "path"
Expand All @@ -76,7 +76,7 @@ upstream = [
]
load_balance = "random" # or "round_robin" or "sticky" (sticky session) or "none" (fix to the first one, default)
upstream_options = [
"override_host",
"disable_override_host",
"upgrade_insecure_requests",
"force_http11_upstream",
]
Expand Down
89 changes: 89 additions & 0 deletions legacy-lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
[package]
name = "rpxy-lib-legacy"
version = "0.6.2"
authors = ["Jun Kurihara"]
homepage = "https://github.com/junkurihara/rust-rpxy"
repository = "https://github.com/junkurihara/rust-rpxy"
license = "MIT"
readme = "../README.md"
edition = "2021"
publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = ["http3-quinn", "sticky-cookie", "cache"]
http3-quinn = ["quinn", "h3", "h3-quinn", "socket2"]
http3-s2n = ["h3", "s2n-quic", "s2n-quic-rustls", "s2n-quic-h3"]
sticky-cookie = ["base64", "sha2", "chrono"]
cache = ["http-cache-semantics", "lru"]
native-roots = ["hyper-rustls/native-tokio"]

[dependencies]
rand = "0.8.5"
rustc-hash = "1.1.0"
bytes = "1.5.0"
derive_builder = "0.12.0"
futures = { version = "0.3.29", features = ["alloc", "async-await"] }
tokio = { version = "1.34.0", default-features = false, features = [
"net",
"rt-multi-thread",
"time",
"sync",
"macros",
"fs",
] }
async-trait = "0.1.74"
hot_reload = "0.1.4" # reloading certs

# Error handling
anyhow = "1.0.75"
thiserror = "1.0.50"

# http and tls
http = "1.0.0"
http-body-util = "0.1.0"
hyper = { version = "1.0.1", default-features = false }
hyper-util = { version = "0.1.1", features = ["full"] }
hyper-rustls = { version = "0.24.2", default-features = false, features = [
"tokio-runtime",
"webpki-tokio",
"http1",
"http2",
] }
tokio-rustls = { version = "0.24.1", features = ["early-data"] }
rustls = { version = "0.21.9", default-features = false }
webpki = "0.22.4"
x509-parser = "0.15.1"

# logging
tracing = { version = "0.1.40" }

# http/3
quinn = { version = "0.10.2", optional = true }
h3 = { path = "../submodules/h3/h3/", optional = true }
h3-quinn = { path = "../submodules/h3/h3-quinn/", optional = true }
s2n-quic = { version = "1.31.0", default-features = false, features = [
"provider-tls-rustls",
], optional = true }
s2n-quic-h3 = { path = "../submodules/s2n-quic-h3/", optional = true }
s2n-quic-rustls = { version = "0.31.0", optional = true }
# for UDP socket wit SO_REUSEADDR when h3 with quinn
socket2 = { version = "0.5.5", features = ["all"], optional = true }

# cache
http-cache-semantics = { path = "../submodules/rusty-http-cache-semantics/", optional = true }
lru = { version = "0.12.0", optional = true }

# cookie handling for sticky cookie
chrono = { version = "0.4.31", default-features = false, features = [
"unstable-locales",
"alloc",
"clock",
], optional = true }
base64 = { version = "0.21.5", optional = true }
sha2 = { version = "0.10.8", default-features = false, optional = true }


[dev-dependencies]
# http and tls
Loading