Notify users if they were blocked due to proxy

This commit is contained in:
Cadence Ember 2020-07-31 03:19:55 +12:00
parent f0a28d485f
commit d4f9af44b0
No known key found for this signature in database
GPG Key ID: 128B99B1B74A6412
3 changed files with 21 additions and 2 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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.
|
|
|