Compare commits

..
4 Commits
Author SHA1 Message Date
Chris Troutner 9c70fc5007 Merge pull request #61 from Permissionless-Software-Foundation/ct-unstable
fix(whitelist): Adding splitbch.com to the whitelist
2020-11-14 17:39:41 -08:00
Chris Troutner b24b659124 fix(whitelist): Adding splitbch.com to the whitelist 2020-11-14 17:36:38 -08:00
Chris Troutner 7ad5acef34 Merge pull request #60 from Permissionless-Software-Foundation/ct-unstable
fix(rate limits): Setting anonymous rate limits to a constant
2020-11-12 09:11:48 -08:00
Chris Troutner 304a3f1d5a fix(rate limits): Setting anonymous rate limits to a constant 2020-11-12 09:10:35 -08:00
+10 -7
View File
@@ -12,10 +12,12 @@
'use strict'
const jwt = require('jsonwebtoken')
const wlogger = require('../util/winston-logging')
const config = require('../../config')
const jwt = require('jsonwebtoken')
const ANON_LIMITS = 50
// Redis
const redisOptions = {
@@ -111,7 +113,7 @@ class RateLimits {
}
// Default value is 50 points per request = 20 RPM
let rateLimit = 50
let rateLimit = ANON_LIMITS
// Only evaluate the JWT token if the user is not using Basic Authentication.
if (!req.locals.proLimit) {
@@ -146,6 +148,7 @@ class RateLimits {
origin &&
(origin.toString().indexOf('wallet.fullstack.cash') > -1 ||
origin.toString().indexOf('sandbox.fullstack.cash') > -1 ||
origin.toString().indexOf('splitbch.com') > -1 ||
origin === 'slp-api')
) {
pointsToConsume = 10
@@ -199,7 +202,7 @@ class RateLimits {
// Calculates the points consumed, based on the jwt information and the route
// requested.
calcPoints (jwtInfo) {
let retVal = 50 // By default, use anonymous tier.
let retVal = ANON_LIMITS // By default, use anonymous tier.
try {
// console.log(`jwtInfo: ${JSON.stringify(jwtInfo, null, 2)}`)
@@ -218,12 +221,12 @@ class RateLimits {
if (level40Routes.includes(resource)) {
if (apiLevel >= 40) retVal = 10
// else if (apiLevel >= 10) retVal = 10
else retVal = 50
else retVal = ANON_LIMITS
// Normal indexer routes
} else if (level30Routes.includes(resource)) {
if (apiLevel >= 30) retVal = 10
else retVal = 50
else retVal = ANON_LIMITS
// Full node tier
} else if (apiLevel >= 20) {
@@ -231,7 +234,7 @@ class RateLimits {
// Free tier, full node only.
} else {
retVal = 50
retVal = ANON_LIMITS
}
}
@@ -239,7 +242,7 @@ class RateLimits {
} catch (err) {
wlogger.error('Error in route-ratelimit.js/calcPoints()')
// throw err
retVal = 50
retVal = ANON_LIMITS
}
return retVal