diff --git a/src/lib/quota/index.js b/src/lib/quota/index.js index 0383d35..937f835 100644 --- a/src/lib/quota/index.js +++ b/src/lib/quota/index.js @@ -38,5 +38,14 @@ function add(req, count) { return limiter.add(identifier, count) } +function isProxyNetwork(req) { + if (!constants.quota.enabled) return false // no need to try to perform detection if we didn't even load the lists + + const ip = getIPFromReq(req) + const identifier = getIdentifier(ip) + return identifier === "proxy" +} + module.exports.remaining = remaining module.exports.add = add +module.exports.isProxyNetwork = isProxyNetwork diff --git a/src/site/api/routes.js b/src/site/api/routes.js index bc48b86..71751e3 100644 --- a/src/site/api/routes.js +++ b/src/site/api/routes.js @@ -159,7 +159,8 @@ module.exports = [ } else if (error === constants.symbols.extractor_results.AGE_RESTRICTED) { return render(403, "pug/age_gated.pug", {settings}) } else if (error === constants.symbols.QUOTA_REACHED) { - return render(429, "pug/quota_reached.pug") + const isProxyNetwork = quota.isProxyNetwork(req) + return render(429, "pug/quota_reached.pug", {isProxyNetwork}) } else { throw error } @@ -302,7 +303,8 @@ module.exports = [ } else if (error === constants.symbols.RATE_LIMITED) { return render(503, "pug/blocked_graphql.pug") } else if (error === constants.symbols.QUOTA_REACHED) { - return render(429, "pug/quota_reached.pug") + const isProxyNetwork = quota.isProxyNetwork(req) + return render(429, "pug/quota_reached.pug", {isProxyNetwork}) } else { throw error } diff --git a/src/site/pug/quota_reached.pug b/src/site/pug/quota_reached.pug index ac12497..85b1e49 100644 --- a/src/site/pug/quota_reached.pug +++ b/src/site/pug/quota_reached.pug @@ -1,3 +1,5 @@ +//- Needs isProxyNetwork + include includes/error.pug doctype html @@ -10,5 +12,11 @@ html | Each person has a limited number of requests to Bibliogram. | You have reached that limit. You cannot load any more data on this instance. | Your quota will reset automatically after some time has passed. + if isProxyNetwork + | + | + | However, this website has detected that you are using a proxy network, like Tor or a VPN. + | To prevent bot abuse, all users on proxy networks share the same request quota. + | | |