From 3075514e22559e7680eed608b5245ff0217b17d7 Mon Sep 17 00:00:00 2001 From: Tom Beynon Date: Mon, 27 May 2024 16:44:27 +0100 Subject: [PATCH 1/2] Force rate limiting of certain domains --- status/healthMonitor.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/status/healthMonitor.js b/status/healthMonitor.js index 429d7d8..8cab9d1 100644 --- a/status/healthMonitor.js +++ b/status/healthMonitor.js @@ -123,6 +123,12 @@ function HealthMonitor() { } } } + const RATE_LIMITED_DOMAINS = ['publicnode.com', 'pupmos.network'] + const hostname = new URL(finalAddress).hostname + // Partial match hostname to avoid rate limiting + if(RATE_LIMITED_DOMAINS.some(domain => hostname.includes(domain))){ + rateLimitedAt = Date.now() + } rateLimited = rateLimitedAt && rateLimitedAt > Date.now() - 1000 * RATE_LIMIT_COOLDOWN let nowAvailable = false; From e412914b168906a57fbad0a380bed2ae0329a97e Mon Sep 17 00:00:00 2001 From: Tom Beynon Date: Mon, 27 May 2024 16:54:30 +0100 Subject: [PATCH 2/2] Only force rate limiting on success --- status/healthMonitor.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/status/healthMonitor.js b/status/healthMonitor.js index 8cab9d1..deb1356 100644 --- a/status/healthMonitor.js +++ b/status/healthMonitor.js @@ -122,12 +122,12 @@ function HealthMonitor() { errorCount = 0; } } - } - const RATE_LIMITED_DOMAINS = ['publicnode.com', 'pupmos.network'] - const hostname = new URL(finalAddress).hostname - // Partial match hostname to avoid rate limiting - if(RATE_LIMITED_DOMAINS.some(domain => hostname.includes(domain))){ - rateLimitedAt = Date.now() + // Force rate limiting of certain problematic domains + const RATE_LIMITED_DOMAINS = ['publicnode.com', 'pupmos.network'] + const hostname = new URL(finalAddress).hostname + if(RATE_LIMITED_DOMAINS.some(domain => hostname.includes(domain))){ + rateLimitedAt = Date.now() + } } rateLimited = rateLimitedAt && rateLimitedAt > Date.now() - 1000 * RATE_LIMIT_COOLDOWN