feat: very unstalbe implementation of initial file cache
This commit is contained in:
parent
719e845d5e
commit
c20e80b64c
22 changed files with 340 additions and 32 deletions
|
|
@ -12,27 +12,28 @@ publish = false
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[features]
|
||||
default = ["http3-quinn"]
|
||||
default = ["http3-quinn", "cache"]
|
||||
http3-quinn = ["rpxy-lib/http3-quinn"]
|
||||
http3-s2n = ["rpxy-lib/http3-s2n"]
|
||||
cache = []
|
||||
|
||||
[dependencies]
|
||||
rpxy-lib = { path = "../rpxy-lib/", default-features = false, features = [
|
||||
"sticky-cookie",
|
||||
] }
|
||||
|
||||
anyhow = "1.0.72"
|
||||
anyhow = "1.0.73"
|
||||
rustc-hash = "1.1.0"
|
||||
serde = { version = "1.0.183", default-features = false, features = ["derive"] }
|
||||
derive_builder = "0.12.0"
|
||||
tokio = { version = "1.29.1", default-features = false, features = [
|
||||
tokio = { version = "1.31.0", default-features = false, features = [
|
||||
"net",
|
||||
"rt-multi-thread",
|
||||
"time",
|
||||
"sync",
|
||||
"macros",
|
||||
] }
|
||||
async-trait = "0.1.72"
|
||||
async-trait = "0.1.73"
|
||||
rustls-pemfile = "1.0.3"
|
||||
|
||||
# config
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use crate::{
|
|||
use rpxy_lib::{reexports::Uri, AppConfig, ProxyConfig, ReverseProxyConfig, TlsConfig, UpstreamUri};
|
||||
use rustc_hash::FxHashMap as HashMap;
|
||||
use serde::Deserialize;
|
||||
use std::{fs, net::SocketAddr};
|
||||
use std::{fs, net::SocketAddr, path::PathBuf};
|
||||
|
||||
#[derive(Deserialize, Debug, Default, PartialEq, Eq, Clone)]
|
||||
pub struct ConfigToml {
|
||||
|
|
@ -32,10 +32,17 @@ pub struct Http3Option {
|
|||
pub max_idle_timeout: Option<u64>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "cache")]
|
||||
#[derive(Deserialize, Debug, Default, PartialEq, Eq, Clone)]
|
||||
pub struct CacheOption {
|
||||
pub cache_dir: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Default, PartialEq, Eq, Clone)]
|
||||
pub struct Experimental {
|
||||
#[cfg(any(feature = "http3-quinn", feature = "http3-s2n"))]
|
||||
pub h3: Option<Http3Option>,
|
||||
pub cache: Option<CacheOption>,
|
||||
pub ignore_sni_consistency: Option<bool>,
|
||||
}
|
||||
|
||||
|
|
@ -160,6 +167,14 @@ impl TryInto<ProxyConfig> for &ConfigToml {
|
|||
if let Some(ignore) = exp.ignore_sni_consistency {
|
||||
proxy_config.sni_consistency = !ignore;
|
||||
}
|
||||
|
||||
if let Some(cache_option) = &exp.cache {
|
||||
proxy_config.cache_enabled = true;
|
||||
proxy_config.cache_dir = match &cache_option.cache_dir {
|
||||
Some(cache_dir) => Some(PathBuf::from(cache_dir)),
|
||||
None => Some(PathBuf::from(CACHE_DIR)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(proxy_config)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
pub const LISTEN_ADDRESSES_V4: &[&str] = &["0.0.0.0"];
|
||||
pub const LISTEN_ADDRESSES_V6: &[&str] = &["[::]"];
|
||||
pub const CONFIG_WATCH_DELAY_SECS: u32 = 20;
|
||||
pub const CACHE_DIR: &str = "./cache";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue