preparing nightly-build
This commit is contained in:
parent
92638ccd2a
commit
f41a2213f9
13 changed files with 109 additions and 110 deletions
|
|
@ -4,3 +4,4 @@ bench/
|
||||||
.private/
|
.private/
|
||||||
.github/
|
.github/
|
||||||
example-certs/
|
example-certs/
|
||||||
|
legacy-lib/
|
||||||
|
|
|
||||||
56
.github/workflows/release.yml
vendored
56
.github/workflows/release.yml
vendored
|
|
@ -44,35 +44,35 @@ jobs:
|
||||||
platform: linux/arm64
|
platform: linux/arm64
|
||||||
tags-suffix: "-s2n"
|
tags-suffix: "-s2n"
|
||||||
|
|
||||||
- target: "gnu"
|
# - target: "gnu"
|
||||||
build-feature: "-native-roots"
|
# build-feature: "-native-roots"
|
||||||
platform: linux/amd64
|
# platform: linux/amd64
|
||||||
tags-suffix: "-native-roots"
|
# tags-suffix: "-native-roots"
|
||||||
|
|
||||||
- target: "gnu"
|
# - target: "gnu"
|
||||||
build-feature: "-native-roots"
|
# build-feature: "-native-roots"
|
||||||
platform: linux/arm64
|
# platform: linux/arm64
|
||||||
tags-suffix: "-native-roots"
|
# tags-suffix: "-native-roots"
|
||||||
|
|
||||||
- target: "musl"
|
# - target: "musl"
|
||||||
build-feature: "-native-roots"
|
# build-feature: "-native-roots"
|
||||||
platform: linux/amd64
|
# platform: linux/amd64
|
||||||
tags-suffix: "-slim-native-roots"
|
# tags-suffix: "-slim-native-roots"
|
||||||
|
|
||||||
- target: "musl"
|
# - target: "musl"
|
||||||
build-feature: "-native-roots"
|
# build-feature: "-native-roots"
|
||||||
platform: linux/arm64
|
# platform: linux/arm64
|
||||||
tags-suffix: "-slim-native-roots"
|
# tags-suffix: "-slim-native-roots"
|
||||||
|
|
||||||
- target: "gnu"
|
# - target: "gnu"
|
||||||
build-feature: "-s2n-native-roots"
|
# build-feature: "-s2n-native-roots"
|
||||||
platform: linux/amd64
|
# platform: linux/amd64
|
||||||
tags-suffix: "-s2n-native-roots"
|
# tags-suffix: "-s2n-native-roots"
|
||||||
|
|
||||||
- target: "gnu"
|
# - target: "gnu"
|
||||||
build-feature: "-s2n-native-roots"
|
# build-feature: "-s2n-native-roots"
|
||||||
platform: linux/arm64
|
# platform: linux/arm64
|
||||||
tags-suffix: "-s2n-native-roots"
|
# tags-suffix: "-s2n-native-roots"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- run: "echo 'The relese triggering workflows passed'"
|
- run: "echo 'The relese triggering workflows passed'"
|
||||||
|
|
@ -81,8 +81,8 @@ jobs:
|
||||||
id: "set-env"
|
id: "set-env"
|
||||||
run: |
|
run: |
|
||||||
if [ ${{ matrix.platform }} == 'linux/amd64' ]; then PLATFORM_MAP="x86_64"; else PLATFORM_MAP="aarch64"; fi
|
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' && 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 }} == 'develop' ]; then BUILD_IMG="nightly"; else BUILD_IMG="latest"; fi
|
if [ ${{ github.ref_name }} == 'main' ]; then BUILD_IMG="latest"; else BUILD_IMG="nightly"; fi
|
||||||
echo "build_img=${BUILD_IMG}" >> $GITHUB_OUTPUT
|
echo "build_img=${BUILD_IMG}" >> $GITHUB_OUTPUT
|
||||||
echo "target_name=rpxy${BUILD_NAME}-${PLATFORM_MAP}-unknown-linux-${{ matrix.target }}${{ matrix.build-feature }}" >> $GITHUB_OUTPUT
|
echo "target_name=rpxy${BUILD_NAME}-${PLATFORM_MAP}-unknown-linux-${{ matrix.target }}${{ matrix.build-feature }}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
|
@ -93,7 +93,7 @@ jobs:
|
||||||
docker cp ${CONTAINER_ID}:/rpxy/bin/rpxy /tmp/${{ steps.set-env.outputs.target_name }}
|
docker cp ${CONTAINER_ID}:/rpxy/bin/rpxy /tmp/${{ steps.set-env.outputs.target_name }}
|
||||||
|
|
||||||
- name: "upload artifacts"
|
- name: "upload artifacts"
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ steps.set-env.outputs.target_name }}
|
name: ${{ steps.set-env.outputs.target_name }}
|
||||||
path: "/tmp/${{ steps.set-env.outputs.target_name }}"
|
path: "/tmp/${{ steps.set-env.outputs.target_name }}"
|
||||||
|
|
@ -122,7 +122,7 @@ jobs:
|
||||||
|
|
||||||
- name: download artifacts
|
- name: download artifacts
|
||||||
if: ${{ steps.regex-match.outputs.match != ''}}
|
if: ${{ steps.regex-match.outputs.match != ''}}
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
path: /tmp/rpxy
|
path: /tmp/rpxy
|
||||||
|
|
||||||
|
|
|
||||||
70
.github/workflows/release_docker.yml
vendored
70
.github/workflows/release_docker.yml
vendored
|
|
@ -44,7 +44,7 @@ jobs:
|
||||||
- target: "s2n"
|
- target: "s2n"
|
||||||
dockerfile: ./docker/Dockerfile
|
dockerfile: ./docker/Dockerfile
|
||||||
build-args: |
|
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++"
|
"ADDITIONAL_DEPS=pkg-config libssl-dev cmake libclang1 gcc g++"
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
tags-suffix: "-s2n"
|
tags-suffix: "-s2n"
|
||||||
|
|
@ -53,42 +53,42 @@ jobs:
|
||||||
jqtype/rpxy:s2n
|
jqtype/rpxy:s2n
|
||||||
ghcr.io/junkurihara/rust-rpxy:s2n
|
ghcr.io/junkurihara/rust-rpxy:s2n
|
||||||
|
|
||||||
- target: "native-roots"
|
# - target: "native-roots"
|
||||||
dockerfile: ./docker/Dockerfile
|
# dockerfile: ./docker/Dockerfile
|
||||||
platforms: linux/amd64,linux/arm64
|
# platforms: linux/amd64,linux/arm64
|
||||||
build-args: |
|
# build-args: |
|
||||||
"CARGO_FEATURES=--no-default-features --features=http3-quinn,cache,native-roots"
|
# "CARGO_FEATURES=--no-default-features --features=http3-quinn,cache,native-roots"
|
||||||
tags-suffix: "-native-roots"
|
# tags-suffix: "-native-roots"
|
||||||
# Aliases must be used only for release builds
|
# # Aliases must be used only for release builds
|
||||||
aliases: |
|
# aliases: |
|
||||||
jqtype/rpxy:native-roots
|
# jqtype/rpxy:native-roots
|
||||||
ghcr.io/junkurihara/rust-rpxy:native-roots
|
# ghcr.io/junkurihara/rust-rpxy:native-roots
|
||||||
|
|
||||||
- target: "slim-native-roots"
|
# - target: "slim-native-roots"
|
||||||
dockerfile: ./docker/Dockerfile-slim
|
# dockerfile: ./docker/Dockerfile-slim
|
||||||
build-args: |
|
# build-args: |
|
||||||
"CARGO_FEATURES=--no-default-features --features=http3-quinn,cache,native-roots"
|
# "CARGO_FEATURES=--no-default-features --features=http3-quinn,cache,native-roots"
|
||||||
build-contexts: |
|
# build-contexts: |
|
||||||
messense/rust-musl-cross:amd64-musl=docker-image://messense/rust-musl-cross:x86_64-musl
|
# 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
|
# messense/rust-musl-cross:arm64-musl=docker-image://messense/rust-musl-cross:aarch64-musl
|
||||||
platforms: linux/amd64,linux/arm64
|
# platforms: linux/amd64,linux/arm64
|
||||||
tags-suffix: "-slim-native-roots"
|
# tags-suffix: "-slim-native-roots"
|
||||||
# Aliases must be used only for release builds
|
# # Aliases must be used only for release builds
|
||||||
aliases: |
|
# aliases: |
|
||||||
jqtype/rpxy:slim-native-roots
|
# jqtype/rpxy:slim-native-roots
|
||||||
ghcr.io/junkurihara/rust-rpxy:slim-native-roots
|
# ghcr.io/junkurihara/rust-rpxy:slim-native-roots
|
||||||
|
|
||||||
- target: "s2n-native-roots"
|
# - target: "s2n-native-roots"
|
||||||
dockerfile: ./docker/Dockerfile
|
# dockerfile: ./docker/Dockerfile
|
||||||
build-args: |
|
# build-args: |
|
||||||
"CARGO_FEATURES=--no-default-features --features=http3-s2n,cache,native-roots"
|
# "CARGO_FEATURES=--no-default-features --features=http3-s2n,cache,native-roots"
|
||||||
"ADDITIONAL_DEPS=pkg-config libssl-dev cmake libclang1 gcc g++"
|
# "ADDITIONAL_DEPS=pkg-config libssl-dev cmake libclang1 gcc g++"
|
||||||
platforms: linux/amd64,linux/arm64
|
# platforms: linux/amd64,linux/arm64
|
||||||
tags-suffix: "-s2n-native-roots"
|
# tags-suffix: "-s2n-native-roots"
|
||||||
# Aliases must be used only for release builds
|
# # Aliases must be used only for release builds
|
||||||
aliases: |
|
# aliases: |
|
||||||
jqtype/rpxy:s2n-native-roots
|
# jqtype/rpxy:s2n-native-roots
|
||||||
ghcr.io/junkurihara/rust-rpxy:s2n-native-roots
|
# ghcr.io/junkurihara/rust-rpxy:s2n-native-roots
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
|
|
||||||
members = ["rpxy-bin", "rpxy-lib", "legacy-lib"]
|
members = ["rpxy-bin", "rpxy-lib"]
|
||||||
exclude = ["submodules"]
|
exclude = ["submodules"]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "rpxy"
|
name = "rpxy"
|
||||||
version = "0.7.0"
|
version = "0.7.0-alpha.0"
|
||||||
authors = ["Jun Kurihara"]
|
authors = ["Jun Kurihara"]
|
||||||
homepage = "https://github.com/junkurihara/rust-rpxy"
|
homepage = "https://github.com/junkurihara/rust-rpxy"
|
||||||
repository = "https://github.com/junkurihara/rust-rpxy"
|
repository = "https://github.com/junkurihara/rust-rpxy"
|
||||||
|
|
@ -12,23 +12,25 @@ publish = false
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["http3-quinn", "cache"]
|
default = ["http3-quinn", "cache", "native-tls-backend"]
|
||||||
http3-quinn = ["rpxy-lib/http3-quinn"]
|
http3-quinn = ["rpxy-lib/http3-quinn"]
|
||||||
http3-s2n = ["rpxy-lib/http3-s2n"]
|
http3-s2n = ["rpxy-lib/http3-s2n"]
|
||||||
|
native-tls-backend = ["rpxy-lib/native-tls-backend"]
|
||||||
|
# Not yet implemented
|
||||||
|
rustls-backend = ["rpxy-lib/rustls-backend"]
|
||||||
cache = ["rpxy-lib/cache"]
|
cache = ["rpxy-lib/cache"]
|
||||||
native-roots = ["rpxy-lib/native-roots"]
|
native-roots = ["rpxy-lib/native-roots"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rpxy-lib = { path = "../rpxy-lib/", default-features = false, features = [
|
rpxy-lib = { path = "../rpxy-lib/", default-features = false, features = [
|
||||||
"sticky-cookie",
|
"sticky-cookie",
|
||||||
"native-tls-backend",
|
|
||||||
] }
|
] }
|
||||||
|
|
||||||
anyhow = "1.0.75"
|
anyhow = "1.0.75"
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash = "1.1.0"
|
||||||
serde = { version = "1.0.193", default-features = false, features = ["derive"] }
|
serde = { version = "1.0.193", default-features = false, features = ["derive"] }
|
||||||
derive_builder = "0.12.0"
|
derive_builder = "0.12.0"
|
||||||
tokio = { version = "1.34.0", default-features = false, features = [
|
tokio = { version = "1.35.0", default-features = false, features = [
|
||||||
"net",
|
"net",
|
||||||
"rt-multi-thread",
|
"rt-multi-thread",
|
||||||
"time",
|
"time",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "rpxy-lib"
|
name = "rpxy-lib"
|
||||||
version = "0.7.0"
|
version = "0.7.0-alpha.0"
|
||||||
authors = ["Jun Kurihara"]
|
authors = ["Jun Kurihara"]
|
||||||
homepage = "https://github.com/junkurihara/rust-rpxy"
|
homepage = "https://github.com/junkurihara/rust-rpxy"
|
||||||
repository = "https://github.com/junkurihara/rust-rpxy"
|
repository = "https://github.com/junkurihara/rust-rpxy"
|
||||||
|
|
@ -21,11 +21,11 @@ http3-s2n = [
|
||||||
"s2n-quic-rustls",
|
"s2n-quic-rustls",
|
||||||
"s2n-quic-h3",
|
"s2n-quic-h3",
|
||||||
]
|
]
|
||||||
|
cache = ["http-cache-semantics", "lru", "sha2", "base64"]
|
||||||
sticky-cookie = ["base64", "sha2", "chrono"]
|
sticky-cookie = ["base64", "sha2", "chrono"]
|
||||||
native-tls-backend = ["hyper-tls"]
|
native-tls-backend = ["hyper-tls"]
|
||||||
rustls-backend = []
|
rustls-backend = [] # not implemented yet
|
||||||
cache = ["http-cache-semantics", "lru", "sha2", "base64"]
|
native-roots = [] #"hyper-rustls/native-tokio"] # not implemented yet
|
||||||
native-roots = [] #"hyper-rustls/native-tokio"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
|
|
@ -33,7 +33,7 @@ rustc-hash = "1.1.0"
|
||||||
bytes = "1.5.0"
|
bytes = "1.5.0"
|
||||||
derive_builder = "0.12.0"
|
derive_builder = "0.12.0"
|
||||||
futures = { version = "0.3.29", features = ["alloc", "async-await"] }
|
futures = { version = "0.3.29", features = ["alloc", "async-await"] }
|
||||||
tokio = { version = "1.34.0", default-features = false, features = [
|
tokio = { version = "1.35.0", default-features = false, features = [
|
||||||
"net",
|
"net",
|
||||||
"rt-multi-thread",
|
"rt-multi-thread",
|
||||||
"time",
|
"time",
|
||||||
|
|
@ -57,7 +57,10 @@ futures-util = { version = "0.3.29", default-features = false }
|
||||||
futures-channel = { version = "0.3.29", default-features = false }
|
futures-channel = { version = "0.3.29", default-features = false }
|
||||||
|
|
||||||
# http client for upstream
|
# http client for upstream
|
||||||
hyper-tls = { version = "0.6.0", features = ["alpn"], optional = true }
|
hyper-tls = { version = "0.6.0", features = [
|
||||||
|
"alpn",
|
||||||
|
"vendored",
|
||||||
|
], optional = true }
|
||||||
# hyper-rustls = { version = "0.24.2", default-features = false, features = [
|
# hyper-rustls = { version = "0.24.2", default-features = false, features = [
|
||||||
# "tokio-runtime",
|
# "tokio-runtime",
|
||||||
# "webpki-tokio",
|
# "webpki-tokio",
|
||||||
|
|
|
||||||
5
rpxy-lib/src/forwarder/cache/cache_error.rs
vendored
5
rpxy-lib/src/forwarder/cache/cache_error.rs
vendored
|
|
@ -1,6 +1,6 @@
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
pub type CacheResult<T> = std::result::Result<T, CacheError>;
|
pub(crate) type CacheResult<T> = std::result::Result<T, CacheError>;
|
||||||
|
|
||||||
/// Describes things that can go wrong in the Rpxy
|
/// Describes things that can go wrong in the Rpxy
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
|
|
@ -9,9 +9,6 @@ pub enum CacheError {
|
||||||
#[error("Invalid null request and/or response")]
|
#[error("Invalid null request and/or response")]
|
||||||
NullRequestOrResponse,
|
NullRequestOrResponse,
|
||||||
|
|
||||||
#[error("Failed to write byte buffer")]
|
|
||||||
FailedToWriteByteBufferForCache,
|
|
||||||
|
|
||||||
#[error("Failed to acquire mutex lock for cache")]
|
#[error("Failed to acquire mutex lock for cache")]
|
||||||
FailedToAcquiredMutexLockForCache,
|
FailedToAcquiredMutexLockForCache,
|
||||||
|
|
||||||
|
|
|
||||||
20
rpxy-lib/src/forwarder/cache/cache_main.rs
vendored
20
rpxy-lib/src/forwarder/cache/cache_main.rs
vendored
|
|
@ -30,7 +30,7 @@ use tokio::{
|
||||||
/* ---------------------------------------------- */
|
/* ---------------------------------------------- */
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
/// Cache main manager
|
/// Cache main manager
|
||||||
pub struct RpxyCache {
|
pub(crate) struct RpxyCache {
|
||||||
/// Inner lru cache manager storing http message caching policy
|
/// Inner lru cache manager storing http message caching policy
|
||||||
inner: LruCacheManager,
|
inner: LruCacheManager,
|
||||||
/// Managing cache file objects through RwLock's lock mechanism for file lock
|
/// Managing cache file objects through RwLock's lock mechanism for file lock
|
||||||
|
|
@ -47,7 +47,7 @@ pub struct RpxyCache {
|
||||||
|
|
||||||
impl RpxyCache {
|
impl RpxyCache {
|
||||||
/// Generate cache storage
|
/// Generate cache storage
|
||||||
pub async fn new(globals: &Globals) -> Option<Self> {
|
pub(crate) async fn new(globals: &Globals) -> Option<Self> {
|
||||||
if !globals.proxy_config.cache_enabled {
|
if !globals.proxy_config.cache_enabled {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
@ -80,7 +80,7 @@ impl RpxyCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Count cache entries
|
/// Count cache entries
|
||||||
pub async fn count(&self) -> (usize, usize, usize) {
|
pub(crate) async fn count(&self) -> (usize, usize, usize) {
|
||||||
let total = self.inner.count();
|
let total = self.inner.count();
|
||||||
let file = self.file_store.count().await;
|
let file = self.file_store.count().await;
|
||||||
let on_memory = total - file;
|
let on_memory = total - file;
|
||||||
|
|
@ -88,7 +88,7 @@ impl RpxyCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Put response into the cache
|
/// Put response into the cache
|
||||||
pub async fn put(
|
pub(crate) async fn put(
|
||||||
&self,
|
&self,
|
||||||
uri: &hyper::Uri,
|
uri: &hyper::Uri,
|
||||||
mut body: Incoming,
|
mut body: Incoming,
|
||||||
|
|
@ -186,7 +186,7 @@ impl RpxyCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get cached response
|
/// Get cached response
|
||||||
pub async fn get<R>(&self, req: &Request<R>) -> Option<Response<ResponseBody>> {
|
pub(crate) async fn get<R>(&self, req: &Request<R>) -> Option<Response<ResponseBody>> {
|
||||||
debug!(
|
debug!(
|
||||||
"Current cache status: (total, on-memory, file) = {:?}",
|
"Current cache status: (total, on-memory, file) = {:?}",
|
||||||
self.count().await
|
self.count().await
|
||||||
|
|
@ -394,7 +394,7 @@ impl FileStoreInner {
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
/// Cache target in hybrid manner of on-memory and file system
|
/// Cache target in hybrid manner of on-memory and file system
|
||||||
pub enum CacheFileOrOnMemory {
|
pub(crate) enum CacheFileOrOnMemory {
|
||||||
/// Pointer to the temporary cache file
|
/// Pointer to the temporary cache file
|
||||||
File(PathBuf),
|
File(PathBuf),
|
||||||
/// Cached body itself
|
/// Cached body itself
|
||||||
|
|
@ -418,11 +418,11 @@ impl CacheFileOrOnMemory {
|
||||||
/// Cache object definition
|
/// Cache object definition
|
||||||
struct CacheObject {
|
struct CacheObject {
|
||||||
/// Cache policy to determine if the stored cache can be used as a response to a new incoming request
|
/// Cache policy to determine if the stored cache can be used as a response to a new incoming request
|
||||||
pub policy: CachePolicy,
|
policy: CachePolicy,
|
||||||
/// Cache target: on-memory object or temporary file
|
/// Cache target: on-memory object or temporary file
|
||||||
pub target: CacheFileOrOnMemory,
|
target: CacheFileOrOnMemory,
|
||||||
/// SHA256 hash of target to strongly bind the cache metadata (this object) and file target
|
/// SHA256 hash of target to strongly bind the cache metadata (this object) and file target
|
||||||
pub hash: Bytes,
|
hash: Bytes,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------- */
|
/* ---------------------------------------------- */
|
||||||
|
|
@ -490,7 +490,7 @@ impl LruCacheManager {
|
||||||
|
|
||||||
/* ---------------------------------------------- */
|
/* ---------------------------------------------- */
|
||||||
/// Generate cache policy if the response is cacheable
|
/// Generate cache policy if the response is cacheable
|
||||||
pub fn get_policy_if_cacheable<B1, B2>(
|
pub(crate) fn get_policy_if_cacheable<B1, B2>(
|
||||||
req: Option<&Request<B1>>,
|
req: Option<&Request<B1>>,
|
||||||
res: Option<&Response<B2>>,
|
res: Option<&Response<B2>>,
|
||||||
) -> CacheResult<Option<CachePolicy>>
|
) -> CacheResult<Option<CachePolicy>>
|
||||||
|
|
|
||||||
2
rpxy-lib/src/forwarder/cache/mod.rs
vendored
2
rpxy-lib/src/forwarder/cache/mod.rs
vendored
|
|
@ -2,4 +2,4 @@ mod cache_error;
|
||||||
mod cache_main;
|
mod cache_main;
|
||||||
|
|
||||||
pub use cache_error::CacheError;
|
pub use cache_error::CacheError;
|
||||||
pub use cache_main::{get_policy_if_cacheable, CacheFileOrOnMemory, RpxyCache};
|
pub(crate) use cache_main::{get_policy_if_cacheable, RpxyCache};
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ where
|
||||||
<B as Body>::Error: Into<Box<(dyn std::error::Error + Send + Sync + 'static)>>,
|
<B as Body>::Error: Into<Box<(dyn std::error::Error + Send + Sync + 'static)>>,
|
||||||
{
|
{
|
||||||
/// Build inner client with http
|
/// Build inner client with http
|
||||||
pub fn try_new(_globals: &Arc<Globals>) -> RpxyResult<Self> {
|
pub async fn try_new(_globals: &Arc<Globals>) -> RpxyResult<Self> {
|
||||||
warn!(
|
warn!(
|
||||||
"
|
"
|
||||||
--------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------
|
||||||
|
|
@ -134,6 +134,7 @@ Please enable native-tls-backend or rustls-backend feature to enable TLS support
|
||||||
let mut http = HttpConnector::new();
|
let mut http = HttpConnector::new();
|
||||||
http.set_reuse_address(true);
|
http.set_reuse_address(true);
|
||||||
let inner = Client::builder(executor).build::<_, B>(http);
|
let inner = Client::builder(executor).build::<_, B>(http);
|
||||||
|
let inner_h2 = inner.clone();
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
inner,
|
inner,
|
||||||
|
|
@ -191,7 +192,7 @@ where
|
||||||
|
|
||||||
#[cfg(feature = "rustls-backend")]
|
#[cfg(feature = "rustls-backend")]
|
||||||
/// Build forwarder with hyper-rustls (rustls)
|
/// Build forwarder with hyper-rustls (rustls)
|
||||||
impl<B1> Forwarder<hyper_tls::HttpsConnector<HttpConnector>, B1>
|
impl<B1> Forwarder<HttpConnector, B1>
|
||||||
where
|
where
|
||||||
B1: Body + Send + Unpin + 'static,
|
B1: Body + Send + Unpin + 'static,
|
||||||
<B1 as Body>::Data: Send,
|
<B1 as Body>::Data: Send,
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
use super::body::IncomingLike;
|
use super::body::IncomingLike;
|
||||||
use crate::error::RpxyError;
|
use crate::error::RpxyError;
|
||||||
use http_body_util::{combinators, BodyExt, Empty, Full};
|
use futures::channel::mpsc::UnboundedReceiver;
|
||||||
use hyper::body::{Body, Bytes, Incoming};
|
use http_body_util::{combinators, BodyExt, Empty, Full, StreamBody};
|
||||||
|
use hyper::body::{Body, Bytes, Frame, Incoming};
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
|
|
||||||
/// Type for synthetic boxed body
|
/// Type for synthetic boxed body
|
||||||
pub(crate) type BoxBody = combinators::BoxBody<Bytes, hyper::Error>;
|
pub type BoxBody = combinators::BoxBody<Bytes, hyper::Error>;
|
||||||
|
|
||||||
/// helper function to build a empty body
|
/// helper function to build a empty body
|
||||||
pub(crate) fn empty() -> BoxBody {
|
pub(crate) fn empty() -> BoxBody {
|
||||||
|
|
@ -17,11 +18,12 @@ pub(crate) fn full(body: Bytes) -> BoxBody {
|
||||||
Full::new(body).map_err(|never| match never {}).boxed()
|
Full::new(body).map_err(|never| match never {}).boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
/* ------------------------------------ */
|
/* ------------------------------------ */
|
||||||
/// Request body used in this project
|
/// Request body used in this project
|
||||||
/// - Incoming: just a type that only forwards the downstream request body to upstream.
|
/// - Incoming: just a type that only forwards the downstream request body to upstream.
|
||||||
/// - IncomingLike: a Incoming-like type in which channel is used
|
/// - IncomingLike: a Incoming-like type in which channel is used
|
||||||
pub(crate) enum RequestBody {
|
pub enum RequestBody {
|
||||||
Incoming(Incoming),
|
Incoming(Incoming),
|
||||||
IncomingLike(IncomingLike),
|
IncomingLike(IncomingLike),
|
||||||
}
|
}
|
||||||
|
|
@ -42,24 +44,16 @@ impl Body for RequestBody {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------ */
|
/* ------------------------------------ */
|
||||||
#[cfg(feature = "cache")]
|
pub type UnboundedStreamBody = StreamBody<UnboundedReceiver<Result<Frame<bytes::Bytes>, hyper::Error>>>;
|
||||||
use futures::channel::mpsc::UnboundedReceiver;
|
|
||||||
#[cfg(feature = "cache")]
|
|
||||||
use http_body_util::StreamBody;
|
|
||||||
#[cfg(feature = "cache")]
|
|
||||||
use hyper::body::Frame;
|
|
||||||
|
|
||||||
#[cfg(feature = "cache")]
|
|
||||||
pub(crate) type UnboundedStreamBody = StreamBody<UnboundedReceiver<Result<Frame<bytes::Bytes>, hyper::Error>>>;
|
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
/// Response body use in this project
|
/// Response body use in this project
|
||||||
/// - Incoming: just a type that only forwards the upstream response body to downstream.
|
/// - Incoming: just a type that only forwards the upstream response body to downstream.
|
||||||
/// - Boxed: a type that is generated from cache or synthetic response body, e.g.,, small byte object.
|
/// - Boxed: a type that is generated from cache or synthetic response body, e.g.,, small byte object.
|
||||||
/// - Streamed: another type that is generated from stream, e.g., large byte object.
|
/// - Streamed: another type that is generated from stream, e.g., large byte object.
|
||||||
pub(crate) enum ResponseBody {
|
pub enum ResponseBody {
|
||||||
Incoming(Incoming),
|
Incoming(Incoming),
|
||||||
Boxed(BoxBody),
|
Boxed(BoxBody),
|
||||||
#[cfg(feature = "cache")]
|
|
||||||
Streamed(UnboundedStreamBody),
|
Streamed(UnboundedStreamBody),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,9 +67,7 @@ impl Body for ResponseBody {
|
||||||
) -> std::task::Poll<Option<Result<Frame<Self::Data>, Self::Error>>> {
|
) -> std::task::Poll<Option<Result<Frame<Self::Data>, Self::Error>>> {
|
||||||
match self.get_mut() {
|
match self.get_mut() {
|
||||||
ResponseBody::Incoming(incoming) => Pin::new(incoming).poll_frame(cx),
|
ResponseBody::Incoming(incoming) => Pin::new(incoming).poll_frame(cx),
|
||||||
#[cfg(feature = "cache")]
|
|
||||||
ResponseBody::Boxed(boxed) => Pin::new(boxed).poll_frame(cx),
|
ResponseBody::Boxed(boxed) => Pin::new(boxed).poll_frame(cx),
|
||||||
#[cfg(feature = "cache")]
|
|
||||||
ResponseBody::Streamed(streamed) => Pin::new(streamed).poll_frame(cx),
|
ResponseBody::Streamed(streamed) => Pin::new(streamed).poll_frame(cx),
|
||||||
}
|
}
|
||||||
.map_err(RpxyError::HyperBodyError)
|
.map_err(RpxyError::HyperBodyError)
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ where
|
||||||
// Functions to generate messages
|
// Functions to generate messages
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#[allow(unused_variables)]
|
||||||
/// Manipulate a response message sent from a backend application to forward downstream to a client.
|
/// Manipulate a response message sent from a backend application to forward downstream to a client.
|
||||||
pub(super) fn generate_response_forwarded<B>(
|
pub(super) fn generate_response_forwarded<B>(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
mod proxy_h3;
|
|
||||||
mod proxy_main;
|
mod proxy_main;
|
||||||
|
mod socket;
|
||||||
|
|
||||||
|
#[cfg(any(feature = "http3-quinn", feature = "http3-s2n"))]
|
||||||
|
mod proxy_h3;
|
||||||
#[cfg(feature = "http3-quinn")]
|
#[cfg(feature = "http3-quinn")]
|
||||||
mod proxy_quic_quinn;
|
mod proxy_quic_quinn;
|
||||||
#[cfg(all(feature = "http3-s2n", not(feature = "http3-quinn")))]
|
#[cfg(all(feature = "http3-s2n", not(feature = "http3-quinn")))]
|
||||||
mod proxy_quic_s2n;
|
mod proxy_quic_s2n;
|
||||||
mod socket;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
globals::Globals,
|
globals::Globals,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue