diff --git a/Makefile b/Makefile index ca21af4..59a6390 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ docker-run: run: - REPLEX_PORT=80 REPLEX_INCLUDE_WATCHED=0 REPLEX_REDIRECT_STREAMS=0 REPLEX_DISABLE_RELATED=1 REPLEX_DISABLE_LEAF_COUNT=0 REPLEX_DISABLE_USER_STATE=1 REPLEX_ENABLE_CONSOLE=0 REPLEX_CACHE_TTL=25 REPLEX_HOST=https://46-4-30-217.01b0839de64b49138531cab1bf32f7c2.plex.direct:42405 RUST_LOG="info,replex=debug" cargo watch -x run + REPLEX_PORT=80 REPLEX_INCLUDE_WATCHED=0 REPLEX_REDIRECT_STREAMS=0 REPLEX_DISABLE_RELATED=1 REPLEX_DISABLE_LEAF_COUNT=0 REPLEX_DISABLE_USER_STATE=1 REPLEX_ENABLE_CONSOLE=0 REPLEX_CACHE_TTL=5 REPLEX_HOST=https://46-4-30-217.01b0839de64b49138531cab1bf32f7c2.plex.direct:42405 RUST_LOG="info,replex=debug" cargo watch -x run # run: # REPLEX_ENABLE_CONSOLE=0 REPLEX_CACHE_TTL=0 REPLEX_HOST=https://46-4-30-217.01b0839de64b49138531cab1bf32f7c2.plex.direct:42405 RUST_LOG="info" cargo run diff --git a/README.md b/README.md index cb73b02..95702f4 100644 --- a/README.md +++ b/README.md @@ -79,11 +79,6 @@ Settings are set via [environment variables](https://kinsta.com/knowledgebase/wh | REPLEX_REDIRECT_STREAMS | false | Redirect streams to another endpoint. | | REPLEX_REDIRECT_STREAMS_URL | REPLEX_HOST | Alternative streams endpoint | | REPLEX_DISABLE_RELATED | false | See: https://github.com/sarendsen/replex/issues/26. | -| REPLEX_SSL_ENABLE | false | Enable automatic SSL generation. http will be disabled | -| | | (stored in /data/acme/letsencrypt so make sure to mount a volume) | -| REPLEX_SSL_DOMAIN | | Domain to request SSL certificate for when REPLEX_SSL_ENABLE is enabled | - -Note: Automatic SSl is untested ## Mixed rows diff --git a/src/cache.rs b/src/cache.rs index 3e9363d..39c4af6 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -143,8 +143,9 @@ impl CacheManager { } pub struct RequestIssuer { - use_scheme: bool, + // use_scheme: bool, use_authority: bool, + use_local_addr: bool, use_path: bool, use_query: bool, use_method: bool, @@ -161,8 +162,9 @@ impl RequestIssuer { /// Create a new `RequestIssuer`. pub fn new() -> Self { Self { - use_scheme: true, - use_authority: true, + // use_scheme: true, + use_authority: false, + use_local_addr: true, use_path: true, use_query: true, use_method: true, @@ -172,15 +174,19 @@ impl RequestIssuer { } } /// Whether to use request's uri scheme when generate the key. - pub fn use_scheme(mut self, value: bool) -> Self { - self.use_scheme = value; - self - } + // pub fn use_scheme(mut self, value: bool) -> Self { + // self.use_scheme = value; + // self + // } /// Whether to use request's uri authority when generate the key. pub fn use_authority(mut self, value: bool) -> Self { self.use_authority = value; self } + pub fn use_local_addr(mut self, value: bool) -> Self { + self.use_local_addr = value; + self + } /// Whether to use request's uri path when generate the key. pub fn use_path(mut self, value: bool) -> Self { self.use_path = value; @@ -215,18 +221,23 @@ impl CacheIssuer for RequestIssuer { _depot: &Depot, ) -> Option { let mut key = String::new(); - key.push_str("uri::"); - if self.use_scheme { - if let Some(scheme) = req.uri().scheme_str() { - key.push_str(scheme); - key.push_str("://"); - } - } + key.push_str("uri::http://"); // always http as we use local addr + // if self.use_scheme { + // if let Some(scheme) = req.uri().scheme_str() { + // key.push_str(scheme); + // key.push_str("://"); + // } + // } if self.use_authority { if let Some(authority) = req.uri().authority() { key.push_str(authority.as_str()); } } + if self.use_local_addr { + // key.push_str(format!("{}", req.local_addr().into())); + // dbg!(format!("{}", req.local_addr())); + key.push_str(req.local_addr().to_string().replace("socket://", "").as_str()); + } if self.use_path { key.push_str(req.uri().path()); } @@ -255,6 +266,7 @@ impl CacheIssuer for RequestIssuer { key.push_str("|X-Plex-Language::"); key.push_str(req.header("X-Plex-Language").unwrap()); } + dbg!(&key); Some(key) } } diff --git a/src/config.rs b/src/config.rs index 534c2be..1b108fc 100644 --- a/src/config.rs +++ b/src/config.rs @@ -58,7 +58,7 @@ pub struct Config { } fn default_cache_ttl() -> u64 { - 5 * 60 + 15 * 60 // 15 minutes } // fn default_port() -> u64 {