require premium for debug module

This commit is contained in:
Bryan Stitt 2023-10-23 15:38:44 -07:00
parent cef4edc17a
commit 45fb2e5ea6
3 changed files with 14 additions and 0 deletions

@ -1633,6 +1633,16 @@ impl App {
method
)).into());
}
if method.starts_with("debug_") {
// make sure its premium
if !(self.config.free_subscriptions
|| web3_request.authorization.active_premium().await)
{
return Err(Web3ProxyError::AccessDenied(
"debug methods require an active premium account".into(),
));
}
}
if web3_request.cache_mode.is_some() {
// don't cache anything larger than 16 MiB

@ -469,6 +469,7 @@ impl CacheMode {
}
}
#[inline]
pub fn cache_jsonrpc_errors(&self) -> bool {
match self {
Self::Never => false,
@ -478,6 +479,7 @@ impl CacheMode {
}
}
#[inline]
pub fn from_block(&self) -> Option<&BlockNumAndHash> {
match self {
Self::SuccessForever => None,
@ -492,6 +494,7 @@ impl CacheMode {
!matches!(self, Self::Never)
}
#[inline]
pub fn to_block(&self) -> Option<&BlockNumAndHash> {
match self {
Self::SuccessForever => None,

@ -501,6 +501,7 @@ impl ValidatedRequest {
self.cache_mode.to_block().map(|x| *x.num())
}
#[inline]
pub fn min_block_needed(&self) -> Option<U64> {
if self.archive_request.load(atomic::Ordering::Relaxed) {
Some(U64::zero())