From 2c4586302ddad238628b0a86fd25c1ebc6d1f840 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Thu, 10 Nov 2022 22:17:22 +0000 Subject: [PATCH] clean up rpc_key_id template change --- TODO.md | 1 + config/example.toml | 2 +- web3_proxy/src/app.rs | 2 +- web3_proxy/src/bin/web3_proxy.rs | 2 +- web3_proxy/src/bin/web3_proxy_cli/check_config.rs | 14 +++++++++++--- web3_proxy/src/config.rs | 2 +- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/TODO.md b/TODO.md index 7531f2e2..7533676a 100644 --- a/TODO.md +++ b/TODO.md @@ -230,6 +230,7 @@ These are roughly in order of completition - [x] /status should include the server weights - [-] add configurable size limits to all the Caches - instead of configuring each cache with MB sizes, have one value for total memory footprint and then percentages for each cache +- [ ] test that runs check_config against example.toml - [ ] actually block unauthenticated requests instead of emitting warning of "allowing without auth during development!" diff --git a/config/example.toml b/config/example.toml index aada359e..2958ddf7 100644 --- a/config/example.toml +++ b/config/example.toml @@ -13,7 +13,7 @@ volatile_redis_max_connections = 300 volatile_redis_url = "redis://REDIS_DOMAIN:REDIS_PORT/" redirect_public_url = "https://llamanodes.com/public-rpc" -redirect_user_url = "https://llamanodes.com/dashboard/keys?key={{rpc_key_id}}" +redirect_user_url = "https://llamanodes.com/dashboard/keys?key={rpc_key_id}" sentry_url = "https://SENTRY_KEY_A.ingest.sentry.io/SENTRY_KEY_B" diff --git a/web3_proxy/src/app.rs b/web3_proxy/src/app.rs index 24cb78bc..6c6511f1 100644 --- a/web3_proxy/src/app.rs +++ b/web3_proxy/src/app.rs @@ -195,7 +195,7 @@ impl Web3ProxyApp { // safety checks on the config if let Some(redirect) = &top_config.app.redirect_user_url { assert!( - redirect.contains("{{rpc_key_id}}"), + redirect.contains("{rpc_key_id}"), "redirect_user_url user url must contain \"{{rpc_key_id}}\"" ); } diff --git a/web3_proxy/src/bin/web3_proxy.rs b/web3_proxy/src/bin/web3_proxy.rs index 60e96646..8a56865b 100644 --- a/web3_proxy/src/bin/web3_proxy.rs +++ b/web3_proxy/src/bin/web3_proxy.rs @@ -283,7 +283,7 @@ mod tests { public_requests_per_period: Some(1_000_000), response_cache_max_bytes: 10_usize.pow(7), redirect_public_url: Some("example.com/".to_string()), - redirect_user_url: Some("example.com/{{user_id}}".to_string()), + redirect_user_url: Some("example.com/{{rpc_key_id}}".to_string()), ..Default::default() }, balanced_rpcs: HashMap::from([ diff --git a/web3_proxy/src/bin/web3_proxy_cli/check_config.rs b/web3_proxy/src/bin/web3_proxy_cli/check_config.rs index 24233035..ae781eb5 100644 --- a/web3_proxy/src/bin/web3_proxy_cli/check_config.rs +++ b/web3_proxy/src/bin/web3_proxy_cli/check_config.rs @@ -1,6 +1,6 @@ use argh::FromArgs; use std::fs; -use tracing::{info, warn}; +use tracing::{error, info, warn}; use web3_proxy::config::TopConfig; #[derive(FromArgs, PartialEq, Eq, Debug)] @@ -65,8 +65,16 @@ impl CheckConfigSubCommand { warn!("app.redirect_public_url is None. Anonyoumous users will get an error page instead of a redirect") } - if top_config.app.redirect_user_url.is_none() { - warn!("app.redirect_user_url is None. Registered users will get an error page instead of a redirect") + // TODO: also check that it contains rpc_key_id! + match top_config.app.redirect_user_url { + None => { + warn!("app.redirect_user_url is None. Registered users will get an error page instead of a redirect") + } + Some(x) => { + if !x.contains("{rpc_key_id}") { + error!("redirect_user_url user url must contain \"{{rpc_key_id}}\"") + } + } } Ok(()) diff --git a/web3_proxy/src/config.rs b/web3_proxy/src/config.rs index b9235709..b4a8c4d1 100644 --- a/web3_proxy/src/config.rs +++ b/web3_proxy/src/config.rs @@ -117,7 +117,7 @@ pub struct AppConfig { /// the stats page url for an anonymous user. pub redirect_public_url: Option, - /// the stats page url for a logged in user. if set, must contain "{user_id}" + /// the stats page url for a logged in user. if set, must contain "{rpc_key_id}" pub redirect_user_url: Option, /// Optionally send errors to